Commit graph

22413 commits

Author SHA1 Message Date
glozow
821f5c824f
Merge bitcoin/bitcoin#25487: [kernel 3b/n] Decouple {Dump,Load}Mempool from ArgsManager
cb3e9a1e3f Move {Load,Dump}Mempool to kernel namespace (Carl Dong)
aa30676541 Move DEFAULT_PERSIST_MEMPOOL out of libbitcoinkernel (Carl Dong)
06b88ffb8a LoadMempool: Pass in load_path, stop using gArgs (Carl Dong)
b857ac60d9 test/fuzz: Invoke LoadMempool via CChainState (Carl Dong)
b3267258b0 Move FopenFn to fsbridge namespace (Carl Dong)
ae1e8e3756 mempool: Use NodeClock+friends for LoadMempool (Carl Dong)
f9e8e5719f mempool: Improve comments for [GS]etLoadTried (Carl Dong)
813962da0b scripted-diff: Rename m_is_loaded -> m_load_tried (Carl Dong)
413f4bb52b DumpMempool: Pass in dump_path, stop using gArgs (Carl Dong)
bd4407817e DumpMempool: Use std::chrono instead of weird int64_t arthmetics (Carl Dong)
c84390b741 test/mempool_persist: Test manual savemempool when -persistmempool=0 (Carl Dong)

Pull request description:

  This is part of the `libbitcoinkernel` project: #24303, https://github.com/bitcoin/bitcoin/projects/18

  -----

  This PR moves `{Dump,Load}Mempool` into its own `kernel/mempool_persist` module and introduces `ArgsManager` `node::` helpers in `node/mempool_persist_args`to remove the scattered calls to `GetBoolArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)`.

  More context can be gleaned from the commit messages.

  -----

  One thing I was reflecting on as I wrote this was that in the long run, I think we should probably invert the validation <-> mempool relationship. Instead of mempool not depending on validation, it might make more sense to have validation not depend on mempool. Not super urgent since `libbitcoinkernel` will include both validation and mempool, but perhaps something for the future.

ACKs for top commit:
  glozow:
    re ACK cb3e9a1e3f via `git range-diff 7ae032e...cb3e9a1`
  MarcoFalke:
    ACK cb3e9a1e3f 🔒
  ryanofsky:
    Code review ACK cb3e9a1e3f

Tree-SHA512: 979d7237c3abb5a1dd9b5ad3dbf3b954f906a6d8320ed7b923557f41a4472deccae3e8a6bca0018c8e7a3c4a93afecc502acd1e26756f2054f157f1c0edd939d
2022-07-18 16:09:27 +01:00
MacroFake
c395c8d6bb
Merge bitcoin/bitcoin#25624: fuzz: Fix assert bug in txorphan target
2315830491 fuzz: Fix assert bug in txorphan target (chinggg)

Pull request description:

  Fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=48914.

  It is possible to construct big tx that got rejected in `AddTx`, so we cannot assume tx will be added successfully. We can only guarantee tx will not be added if orphanage already has it.

ACKs for top commit:
  MarcoFalke:
    lgtm ACK 2315830491

Tree-SHA512: e173bc1a932639746de1192ed238e2e2318899f55371febb598facd0e811d8c54997f074f5e761757e1ffd3ae76d8edf9d673f020b2d97d5762ac656f632be81
2022-07-18 15:05:39 +02:00
fanquake
c5fa7ed409
Merge bitcoin/bitcoin#25544: wallet: don't iter twice when getting the cached debit/credit amount
757216e31c wallet: don't iter twice when getting the cached debit/credit amount (Antoine Poinsot)

Pull request description:

  A small optimization i stumbled upon while looking at something else. Figured it could be worth a PR.

  Instead of calling GetCachableAmount twice, which will result in
  iterating through all the transaction txins/txouts and calling
  GetDebit/GetCredit (which lock cs_wallet), just merge the filters and do
  it once.

ACKs for top commit:
  achow101:
    ACK 757216e31c
  aureleoules:
    ACK 757216e31c.

Tree-SHA512: 0dbbdd24231380196e929dce572752e6be1d69457252a7215e279e71d6199483b516f64019ae999a91dbce7fdd86f8bf0336b6e151cca93cbcf51bc854e838a2
2022-07-18 10:37:45 +01:00
MacroFake
fae5ce8795
univalue: Return more detailed type check error messages 2022-07-18 11:31:36 +02:00
MacroFake
fafab147e7
move-only: Move UniValue::getInt definition to keep class with definitions only
Can be reviewed with the git options

--color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
2022-07-18 10:37:00 +02:00
fanquake
1f0c83f430
refactor: remove BOOST_*_TEST_ macros 2022-07-18 09:15:18 +01:00
fanquake
70d807c355
refactor: integrate no_nul into univalue unitester 2022-07-18 09:15:18 +01:00
fanquake
98a0ae6b24
doc: remove references to downstream
Having references to downstream no-longer make sense now that we've
unsubtree'd.
2022-07-18 09:15:18 +01:00
MacroFake
55b76ac1c0
Merge bitcoin/bitcoin#25615: rpc: add missing description in gettxout help text
743a84a5f6 fix gettxout help text (Marnix)

Pull request description:

  replaces #25578

  Add help text to asm & hex (like everywhere else).
  I've also changed two `RPCResult::Type::STR` to `RPCResult::Type::STR_HEX`

Top commit has no ACKs.

Tree-SHA512: 4109d6abddf71b24899f3252545248bb0c7cc366eb994d30927eb300d0b939a14b8140bac4a4c2bd45098a406666dbe1feb10da8dec923777bb8ed26784dfd54
2022-07-17 08:52:53 +02:00
chinggg
2315830491 fuzz: Fix assert bug in txorphan target 2022-07-17 08:04:24 +08:00
Hennadii Stepanov
6decdedaf9
Merge bitcoin-core/gui#469: Load Base64 PSBT string from file
2c3ee4c347 gui: Load Base64 PSBT string from file (Andrew Chow)

Pull request description:

  Some .psbt files may have the PSBT as a base64 string instead of in binary. We should be able to load those files.

ACKs for top commit:
  jarolrod:
    tACK 2c3ee4c347
  shaavan:
    ACK 2c3ee4c347

Tree-SHA512: 352b0611693c8989ea7d1b8d494ea58c69dc15cf81b8d62271541832e74b0a0399cb6ed4e686ab7c741cb4e5374527e054a9ecfe7355bc6f77d8fdd13569ab76
2022-07-15 21:18:58 +01:00
Carl Dong
cb3e9a1e3f Move {Load,Dump}Mempool to kernel namespace
Also:
1. Add the newly introduced kernel/mempool_persist.cpp to IWYU CI script
2. Add chrono mapping for iwyu
2022-07-15 12:26:20 -04:00
Carl Dong
aa30676541 Move DEFAULT_PERSIST_MEMPOOL out of libbitcoinkernel
It is no longer used by anything inside libbitcoinkernel, move it to
node/mempool_persist_args.h where it belongs.
2022-07-15 12:26:20 -04:00
Carl Dong
06b88ffb8a LoadMempool: Pass in load_path, stop using gArgs
Also:
1. Have CChainState::LoadMempool and ::ThreadImport take in paths and
   pass it through untouched to LoadMempool.
2. Make LoadMempool exit early if the load_path is empty.
3. Adjust the call to ::ThreadImport in ::AppInitMain to correctly pass
   in an empty path if mempool persistence is disabled.
2022-07-15 12:26:20 -04:00
Carl Dong
b857ac60d9 test/fuzz: Invoke LoadMempool via CChainState
Not only does this increase coverage, it is also more correct in that
when ::LoadMempool is called with a mempool and chainstate, it calls
AcceptToMemoryPool with just the chainstate.

AcceptToMemoryPool will then act on the chainstate's mempool via
CChainState::GetMempool, which may be different from the mempool
originally passed to ::LoadMempool. (In this fuzz test's case, it
definitely is different)

Also, move DummyChainstate to its own file since it's now used by the
validation_load_mempool fuzz test to replace CChainState's m_mempool.
2022-07-15 12:26:00 -04:00
Carl Dong
b3267258b0 Move FopenFn to fsbridge namespace
[META] In a future commit in this patchset, it will be used by more than
       just validation, and it needs to align with fopen anyway.
2022-07-15 12:25:51 -04:00
Andrew Chow
4c495413e1 Disallow encryption of watchonly wallets
Watchonly wallets do not have any private keys to encrypt. It does not
make sense to encrypt such wallets, so disable the option to encrypt
them.

This avoids an assertion that can be hit when encrypting watchonly descriptor
wallets.
2022-07-15 11:41:43 -04:00
Carl Dong
ae1e8e3756 mempool: Use NodeClock+friends for LoadMempool 2022-07-15 11:35:13 -04:00
Carl Dong
f9e8e5719f mempool: Improve comments for [GS]etLoadTried
Also change the param name for SetLoadTried to load_tried.
2022-07-15 11:35:13 -04:00
Carl Dong
813962da0b scripted-diff: Rename m_is_loaded -> m_load_tried
m_is_loaded/IsLoaded() doesn't actually indicate whether or not the
mempool was successfully, loaded, but rather if a load has been
attempted and did not result in a catastrophic ShutdownRequested.

-BEGIN VERIFY SCRIPT-
find_regex="\bm_is_loaded\b" \
    && git grep -l -E "$find_regex" \
        | xargs sed -i -E "s@$find_regex@m_load_tried@g"

find_regex="\bIsLoaded\b" \
    && git grep -l -E "$find_regex" \
        | xargs sed -i -E "s@$find_regex@GetLoadTried@g"

find_regex="\bSetIsLoaded\b" \
    && git grep -l -E "$find_regex" \
        | xargs sed -i -E "s@$find_regex@SetLoadTried@g"
-END VERIFY SCRIPT-
2022-07-15 11:35:13 -04:00
fanquake
a969b2fcd3
Merge bitcoin/bitcoin#25551: refactor: Throw exception on invalid Univalue pushes over silent ignore
fa277cd55d univalue: Throw exception on invalid pushes over silent ignore (MacroFake)
ccccc17b91 refactor: Default options in walletcreatefundedpsbt to VOBJ instead of VNULL (MacroFake)

Pull request description:

  The return value of the `push*` helpers is never used, but important to determine if the operation was successful. One way to fix this would be to add the "nodiscard" attribute. However, this would make the code (and this diff) overly verbose for no reason.

  So fix it by removing the never used return value. Also, fail verbosely in case of a programming mistake.

ACKs for top commit:
  furszy:
    code ACK fa277cd5

Tree-SHA512: ef212a5bf5ae6bbad20acc4dafa3715521e81544185988d1eab724f440e4864a27e686aff51d5bc51b3017892c2eb8e577bcb8f37e8ddbaa0d8833bb622f2f9c
2022-07-15 16:33:55 +01:00
Carl Dong
413f4bb52b DumpMempool: Pass in dump_path, stop using gArgs
Also introduce node::{ShouldPersistMempool,MempoolPath} helper functions
in node/mempool_persist_args.{h,cpp} which are used by non-kernel
DumpMempool callers to determine whether or not to automatically dump
the mempool and where to dump it to.
2022-07-15 11:30:50 -04:00
Carl Dong
bd4407817e DumpMempool: Use std::chrono instead of weird int64_t arthmetics
This makes it so that DumpMempool doesn't depend on MICRO anymore
2022-07-15 11:30:47 -04:00
Andrew Chow
85b601e043
Merge bitcoin/bitcoin#24148: Miniscript support in Output Descriptors
ffc79b8e49 qa: functional test Miniscript watchonly support (Antoine Poinsot)
bfb036756a Miniscript support in output descriptors (Antoine Poinsot)
4a082887be qa: better error reporting on descriptor parsing error (Antoine Poinsot)
d25d58bf5f miniscript: add a helper to find the first insane sub with no child (Antoine Poinsot)
c38c7c5817 miniscript: don't check for top level validity at parsing time (Antoine Poinsot)

Pull request description:

  This adds Miniscript support for Output Descriptors without any signing logic (yet). See the OP of #24147 for a description of Miniscript and a rationale of having it in Bitcoin Core.
  On its own, this PR adds "watchonly" support for Miniscript descriptors in the descriptor wallet. A follow-up adds signing support.

  A minified corpus of Miniscript Descriptors for the `descriptor_parse` fuzz target is available at https://github.com/bitcoin-core/qa-assets/pull/92.
  The Miniscript descriptors used in the unit tests here and in #24149 were cross-tested against the Rust implementation at https://github.com/rust-bitcoin/rust-miniscript.

  This PR contains code and insights from Pieter Wuille.

ACKs for top commit:
  Sjors:
    re-utACK ffc79b8e49
  achow101:
    ACK ffc79b8e49
  w0xlt:
    reACK ffc79b8e49

Tree-SHA512: 02d919d38bb626d3c557eca3680ce71117739fa161b7a92cfdb6c9c432ed88870b1ed127ba24248574c40c7428217d7e9bdd986fd8cd7c51fae8c776e1271fb9
2022-07-14 14:54:19 -04:00
Marnix
743a84a5f6 fix gettxout help text 2022-07-14 20:53:23 +02:00
John Newbery
8d8eeb422e [net processing] Remove CNode::nLocalServices 2022-07-14 15:25:15 +02:00
dergoegge
5961f8eea1 [net] Return CService from GetLocalAddrForPeer and GetLocalAddress 2022-07-14 15:24:00 +02:00
John Newbery
d9079fe18d [net processing] Remove CNode::nServices
Use Peer::m_their_services instead
2022-07-14 14:50:44 +02:00
John Newbery
7d1c036934 [net processing] Replace fHaveWitness with CanServeWitnesses() 2022-07-14 14:49:31 +02:00
John Newbery
f65e83d51b [net processing] Remove fClient and m_limited_node
fClient is replaced by CanServeBlocks(), and m_limited_node is replaced
by IsLimitedPeer().
2022-07-14 14:48:41 +02:00
John Newbery
fc5eb528f7 [tests] Connect peer in outbound_slow_chain_eviction by sending p2p messages
Prior to this commit, the peer was connected, and then the services and
connectivity fields in the CNode object were manually set. Instead, send
p2p `version` and `verack` messages, and have net_processing's internal
logic set the state of the node.

This ensures that the node's internal state is consistent with how it
would be set in the live code.

Prior to this commit, `dummyNode1.nServices` was set to `NODE_NONE`
which was not a problem since `CNode::fClient` and
`CNode::m_limited_node` are default initialised to false. Now that we
are doing the actual version handshake, the values of `fClient` and
`m_limited_node` are set during the handshake and cause the test to fail
if we do not set `dummyNode1.nServices` to a reasonable value
(NODE_NETWORK | NODE_WITNESS).
2022-07-14 14:44:44 +02:00
John Newbery
1f52c47d5c [net processing] Add m_our_services and m_their_services to Peer
Track services offered by us and the peer in the Peer object.
2022-07-14 14:44:44 +02:00
Carl Dong
ce8b0f971b Use designated initializers for ChainstateManager::Options
This wasn't available at the time when ChainstateManager::Options was
introduced but is helpful to be explicit and ensure correctness.
2022-07-14 08:35:23 -04:00
Carl Dong
3837700267 Move ChainstateManagerOpts into kernel:: namespace
It should have been there in the first place.
2022-07-14 08:27:54 -04:00
Antoine Poinsot
bfb036756a
Miniscript support in output descriptors
Miniscript descriptors are defined under P2WSH context (either `wsh()`
or `sh(wsh())`).
Only sane Miniscripts are accepted, as insane ones (although valid by
type) can have surprising behaviour with regard to malleability
guarantees and resources limitations.
As Miniscript descriptors are longer and more complex than "legacy"
descriptors, care was taken in error reporting to help a user determine
for what reason a provided Miniscript is insane.

Co-authored-by: Pieter Wuille <pieter.wuille@gmail.com>
2022-07-14 12:11:44 +02:00
Antoine Poinsot
4a082887be
qa: better error reporting on descriptor parsing error
A nit, but was helpful when writing unit tests for Miniscript parsing
2022-07-14 12:03:50 +02:00
Antoine Poinsot
d25d58bf5f
miniscript: add a helper to find the first insane sub with no child
This is helpful for finer grained descriptor parsing error: when there
are multiple errors to report in a Miniscript descriptor start with the
"smallest" fragments: the ones closer to be a leaf.

Co-Authored-By: Pieter Wuille <pieter@wuille.net>
2022-07-14 12:03:49 +02:00
Antoine Poinsot
c38c7c5817
miniscript: don't check for top level validity at parsing time
Letting the caller perform the checks allows for finer-grained error
reporting.
2022-07-14 12:03:49 +02:00
MacroFake
062b9db0cc
Merge bitcoin/bitcoin#25594: refactor: Return BResult from restoreWallet
fa475e9c79 refactor: Return BResult from restoreWallet (MacroFake)
fa8de09edc Prepare BResult for non-copyable types (MacroFake)

Pull request description:

  This avoids the `error` in-out param (and if `warnings` is added to `BResult`, it will avoid passing that in-out param as well).

  Also, as it is needed for this change, prepare `BResult` for non-copyable types.

ACKs for top commit:
  w0xlt:
    reACK fa475e9c79
  ryanofsky:
    Code review ACK fa475e9c79. Changes since last review were replacing auto with explicit type and splitting commits

Tree-SHA512: 46350883572f13721ddd198f5dfb88d2fa58ebcbda416f74da3563ea15c920fb1e6ff30558526a4ac91c36c21e6afe27751a4e51b7b8bcbcbe805209f4e9014b
2022-07-14 10:04:42 +02:00
MacroFake
8efa73e7ce
Merge bitcoin/bitcoin#25557: p2p: Eliminate atomic for m_last_getheaders_timestamp
613e221149 test: remove unnecessary parens (Suhas Daftuar)
e939cf2b76 Remove atomic for m_last_getheaders_timestamp (Suhas Daftuar)

Pull request description:

  Eliminate the unnecessary atomic guarding `m_last_getheaders_timestamp`, which is only accessed in a single thread (thanks to MarcoFalke for pointing this out).

  Also address a nit that came up in #25454.

ACKs for top commit:
  MarcoFalke:
    review ACK 613e221149
  vasild:
    ACK 613e221149

Tree-SHA512: 6d6c473735b450b8ad43aae5cf16ed419154d72f4a05c0a6ce6f26caecab9db2361041398b70bf9395611c107d50897f501fa5fdbabb2891144bbc2b479dfdad
2022-07-14 09:55:44 +02:00
MacroFake
fa277cd55d
univalue: Throw exception on invalid pushes over silent ignore 2022-07-13 18:05:39 +02:00
MacroFake
ccccc17b91
refactor: Default options in walletcreatefundedpsbt to VOBJ instead of VNULL
This should not change behavior and makes the code consistent with other
places.
2022-07-13 18:04:23 +02:00
fanquake
c30b3e90f0
Merge bitcoin/bitcoin#25472: build: Increase MS Visual Studio minimum version
630c1711b4 refactor: Drop no longer needed `util/designator.h` (Hennadii Stepanov)
88ec5d40dc build: Increase MS Visual Studio minimum version (Hennadii Stepanov)
555f9dd5d3 rpc, refactor: Add `decodepsbt_outputs` (Hennadii Stepanov)
0c432cbbfa rpc, refactor: Add `decodepsbt_inputs` (Hennadii Stepanov)
01d95a3964 rpc, refactor: Add `getblock_prevout` (Hennadii Stepanov)

Pull request description:

  Visual Studio 2022 with `/std:c++20` supports [designated initializers](https://github.com/bitcoin/bitcoin/pull/24531).

ACKs for top commit:
  sipsorcery:
    reACK 630c1711b4.

Tree-SHA512: 5b8933940dd69061c6b077512168bebb6fea05d429b63ffbab191950798b4c825e8484b1a651db0ae13f97eae481097d3c16395659c0f3b9f847af2aaf44b65d
2022-07-13 16:18:44 +01:00
fanquake
081965ccc3
Merge bitcoin/bitcoin#25464: rpc: Reduce Univalue push_backV peak memory usage in listtransactions
fa8a1c0696 rpc: Fix Univalue push_backV OOM in listtransactions (MacroFake)

Pull request description:

  Related to, but not intended as a fix for #25229.

  Currently the RPC will have the same data stored thrice:

  * `UniValue ret` (memory filled by `ListTransactions`)
  * `std::vector<UniValue> vec` (constructed by calling `push_backV`)
  * `UniValue result` (the actual result, memory filled by `push_backV`)

  Fix this by filling the memory only once:

  * `std::vector<UniValue> ret` (memory filled by `ListTransactions`)
  * Pass iterators to `push_backV` instead of creating a full copy
  * Move memory into `UniValue result` instead of copying it

ACKs for top commit:
  shaavan:
    Code Review ACK fa8a1c0696

Tree-SHA512: 1c3ca40fc8497134a4141195160e4aa9fe72b3c00c5998c972b58ad0eb498ebea05013f9105bb80e7264c9db1d0e7a2032396a8a4af1f326d831fbee20f32ea3
2022-07-13 15:58:53 +01:00
Suhas Daftuar
e939cf2b76 Remove atomic for m_last_getheaders_timestamp
This variable is only used in a single thread, so no atomic or mutex is
necessary to guard it.
2022-07-12 13:38:14 -04:00
MacroFake
fa475e9c79
refactor: Return BResult from restoreWallet 2022-07-12 19:20:01 +02:00
MacroFake
fa8de09edc
Prepare BResult for non-copyable types 2022-07-12 19:19:49 +02:00
MacroFake
1d89fc695a
Merge bitcoin/bitcoin#25324: refactor: add most of src/util to iwyu
07f2c25d04 refactor: add most of src/util to iwyu (fanquake)

Pull request description:

  These files change infrequently, and not much header shuffling is required.

  We don't add everything in src/util/ yet, because IWYU makes some
  dubious suggestions, which I'm going to follow up with upstream.

  Soon we'll swap `src/util/xyz.cpp` for just `src/util/`.

ACKs for top commit:
  hebasto:
    ACK 07f2c25d04, I have reviewed the code and it looks OK, I agree it can be merged.

Tree-SHA512: 07d76435c2bff1a62c4967eb0efaafe619cc3bbaf4166741d8520927b24336c01aee59822f8082ee2a01e15046a0f5d506b4b23a6e40ceb750f3226ed8167847
2022-07-12 18:05:59 +02:00
MacroFake
46fcb52cb1
Merge bitcoin/bitcoin#24944: rpc: add getblockfrompeer RPCTypeCheck and invalid input test coverage
2ef5294a5b rpc: add RPCTypeCheck for getblockfrompeer inputs (Jon Atack)
734b9669ff test: add getblockfrompeer coverage of invalid inputs (Jon Atack)

Pull request description:

  The new getblockfrompeer RPC lacks test coverage for invalid arguments, and its error messages are not harmonized with the existing RPCs.

  Fix all issues.

ACKs for top commit:
  brunoerg:
    ACK 2ef5294a5b

Tree-SHA512: 454782cf6a44fd0e05483bb152153667ef5c8021358385ddcf89724fbbbd35e187362bdff757e00c99319527bc4c0b20c7187f67241d4585d767a29787142f25
2022-07-12 17:28:26 +02:00
MacroFake
7d258ee8bc
Merge bitcoin/bitcoin#25489: wallet: change ScanForWalletTransactions to use Ticks(Dur2 d)
c6c35db057 wallet: change `ScanForWalletTransactions` to use `Ticks()` (w0xlt)

Pull request description:

  This PR changes `ScanForWalletTransactions()` to use the `Ticks(Dur2 d)` function (introduced in #25456).

ACKs for top commit:
  MarcoFalke:
    cr ACK c6c35db057

Tree-SHA512: 864e136b470baf22293dc03ae3400bbb34955389a1efc83862f006cfac84da9128c3a201ef051606c06f782a1fde84129261dd4b417cbfff854d5c359a92703e
2022-07-12 17:20:12 +02:00
MacroFake
dd13d7bf16
Merge bitcoin/bitcoin#25591: move-only: Version handshake to libtest_util
fa4be8e7c3 move-only: InitializeNode to handshake helper (MacroFake)
fa7098947c move-only: Version handshake to libtest_util (MacroFake)

Pull request description:

  The version handshake after setting up a peer is an integral part of (unit) testing net processing logic.

  Thus, make the helper accessible in libtest_util.

  Also, remove the peerman argument from `FillNode`, as it must be equal to connman's peerman, which can then be used instead.

ACKs for top commit:
  dergoegge:
    ACK fa4be8e7c3

Tree-SHA512: 8296399dc2c29196bd56584c9b61f1c5a088f96dd3438b07b84e1acf525d867f1e37fdfdeede8a831add25848cda0c221ce3fb873e5ae5ca805a1765aa08eb12
2022-07-12 17:05:42 +02:00
w0xlt
c6c35db057 wallet: change ScanForWalletTransactions to use Ticks() 2022-07-12 10:29:08 -03:00
MacroFake
316afb1eca
Merge bitcoin/bitcoin#25218: refactor: introduce generic 'Result' class and connect it to CreateTransaction and GetNewDestination
111ea3ab71 wallet: refactor GetNewDestination, use BResult (furszy)
22351725bc send: refactor CreateTransaction flow to return a BResult<CTransactionRef> (furszy)
198fcca162 wallet: refactor, include 'FeeCalculation' inside 'CreatedTransactionResult' (furszy)
7a45c33d1f Introduce generic 'Result' class (furszy)

Pull request description:

  Based on a common function signature pattern that we have all around the sources:
  ```cpp
  bool doSomething(arg1, arg2, arg3, arg4, &result_obj, &error_string) {
      // do something...
      if (error) {
          error_string = "something bad happened";
          return false;
      }

      result = goodResult;
      return true;
  }
  ```

  Introduced a generic class `BResult` that encapsulate the function boolean result, the result object (in case of having it) and, in case of failure, the string error reason.

  Obtaining in this way cleaner function signatures and removing boilerplate code:

  ```cpp
  BResult<Obj> doSomething(arg1, arg2, arg3, arg4) {
      // do something...
      if (error) return "something bad happened";

      return goodResult;
  }
  ```

  Same cleanup applies equally to the function callers' side as well. There is no longer need to add the error string and the result object declarations before calling the function:

  Before:
  ```cpp
  Obj result_obj;
  std::string error_string;
  if (!doSomething(arg1, arg2, arg3, arg4, result_obj, error_string)) {
      LogPrintf("Error: %s", error_string);
  }
  return result_obj;
  ```

  Now:
  ```cpp
  BResult<Obj> op_res = doSomething(arg1, arg2, arg3, arg4);
  if (!op_res) {
      LogPrintf("Error: %s", op_res.GetError());
  }
  return op_res.GetObjResult();
  ```

  ### Initial Implementation:

  Have connected this new concept to two different flows for now:

  1) The `CreateTransaction` flow. --> 7ba2b87c
  2) The `GetNewDestination` flow. --> bcee0912

  Happy note: even when introduced a new class into the sources, the amount of lines removed is almost equal to added ones :).

  Extra note: this work is an extended version (and a decoupling) of the work that is inside #24845 (which does not contain the `GetNewDestination` changes nor the inclusion of the `FeeCalculation` field inside `CreatedTransactionResult`).

ACKs for top commit:
  achow101:
    ACK 111ea3ab71
  w0xlt:
    reACK 111ea3ab71
  theStack:
    re-ACK 111ea3ab71
  MarcoFalke:
    review ACK 111ea3ab71 🎏

Tree-SHA512: 6d84d901a4cb923727067f25ff64542a40edd1ea84fdeac092312ac684c34e3688a52ac5eb012717d2b73f4cb742b9d78e458eb0e9cb9d6d72a916395be91f69
2022-07-12 13:56:48 +02:00
Hennadii Stepanov
27a4dd055b
Merge bitcoin-core/gui#627: Apply translator comments to reset options confirmation dialog
d5c141f221 qt: apply translator comments to reset options confirmation dialog (Jarol Rodriguez)

Pull request description:

  This is a followup to #617. Because the strings were being concatenated, we can not apply translator comments to all of the revelant strings. This can be tested by applying the following diff to current master and running `make translate`; then check the resulting diff:

  ```diff
  diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp
  index 462b923d6..3cf165004 100644
  --- a/src/qt/optionsdialog.cpp
  +++ b/src/qt/optionsdialog.cpp
  @@ -286,9 +286,17 @@ void OptionsDialog::on_resetButton_clicked()
   {
       if (model) {
           // confirmation dialog
  +        //: Window title text of pop-up window shown when the user has chosen to reset options.
           QMessageBox::StandardButton btnRetVal = QMessageBox::question(this, tr("Confirm options reset"),
  +            /*: Text explaining that the settings the user changed will not come
  +                into effect until the client is restarted. */
               tr("Client restart required to activate changes.") + "<br><br>" +
  +            /*: Text explaining to the user that the client's current settings
  +                will be backed up at a specific location. %1 is a stand-in
  +                argument for the backup location's path. */
               tr("Current settings will be backed up at \"%1\".").arg(m_client_model->dataDir()) + "<br><br>" +
  +            /*: Text asking the user to confirm if they would like to proceed
  +                with a client shutdown. */
               tr("Client will be shut down. Do you want to proceed?"),
               QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
  ```

  To apply the above translator comments, what we want to do instead is have a variable in which the translatable strings are appended to using the [QString append function](https://doc.qt.io/qt-5/qstring.html#append).

  When you run `make translate` with this PR, you will see the translator comments properly applied, as shown below:
  ``` diff
  diff --git a/src/qt/locale/bitcoin_en.ts b/src/qt/locale/bitcoin_en.ts
  index 35d820187..9e5158b3e 100644
  --- a/src/qt/locale/bitcoin_en.ts
  +++ b/src/qt/locale/bitcoin_en.ts
  @@ -1942,28 +1942,37 @@ Signing is only possible with addresses of the type &apos;legacy&apos;.</source>
           <translation>default</translation>
       </message>
       <message>
  -        <location line="+81"/>
  +        <location line="+86"/>
           <source>none</source>
           <translation type="unfinished"></translation>
       </message>
       <message>
  -        <location line="+97"/>
  +        <location line="+107"/>
           <source>Confirm options reset</source>
  +        <extracomment>Window title text of pop-up window shown when the user has chosen to reset options.</extracomment>
           <translation>Confirm options reset</translation>
       </message>
       <message>
  -        <location line="+1"/>
  -        <location line="+70"/>
  +        <location line="-9"/>
  +        <location line="+79"/>
           <source>Client restart required to activate changes.</source>
  +        <extracomment>Text explaining that the settings changed will not come into effect until the client is restarted.</extracomment>
  +        <translation type="unfinished"></translation>
  +    </message>
  +    <message>
  +        <location line="-75"/>
  +        <source>Current settings will be backed up at &quot;%1&quot;.</source>
  +        <extracomment>Text explaining to the user that the client&apos;s current settings will be backed up at a specific location. %1 is a stand-in argument for the backup location&apos;s path.</extracomment>
           <translation type="unfinished"></translation>
       </message>
       <message>
  -        <location line="-70"/>
  +        <location line="+3"/>
           <source>Client will be shut down. Do you want to proceed?</source>
  +        <extracomment>Text asking the user to confirm if they would like to proceed with a client shutdown.</extracomment>
           <translation type="unfinished"></translation>
       </message>
       <message>
  -        <location line="+18"/>
  +        <location line="+20"/>
           <source>Configuration options</source>
           <extracomment>Window title text of pop-up box that allows opening up of configuration file.</extracomment>
           <translation type="unfinished"></translation>
  ```

  No difference in rendering between master and PR

  | master | PR |
  | ------- | --- |
  <img width="532" alt="Screen Shot 2022-06-29 at 11 39 17 PM" src="https://user-images.githubusercontent.com/23396902/176588495-9d3761b6-9d96-489a-bbe5-a8907f7d5f99.png"> | <img width="532" alt="Screen Shot 2022-06-29 at 11 39 51 PM" src="https://user-images.githubusercontent.com/23396902/176588513-92e29564-b74a-46f5-a5dd-469c4ee953f7.png"> |

ACKs for top commit:
  shaavan:
    ACK d5c141f221
  furszy:
    Tested ACK d5c141f2, no functional changes.
  w0xlt:
    tACK d5c141f221

Tree-SHA512: 6175a096c6f99edb3041cc2429e1ea0670a10cd2cab0364f664a56c7dee1aa8631d52c0a36edb5d571f6ef934e947d45017e446cea7dddae044085c39c8835ef
2022-07-12 08:46:02 +01:00
MacroFake
fa4be8e7c3
move-only: InitializeNode to handshake helper 2022-07-12 08:41:34 +02:00
MacroFake
fa7098947c
move-only: Version handshake to libtest_util 2022-07-12 08:41:24 +02:00
MacroFake
7ba0850c49
Merge bitcoin/bitcoin#25036: wallet: Save wallet scan progress
230a2f4cc3 wallet test: Add unit test for wallet scan save_progress option (Ryan Ofsky)
a89ddfbe22 wallet: Save wallet scan progress (w0xlt)

Pull request description:

  Currently, the wallet scan progress is not saved.
  If it is interrupted,  it will be necessary to start from scratch on the next load.
  This PR changes this and the progress is saved right after checking a block.

  Close https://github.com/bitcoin/bitcoin/issues/25010

ACKs for top commit:
  furszy:
    re-ACK 230a2f4
  achow101:
    ACK 230a2f4cc3
  ryanofsky:
    Code review ACK 230a2f4cc3. Only change since last review is tweaking whitespace and adding log print

Tree-SHA512: 1a9dec207ed22b3443fb06a4daf967637bc02bcaf71c070b7dc33605d0cab959551e4014c9e92293a63f54c5cbcc98bb9f8844a8c60bc32a1482b1c4130fab32
2022-07-12 08:02:22 +02:00
Andrew Chow
d2ed97656b wallet: Precompute Txdata after setting PSBT inputs' UTXOs
If we are given a PSBT that is missing one or more input UTXOs, our
PrecomputedTransactionData will be incorrect and missing information
that it should otherwise have, and therefore we may not produce a
signature when we should. To avoid this problem, we can do the
precomputation after we have set the UTXOs the wallet is able to set for
the PSBT.

Also adds a test for this behavior.
2022-07-11 18:08:32 -04:00
Andrew Chow
c92eb6cda0
Merge bitcoin/bitcoin#25562: test: add tests for negative waste during coin selection
98ea43d5e9 test: add tests for negative waste during coin selection (ishaanam)

Pull request description:

  #25495 mentions that waste can be negative when the current feerate is less than the long term feerate. There are currently no waste tests for negative waste, so this PR adds two of them.

ACKs for top commit:
  achow101:
    ACK 98ea43d5e9
  glozow:
    light code review ACK 98ea43d5e9, good to have tests for negative waste

Tree-SHA512: d194d370f1257975959d3c601fea9f82c30c1aabc3e8bedc997c62659283fe681cc527e59df1a0187b3c91e8067c60374dd5ce0237561bd882edafe6a575a9b9
2022-07-11 13:11:25 -04:00
Hennadii Stepanov
f9783b0f07
Merge bitcoin-core/gui#471: Add Wallet Restore in the GUI
bc13ec888c doc: Add a release note about the "restore wallet" menu item (w0xlt)
e7a3f698b5 gui: Add Wallet Restore in the GUI (w0xlt)

Pull request description:

  This PR adds a menu item to restore a wallet from a backup file in the GUI.
  Currently this option exists only in RPC interface.

  Motivation: It makes easier for non-technical users to restore backups.

  Master | PR |
  --- | ---
  <img width="307" alt="master" src="https://user-images.githubusercontent.com/94266259/141673349-0bf8a237-ecec-42e4-a0d7-1d5863940036.png"> | <img width="307" alt="pr" src="https://user-images.githubusercontent.com/94266259/141673350-972dea23-ae56-4283-a365-819da62b7067.png"> |

ACKs for top commit:
  w0xlt:
    Added a release note in a new commit (bc13ec888c) to not invalidate the ACKs for the previous one.
  furszy:
    utACK bc13ec8
  shaavan:
    ACK bc13ec888c
  hebasto:
    ACK bc13ec888c

Tree-SHA512: edc3675484238857b77e74382a4041dd5d2cbcda1e2d5bfe52c83d9d7bb7be8a243ecd97e25e994d8c30ab6d7c59ead5a1c953a46dce173666b137eeffc3c94f
2022-07-10 20:43:54 +01:00
Andrew Chow
194710d8ff
Merge bitcoin/bitcoin#25481: wallet: unify max signature logic
d54c5c8b1b wallet: use CCoinControl to estimate signature size (S3RK)
a94659c84e wallet: replace GetTxSpendSize with CalculateMaximumSignedInputSize (S3RK)

Pull request description:

  Currently `DummySignTx` and `DummySignInput` use different ways to determine signature size.
  This PR unifies the way wallet estimates signature size for various inputs.
  Instead of passing boolean flags from calling code the `use_max_sig` is now calculated at the place of signature creation using information available in `CCoinControl`

ACKs for top commit:
  achow101:
    ACK d54c5c8b1b
  theStack:
    Code-review ACK d54c5c8b1b

Tree-SHA512: e790903ad4683067070aa7dbf7434a1bd142282a5bc425112e64d88d27559f1a2cd60c68d6022feaf6b845237035cb18ece10f6243d719ba28173b69bd99110a
2022-07-08 10:27:06 -04:00
furszy
111ea3ab71
wallet: refactor GetNewDestination, use BResult 2022-07-08 11:18:35 -03:00
furszy
22351725bc
send: refactor CreateTransaction flow to return a BResult<CTransactionRef> 2022-07-08 11:18:35 -03:00
furszy
198fcca162
wallet: refactor, include 'FeeCalculation' inside 'CreatedTransactionResult' 2022-07-08 11:18:35 -03:00
furszy
7a45c33d1f
Introduce generic 'Result' class
Useful to encapsulate the function result object (in case of having it) or, in case of failure, the failure reason.

This let us clean lot of boilerplate code, as now instead of returning a boolean and having to add a ref arg for the
return object and another ref for the error string. We can simply return a 'BResult<Obj>'.

Example of what we currently have:
```
bool doSomething(arg1, arg2, arg3, arg4, &result, &error_string) {
    do something...
    if (error) {
        error_string = "something bad happened";
        return false;
    }

    result = goodResult;
    return true;
}
```

Example of what we will get with this commit:
```
BResult<Obj> doSomething(arg1, arg2, arg3, arg4) {
    do something...
    if (error) return {"something happened"};

    // good
    return {goodResult};
}
```

This allows a similar boilerplate cleanup on the function callers side as well. They don't have to add the extra
pre-function-call error string and result object declarations to pass the references to the function.
2022-07-08 11:18:35 -03:00
Andrew Chow
b9f9ed4640
Merge bitcoin/bitcoin#25337: refactor: encapsulate wallet's address book access
d69045e291 test: add coverage for 'listreceivedbyaddress' no change addrs return (furszy)
324f00a642 refactor: 'ListReceived' use optional for filtered address (furszy)
b459fc122f refactor: RPC 'ListReceived', encapsulate m_address_book access (furszy)
fa9f2ab8fd refactor: RPC 'listlabels', encapsulate 'CWallet::ListAddrBookLabels' functionality (furszy)
83e42c4b94 refactor: use 'ForEachAddrBookEntry' in RPC 'getaddressesbylabel' (furszy)
2b48642499 refactor: use ForEachAddrBookEntry in interfaces::getAddresses (furszy)
032842ae41 wallet: implement ForEachAddrBookEntry method (furszy)
09649bc95d refactor: implement general 'ListAddrBookAddresses' for addressbook destinations lookup (furszy)
192eb1e61c refactor: getAddress don't access m_address_book, use FindAddressEntry function (furszy)

Pull request description:

  ### Context

  The wallet's `m_address_book` field is being accessed directly from several places across the sources.

  ### Problem

  Code structure wise, we shouldn't be accessing it directly. It could end up being modified by mistake (from a place that has nothing to do with the wallet like an RPC command or the GUI) and cause a bigger issue: like an address book entry 'purpose' string change, which if done badly (from 'send' to 'receive'), could end up in a user sharing a "receive" address that he/she doesn't own.

  ### Solution

  Encapsulate `m_address_book` access inside the wallet.

  -------------------------------------------------------

  Extra Note:

  This is the initial step towards decoupling the address book functionality from the wallet's sources. In other words, the creation of the `AddressBookManager` (which will be coming in a follow-up PR).

ACKs for top commit:
  achow101:
    ACK d69045e291
  theStack:
    ACK d69045e291 
  w0xlt:
    ACK d69045e291

Tree-SHA512: dba17acd86f171b4e9af0223bbbcad380048570f6a2f6a92732a51f01abe8806debaf65c9e9e5569fa76a541903cbb50adcb5f56ef77858151c698ae6b218e2a
2022-07-08 10:16:08 -04:00
fanquake
07f2c25d04
refactor: add most of src/util to iwyu
These files change infrequently, and not much header shuffling is required.

We don't add everything in src/util/ yet, because IWYU makes some
dubious suggestions, which I'm going to follow up with upstream.
2022-07-08 11:06:01 +01:00
MacroFake
a7f3479ba3
Merge bitcoin/bitcoin#25353: Add a -mempoolfullrbf node setting
4c9666bd73 Mention `mempoolfullrbf` in policy/mempool-replacements.md (Antoine Riard)
aae66ab43d Update getmempoolinfo RPC with `mempoolfullrbf` (Antoine Riard)
3e27e31727 Introduce `mempoolfullrbf` node setting. (Antoine Riard)

Pull request description:

  This is ready for review.

  Recent discussions among LN devs have brought back on the surface concerns about the security of multi-party funded transactions against pinnings attacks and other mempool-based nuisances. The lack of full-rbf transaction-relay topology connected to miners open the way to cheap and naive DoS against multi-party funded transactions (e.g coinjoins, dual-funded channels, on-chain DLCs, ...) without solutions introducing an overhead cost or centralization vectors afaik . For more details, see [0].

  This PR implements a simple `fullrbf` setting, where the node always allows transaction replacement, ignoring BIP125 opt-in flag. The default value of the setting stays **false**, therefore opt-in replacement is still the default Bitcoin Core replacement policy. Contrary to a previous proposal of mine and listening to feedbacks collected since then [1], I think this new setting simply offers more flexibility in a node transaction-relay policy suiting one's application requirements, without arguing a change of the default behavior.

  I [posted](https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2022-June/020557.html) on the ML to invite operators with a bitcoin application sensitive to full-rbf (e.g dual-funded LN channels service providers) or mempool researchers to join a bootstrapped full-rbf activated peers network for experimentation and learning. If people have strong opinions against the existence of such full-rbf transaction-relay network, I'm proposing to express them on the future thread.

  [0] https://lists.linuxfoundation.org/pipermail/lightning-dev/2021-May/003033.html
  [1] https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2021-June/019074.html

  Follow-up suggestions :
  - soft-enable opt-in RBF in the wallet : https://github.com/bitcoin/bitcoin/pull/25353#issuecomment-1154918789
  - p2p discovery and additional outbound connection to full-rbf peers : https://github.com/bitcoin/bitcoin/pull/25353#issuecomment-1156044401
  - match the code between RPC, wallet and mempool about disregard of inherited signaling : #22698

ACKs for top commit:
  instagibbs:
    reACK 4c9666bd73
  glozow:
    ACK 4c9666bd73, a few nits which are non-blocking.
  w0xlt:
    ACK 4c9666bd73

Tree-SHA512: 9e288bf22e06a9808804e58178444ef1830c3fdd42fd8a7cd7ffb101f8f586e08b000679be407d63ca76a56f7216227b368ff630c81f3fac3243db1a1202ab1c
2022-07-08 11:06:24 +02:00
Hennadii Stepanov
630c1711b4
refactor: Drop no longer needed util/designator.h 2022-07-07 20:01:01 +01:00
Hennadii Stepanov
555f9dd5d3
rpc, refactor: Add decodepsbt_outputs
This change eliminates memory usage spike when compiling with Visual
Studio 2022 (at least in Cirrus CI environment).

Easy to review using
`git diff --color-moved-ws=allow-indentation-change --color-moved=dimmed-zebra`
2022-07-07 19:59:48 +01:00
Hennadii Stepanov
0c432cbbfa
rpc, refactor: Add decodepsbt_inputs
This change eliminates memory usage spike when compiling with Visual
Studio 2022 (at least in Cirrus CI environment).

Easy to review using
`git diff --color-moved-ws=allow-indentation-change --color-moved=dimmed-zebra`
2022-07-07 19:59:48 +01:00
Hennadii Stepanov
01d95a3964
rpc, refactor: Add getblock_prevout
This change eliminates memory usage spike when compiling with Visual
Studio 2022 (at least in Cirrus CI environment).

Easy to review using
`git diff --color-moved-ws=allow-indentation-change --color-moved=dimmed-zebra`
2022-07-07 19:59:41 +01:00
fanquake
5abbc9afec
Merge bitcoin/bitcoin#24832: index: Verify the block filter hash when reading the filter from disk.
e734228d85 Update GCSFilter benchmarks (Calvin Kim)
aee9a8140b Add GCSFilterDecodeSkipCheck benchmark (Patrick Strateman)
299023c1d9 Add GCSFilterDecode and GCSBlockFilterGetHash benchmarks. (Patrick Strateman)
b0a53d50d9 Make sanity check in GCSFilter constructor optional (Patrick Strateman)

Pull request description:

  This PR picks up the abandoned #19280

  BlockFilterIndex was depending on `GolombRiceDecode()` during the filter decode to sanity check that the filter wasn't corrupt. However, we can check for corruption by ensuring that the encoded blockfilter's hash matches up with the one stored in the index database.

  Benchmarks that were added in #19280 showed that checking the hash is much faster.

  The benchmarks were changed to nanobench and the relevant benchmarks were like below, showing a clear win for the hash check method.

  ```
  |             ns/elem |              elem/s |    err% |        ins/elem |       bra/elem |   miss% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------------:|---------------:|--------:|----------:|:----------
  |              531.40 |        1,881,819.43 |    0.3% |        3,527.01 |         411.00 |    0.2% |      0.01 | `DecodeCheckedGCSFilter`
  |          258,220.50 |            3,872.66 |    0.1% |    2,990,092.00 |     586,706.00 |    1.7% |      0.01 | `DecodeGCSFilter`
  |           13,036.77 |           76,706.09 |    0.3% |       64,238.24 |         513.04 |    0.2% |      0.01 | `BlockFilterGetHash`
  ```

ACKs for top commit:
  mzumsande:
    Code Review ACK e734228d85
  theStack:
    Code-review ACK e734228d85
  stickies-v:
    ACK e734228d85
  ryanofsky:
    Code review ACK e734228d85, with caveat that I mostly paid attention to the main code, not the changes to the benchmark. Only changes since last review were changes to the benchmark code.

Tree-SHA512: 02b86eab7b554e1a57a15b17a4d6d71faa91b556c637b0da29f0c9ee76597a110be8e3b4d0c158d4cab04af0623de18b764837be0ec2a72afcfe1ad9c78a83c6
2022-07-07 17:59:02 +01:00
fanquake
d571cf2d24
Merge bitcoin/bitcoin#25500: refactor: Move inbound eviction logic to its own translation unit
0101d2bc3c [net] Move eviction logic to its own file (dergoegge)
c741d748d4 [net] Move ConnectionType to its own file (Cory Fields)
a3c2707039 [net] Add connection type to NodeEvictionCandidate (dergoegge)
42aa5d5b62 [net] Add NoBan status to NodeEvictionCandidate (dergoegge)

Pull request description:

  This PR splits of the first couple commits from #25268 that move the inbound eviction logic from `net.{h,cpp}` to `eviction.{h,cpp}`.

  Please look at #25268 for motivation and conceptual review.

ACKs for top commit:
  jnewbery:
    utACK 0101d2bc3c
  theuni:
    utACK 0101d2bc3c. I quickly verified with `git --color-moved` that the move-only changes are indeed move-only.

Tree-SHA512: e0c345a698030e049cb22fe281b44503c04403c5be5a3750ca14bfcc603a162ac6bac9a39552472feb57c460102b7ca91430b8ad6268f2efccc49b5e8959331b
2022-07-07 17:54:37 +01:00
MacroFake
bac52a1cfe
Merge bitcoin/bitcoin#25447: fuzz: add low-level target for txorphanage
6eb0909cb7 fuzz: add low-level target for txorphanage (chinggg)

Pull request description:

  This adds a low-level fuzz target for orphan transaction handling by creating random transactions and calling all functions in `TxOrphanage`.
  It cannot simulate real-world `orphan/unorphan` scenarios effectively since it does not maintain any state about the node and the chain. A high-level fuzz target which construct well-designed transaction graphs will be added later.

ACKs for top commit:
  MarcoFalke:
    review ACK 6eb0909cb7 🐈

Tree-SHA512: b4d64f5941df77d13981f75ec170cef6ffabe782797c982ede7f34134be01dc0026dd7c0bee614bc1d64715e90a933d2a8c95974d402e32eaba8e24cc928299e
2022-07-07 14:03:52 +02:00
ishaanam
98ea43d5e9 test: add tests for negative waste during coin selection 2022-07-07 13:05:13 +05:30
Antoine Riard
aae66ab43d Update getmempoolinfo RPC with mempoolfullrbf 2022-07-06 20:57:31 -04:00
Antoine Riard
3e27e31727 Introduce mempoolfullrbf node setting.
This new node policy setting enables to accept replaced-by-fee
transaction without inspection of the replaceability signaling
as described in BIP125 "explicit signaling".

If turns on, the node mempool accepts transaction replacement
as described in `policy/mempool-replacements.md`.

The default setting value is `false`, implying opt-in RBF
is enforced.
2022-07-06 20:57:29 -04:00
furszy
47ea70fbb8
wallet: clean AllInputsMine code, use InputIsMine internally
Instead of duplicate the exact same code twice.
2022-07-06 18:04:19 -03:00
dergoegge
0101d2bc3c [net] Move eviction logic to its own file 2022-07-06 18:13:54 +02:00
Cory Fields
c741d748d4 [net] Move ConnectionType to its own file 2022-07-06 18:13:53 +02:00
Andrew Chow
aeab1b42e6
Merge bitcoin/bitcoin#25507: wallet: don't add change fee to target if subtracting fees from output
140d942634 wallet: don't add change fee to target if subtracting fees from output (S3RK)

Pull request description:

  Change fee is payed by the recipient, so we don't need to add it to our target for coin selection.

ACKs for top commit:
  achow101:
    ACK 140d942634
  ishaanam:
    ACK 140d942634
  furszy:
    Code review ACK 140d9426

Tree-SHA512: b5efd0264c47ecee9204a3fd039bad24c69f9e614c6e1d9bb240ee5be6356b175aa074f3be123e6cfb8becd4d7bd1028eebe18801662cc69d19413d8d5a9dd5c
2022-07-06 11:01:07 -04:00
chinggg
6eb0909cb7 fuzz: add low-level target for txorphanage 2022-07-06 22:13:54 +08:00
Antoine Poinsot
757216e31c
wallet: don't iter twice when getting the cached debit/credit amount
Instead of calling GetCachableAmount twice, which will result in
iterating through all the transaction txins/txouts and calling
GetDebit/GetCredit (which lock cs_wallet), just merge the filters and do
it once.
2022-07-05 15:43:09 +02:00
furszy
bf310b0e8c
wallet: clean InputIsMine code, use GetWalletTx 2022-07-05 10:10:33 -03:00
furszy
0cb177263c
wallet: unify CachedTxGetImmatureCredit and CachedTxGetImmatureWatchOnlyCredit 2022-07-05 10:10:27 -03:00
furszy
04c6423f7b
wallet: remove always true 'fUseCache' arg from CachedTxGetAvailableCredit 2022-07-05 10:10:27 -03:00
furszy
4f0ca9bff6
wallet: remove always false 'recalculate' arg from GetCachableAmount 2022-07-05 10:10:27 -03:00
furszy
47b1012677
wallet: remove always true 'fUseCache' from CachedTxGetImmatureWatchOnlyCredit 2022-07-05 10:10:27 -03:00
furszy
da8f62de2c
wallet: remove always true 'fUseCache' from CachedTxGetImmatureCredit 2022-07-05 10:10:26 -03:00
fanquake
87d012324a
Merge bitcoin/bitcoin#25454: p2p: Avoid multiple getheaders messages in flight to the same peer
99f4785cad Replace GetTime() with NodeClock in MaybeSendGetHeaders() (Suhas Daftuar)
abf5d16c24 Don't send getheaders message when another request is outstanding (Suhas Daftuar)
ffe87db247 Cleanup received_new_header calculation to use WITH_LOCK (Suhas Daftuar)
6d95cd3e74 Move peer state updates from headers message into separate function (Suhas Daftuar)
2b341db731 Move headers direct fetch to end of ProcessHeadersMessage (Suhas Daftuar)
29c4518522 Move headers-direct-fetch logic into own function (Suhas Daftuar)
bf8ea6df75 Move additional headers fetching to own function (Suhas Daftuar)
9492e93bf9 Add helper function for checking header continuity (Suhas Daftuar)
7f2450871b Move handling of unconnecting headers into own function (Suhas Daftuar)

Pull request description:

  Change `getheaders` messages so that we wait up to 2 minutes for a response to a prior `getheaders` message before issuing a new one.

  Also change the handling of the `getheaders` message sent in response to a block INV, so that we no longer use the hashstop variable (including the hash stop will just mean that if our peer's headers chain is longer, then we won't learn
  it, so there's no benefit to using hashstop).

  Also, now respond to a `getheaders` during IBD with an empty headers message (rather than nothing) -- this better conforms to the intent of the new logic that it's better to not ignore a peer's `getheaders` message, even if you have nothing to give. This also avoids a lot of functional tests breaking.

  This PR also reworks the headers processing logic to make it more readable.

ACKs for top commit:
  ajtowns:
    ACK 99f4785cad ; code review, check over new logic of when to send getheaders messages
  dergoegge:
    Code review ACK  99f4785cad
  mzumsande:
    Code Review ACK 99f4785cad
  sipa:
    utACK 99f4785cad
  w0xlt:
    tACK 99f4785cad Good improvement in the code.

Tree-SHA512: b8a63f6f71ac83e292edc0200def7835ad8b06b2955dd34e3ea6fac85980fa6962efd31d689ef5ea121ff5477ec14aafa4bbe2d0db134c05f4a31a57a8ced365
2022-07-04 21:28:21 +01:00
dergoegge
a3c2707039 [net] Add connection type to NodeEvictionCandidate 2022-07-04 14:58:43 +02:00
dergoegge
42aa5d5b62 [net] Add NoBan status to NodeEvictionCandidate 2022-07-04 14:57:49 +02:00
Fabian Jahr
833ce76df7
rpc, wallet: Document mempool rescan after importdescriptor, importwallet 2022-07-03 21:06:49 +02:00
Fabian Jahr
0e396d1ba7
rpc, wallet: Document mempool scan after importmulti 2022-07-03 21:06:49 +02:00
Fabian Jahr
e6d3ef8586
rpc, wallet: Document mempool scan after importpubkey 2022-07-03 21:06:49 +02:00
João Barbosa
6d3db52e66
rpc, wallet: Document and test mempool scan after importprivkey
co-authored-by: Fabian Jahr <fjahr@protonmail.com>
2022-07-03 21:06:49 +02:00
João Barbosa
3abdbbb90a
rpc, wallet: Document and test mempool scan after importaddress
co-authored-by: Fabian Jahr <fjahr@protonmail.com>
2022-07-03 21:06:49 +02:00
Fabian Jahr
236239bd40
wallet: Rescan mempool for transactions as well 2022-07-03 21:06:47 +02:00
MacroFake
4129c13754
Merge bitcoin/bitcoin#25521: build: Remove outdated libbitcoinkernel comment
18f5355f3a Remove outdated comment (Igor Bubelov)

Pull request description:

  Looks like this comment is no longer relevant, the last files which matched `index/*.cpp` pattern were removed in f100687566

ACKs for top commit:
  dongcarl:
    ACK 18f5355f3a
  shaavan:
    ACK 18f5355f3a

Tree-SHA512: d3fcc2db0940f81ce521fddff836f271709ea327c357942383f8aff6c7089e74490fa720e7a2916900215c733d2b64960c1aa185f0c9b1567fce90a249d405e0
2022-07-01 21:50:50 +02:00