Commit graph

4192 commits

Author SHA1 Message Date
fanquake
895937edb2
Merge bitcoin/bitcoin#25285: Add AutoFile without ser-type and ser-version and use it where possible
facc2fa7b8 Use AutoFile where possible (MacroFake)
6666803c89 streams: Add AutoFile without ser-type and ser-version (MacroFake)

Pull request description:

  This was done in the context of https://github.com/bitcoin/bitcoin/pull/25284 , but I think it also makes sense standalone.

  The basic idea is that serialization type should not be initialized when it is not needed. Same for the serialization version.

  So do this here for `AutoFile`. `CAutoFile` remains in places where it is not yet possible.

ACKs for top commit:
  laanwj:
    Code review ACK facc2fa7b8
  fanquake:
    ACK facc2fa7b8

Tree-SHA512: d82d024d55af57565ac53d9d1517afafc12b46964effba0332de62a6c77869356fa77f89e6d4834438fff44c45b64fccdf5a1358bfea03e28dfe55013b3c099d
2022-07-20 09:32:11 +01:00
Pieter Wuille
544b4332f0 Add wallet tests for spending rawtr() 2022-07-19 18:17:20 -04:00
Pieter Wuille
8d9670ccb7 Add rawtr() descriptor for P2TR with unknown tweak 2022-07-19 17:36:08 -04:00
josibake
da03cb41a4
test: functional test for new coin selection logic
Create a wallet with mixed OutputTypes and send a volley of payments,
ensuring that there are no mixed OutputTypes in the txs. Finally,
verify that OutputTypes are mixed only when necessary.
2022-07-19 18:42:21 +02:00
Sebastian Falbesoner
71a751f6c3 test: add test for decoding PSBT with per-input preimage types 2022-07-19 17:44:50 +02:00
Sebastian Falbesoner
faf43378e2 refactor: move helper random_bytes to util library
Can be easily reviewed with `--color-moved=dimmed-zebra`.
2022-07-19 17:42:35 +02:00
Sebastian Falbesoner
fdc1ca3896 test: add constants for PSBT key types (BIP 174)
Also take use of the constants in the signet miner to get rid of
magic numbers and increase readability and maintainability.
2022-07-19 15:40:51 +02:00
Sebastian Falbesoner
1b035c03f9 refactor: move PSBT(Map) helpers from signet miner to test framework
Can be easily reviewed with `--color-moved=dimmed-zebra`.
2022-07-19 15:40:51 +02:00
Sebastian Falbesoner
7c0dfec2dd refactor: move from_binary helper from signet miner to test framework
Can be easily reviewed with `--color-moved=dimmed-zebra`.
2022-07-19 15:40:51 +02:00
Antoine Poinsot
55f98d087e
rpc: output parent wallet descriptors for coins in listunspent 2022-07-19 12:46:15 +02:00
Antoine Poinsot
b724476158
rpc: output wallet descriptors for received entries in listsinceblock
The descriptor wallets allow an application to track coins of multiple
descriptors in a single wallet. However, such an application would not
previously be able to (easily) tell what received coin "belongs" to what
descriptor.

This commit tackles this issues by adding a "wallet_desc" entry to the
entries for received coins in 'listsinceblock'.
2022-07-19 12:46:01 +02:00
fanquake
47dad42833
Merge bitcoin/bitcoin#25629: univalue: Return more detailed type check error messages
fae5ce8795 univalue: Return more detailed type check error messages (MacroFake)
fafab147e7 move-only: Move UniValue::getInt definition to keep class with definitions only (MacroFake)

Pull request description:

  Print the current type and the expected type

ACKs for top commit:
  aureleoules:
    ACK fae5ce8795.

Tree-SHA512: 4ae720a012ff8245baf5cd7f844f93b946c58feebe62de6dfd84ebc5c8afb988295a94de7c01aef98aaf4c6228f7184ed622f37079c738924617e0f336ac5b6e
2022-07-19 11:24:53 +01:00
MacroFake
1b285b7807
Merge bitcoin/bitcoin#25590: wallet: Precompute Txdata after setting PSBT inputs' UTXOs
d2ed97656b wallet: Precompute Txdata after setting PSBT inputs' UTXOs (Andrew Chow)

Pull request description:

  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.

ACKs for top commit:
  instagibbs:
    reACK d2ed97656b
  Sjors:
    ACK d2ed97656b
  aureleoules:
    ACK d2ed97656b.

Tree-SHA512: 71beb6c7946096e82cfca83f36277302aa9e69d27b4f6d73d7d8f2f9f0ea1c0d653e846fa6aebee5e4763f56f950b4481240e953f6a2412caa84908d519171e1
2022-07-19 10:58:25 +02:00
Andrew Chow
4aaa3b5200
Merge bitcoin/bitcoin#25351: rpc, wallet: Scan mempool after import* - Second attempt
1be7964189 test, wallet: Add mempool rescan test for import RPCs (Fabian Jahr)
833ce76df7 rpc, wallet: Document mempool rescan after importdescriptor, importwallet (Fabian Jahr)
0e396d1ba7 rpc, wallet: Document mempool scan after importmulti (Fabian Jahr)
e6d3ef8586 rpc, wallet: Document mempool scan after importpubkey (Fabian Jahr)
6d3db52e66 rpc, wallet: Document and test mempool scan after importprivkey (João Barbosa)
3abdbbb90a rpc, wallet: Document and test mempool scan after importaddress (João Barbosa)
236239bd40 wallet: Rescan mempool for transactions as well (Fabian Jahr)

Pull request description:

  This PR picks up the work from #18964 and closes #18954.

  It should incorporate all the unaddressed feedback from the PR:
  - Mempool rescan now expanded to all relevant import* RPCs
  - Added documentation in the help of each RPC
  - More tests

ACKs for top commit:
  Sjors:
    re-utACK 1be7964189 (only a test change)
  achow101:
    ACK 1be7964189
  w0xlt:
    reACK 1be7964189

Tree-SHA512: b62fed5f97c6c242b2af417b41c9696a1f18878483d9e1c9429791f9c05257f57a00540a9a84df23c49faf6a61c3109c22972de81540083f38b506217804fcc5
2022-07-18 14:26:21 -04:00
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
fae5ce8795
univalue: Return more detailed type check error messages 2022-07-18 11:31:36 +02:00
Andrew Chow
61d9149e78 rpc: Default rbf enabled 2022-07-15 11:46:34 -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
Antoine Poinsot
ffc79b8e49
qa: functional test Miniscript watchonly support 2022-07-14 12:11:44 +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
Andrew Chow
e3c33637ba wallet: Enable -walletrbf by default 2022-07-13 16:20:35 -04:00
Carl Dong
c84390b741 test/mempool_persist: Test manual savemempool when -persistmempool=0 2022-07-12 22:37:17 -04:00
Suhas Daftuar
613e221149 test: remove unnecessary parens 2022-07-12 13:38:14 -04:00
MacroFake
faace13b71
test: Remove duplicate MAX_BIP125_RBF_SEQUENCE constant 2022-07-12 18:51:18 +02:00
MacroFake
fa0404dbb7
scripted-diff: [test] Rename BIP125_SEQUENCE_NUMBER to MAX_BIP125_RBF_SEQUENCE
-BEGIN VERIFY SCRIPT-
 sed -i 's:BIP125_SEQUENCE_NUMBER:MAX_BIP125_RBF_SEQUENCE:g' $(git grep -l BIP125_SEQUENCE_NUMBER ./test)
-END VERIFY SCRIPT-
2022-07-12 18:49:08 +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
01ae8d9cd2
Merge bitcoin/bitcoin#25592: test persistence of non-mempool tx prioritisation
a9790ba95f [test] persist prioritisation of transactions not in mempool (glozow)

Pull request description:

  We persist tx prioritisation/fee deltas in mempool.dat (see `DumpMempool`). It seems we have test coverage for persistence of modified fees of mempool entries (see `vinfo` loop), but not for the prioritisation of transactions not in mempool (see `mapDeltas`).

  Relevant: https://github.com/bitcoin/bitcoin/pull/25487#discussion_r917490221

ACKs for top commit:
  darosior:
    utACK a9790ba95f
  w0xlt:
    ACK a9790ba95f

Tree-SHA512: 3f2769a917041f12414584f69b2239eef57586f9975869e826f356633fcaf893fde15500619b302e7663de14f3661c6cba22c7524cab5286e715e2c105726521
2022-07-12 17:08:36 +02:00
glozow
39d111aee7
Merge bitcoin/bitcoin#25575: Address comments remaining from #25353
1056bbdfcd Address comments remaining from #25353 (Antoine Riard)

Pull request description:

  This PR should address the remaining comments from #25353.

ACKs for top commit:
  MarcoFalke:
    cr ACK 1056bbdfcd
  glozow:
    ACK 1056bbdfcd
  w0xlt:
    cr ACK 1056bbdfcd

Tree-SHA512: 194524193b1f087742c04d3cbe221e2ccf62e1f9303dc6668d62b73bd2dc0c039b7d68b33658dbee7809bd14bb8a5479f8e7928180b18c3180fdfbe3876c3ca1
2022-07-12 15:58:39 +01:00
glozow
a9790ba95f
[test] persist prioritisation of transactions not in mempool 2022-07-12 10:37:13 +01:00
Antoine Riard
1056bbdfcd Address comments remaining from #25353 2022-07-11 18:48:26 -04: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
furszy
76a84c0a6c
test: speedup wallet_coinbase_category.py
No need to create a chain for it (nor use the cache).
2022-07-11 15:13:32 -03:00
MacroFake
0817cc379f
Merge bitcoin/bitcoin#25512: test: remove wallet dependency and refactor rpc_signrawtransaction.py
0ee43d13e9 test: refactor rpc_signrawtransaction.py (Ayush Sharma)

Pull request description:

  `rpc_signrawtransaction.py` currently tests the `signrawtransactionwithkey` and `signrawtransactionwithwallet` RPCs.

  This PR splits `rpc_signrawtransaction.py` into

  1. `rpc_signrawtransactionwithkey.py`: the tests for `signrawtransactionwithkey` are moved here and this test can now be run with the wallet disabled.
  2.  `wallet_signrawtransactionwithwallet.py`: wallet only tests for `signrawtransactionwithwallet.py`

ACKs for top commit:
  aureleoules:
    tACK 0ee43d13e9.

Tree-SHA512: c7bd2ea746345c978eae231a781fc52953b9d277eb9f8abb9c3270fe1d9f678f23f3784377d7303a2aa23d7ad90097245e517d386b27b4e0016585dfddcb9d49
2022-07-11 15:33:18 +02:00
Sebastian Falbesoner
6cbe65c5d7 test: refactor: pass absolute fee in create_lots_of_big_transactions helper 2022-07-10 13:09:51 +02: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
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
MacroFake
8ef096d4f8
Merge bitcoin/bitcoin#25522: test: Remove -acceptnonstdtxn=1 from feature_rbf.py
fad690ba0a test: Remove -acceptnonstdtxn=1 from feature_rbf.py (MacroFake)
fa5059b7df test: Make the scriptPubKey of MiniWallet created txs mutable (MacroFake)
fa29245827 test: Allow setting sequence per input in MiniWallet create_self_transfer_multi (MacroFake)
fac3800d2c test: Allow amount_per_output in MiniWallet create_self_transfer_multi (MacroFake)
2222842ae7 test: Allow absolute fee in MiniWallet create_self_transfer (MacroFake)

Pull request description:

  On the main network, nonstandard transactions are hardly relayed, so it seems odd that one of our policy test requires a policy setting opposite of the norm.

  Surely it is also important to test that nonstandard transactions can be replaced. However, rbf code should not care about the standardness at all. Moreover, I think testing nonstandardness rbf is of lower priority than testing the stuff that actually happens in production.

ACKs for top commit:
  theStack:
    re-ACK fad690ba0a
  jamesob:
    ACK fad690ba0a ([`jamesob/ackr/25522.1.MarcoFalke.test_remove_acceptnonstd`](https://github.com/jamesob/bitcoin/tree/ackr/25522.1.MarcoFalke.test_remove_acceptnonstd))

Tree-SHA512: e0a0c808bccdddf738fb6a84e5e5672d7c341bffd941c4f0c232112bfc68265fa81a2e42ddcab107d586358ffdb3dccc46bb5533d46999fd9ab024169dac0f78
2022-07-07 16:12:12 +02:00
MacroFake
67c6b61f96
Merge bitcoin/bitcoin#25525: test: remove wallet dependency from mempool_updatefromblock.py
eac1099e00 test: remove wallet dependency  from mempool_updatefromblock.py (Ayush Sharma)

Pull request description:

  This PR enables one of the non-wallet functional tests(`mempool_updatefromblock.py`) to be run with the wallet disabled.

ACKs for top commit:
  aureleoules:
    tACK eac1099e00.

Tree-SHA512: 9734815f2d2e65e8813bd776cf1d847a55ba4181e218c5e7b066ec69a556261069214f675681d672f5d7b0ba8e06342c4a456619dcc005cbf5618a0527303b7f
2022-07-07 13:55:43 +02: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
MacroFake
fad690ba0a
test: Remove -acceptnonstdtxn=1 from feature_rbf.py 2022-07-06 10:21:44 +02:00
MacroFake
195e07feaf
Merge bitcoin/bitcoin#19393: test: Add more tests for orphan tx handling
c0a5fceee9 test: Add test for erase orphan tx conflicted by block (Hennadii Stepanov)
fa45bb2119 test: Add test for erase orphan tx included by block (Hennadii Stepanov)
5c049780c8 test: Add test for erase orphan tx from peer (Hennadii Stepanov)

Pull request description:

  This PR adds test coverage for the following cases:
  - erase orphan transactions when a peer is disconnected
  - erase an orphan transaction when it is included in a new tip block
  - erase an orphan transaction when it is conflicted with other transactions included in a new tip block

  Found useful while working on #19374.

ACKs for top commit:
  aureleoules:
    tACK c0a5fceee9 (`make check` and `test/functional/test_runner.py`).
  kouloumos:
    ACK c0a5fceee9 with a nit per https://github.com/bitcoin/bitcoin/pull/19393#discussion_r899156623.
  pg156:
    Reviewed to c0a5fceee9. Concept ACK. Agree due to the lack of RPC calls to inspect orphan pool, using `assert_debug_log` to match strings in log is a reasonable way to test.

Tree-SHA512: 98f8deeee2d1c588c7e28a82e513d4a18655084198369db33fe2710458251eeaffed030626940072d7576f57fcbf7d856d761990129e2ca9e372d2ccbd86d07d
2022-07-05 18:55:56 +02: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
Fabian Jahr
1be7964189
test, wallet: Add mempool rescan test for import RPCs 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
Sebastian Falbesoner
1770be72d5 test: pass dustrelayfee=0 option for tests using dust (instead of acceptnonstdtxn=1)
By specifying the `dustrelayfee=0` option instead of the more
generic `acceptnonstdtxn=1`, we can be more specific about what
part of the transaction is non-standard and can be sure that all
other aspects follow the standard policy.
2022-07-03 16:30:11 +02:00
0xb10c
dba6f82342
test: adopt USDT utxocache interface tests
The USDT interface exposes process internals via the tracepoints. This
means, the USDT interface tests somewhat awardly depend on these
internals. If internals change, the tests have to adopt to that change.
Previously, the USDT interface tests weren't run in the CI so changes
could break the USDT interface tests without being noticed (e.g.
https://github.com/bitcoin/bitcoin/pull/25486).

In fa13375aa3 a 'self.rescan_utxos()' call
was added in the 'generate()' function of the test framework.
'rescan_utxos()' causes the UTXO cache to be flushed. In the USDT
interface tests for the 'utxocache:flush' trancepoint, 'generate()' is
used. As the utxo cache is now flushed more often, the number of flushes
the tests expectes need to be adopted. Also, the utxo cache has now a
different size when being flushed.

The utxocache tracepoint is tested by shutting the node down and
pruning blocks, to test the 'for_prune' argument.

Changes:
- A list 'expected_flushes' is now used which contains 'mode',
  'for_prune', and 'size' for each expected flush.
- When a flush happens, the expected-flush is removed from the list.
  This list is checked to be empty (unchanged).
- Previously, shutting down caused these two flushes:
    UTXOCacheFlush(duration=*, mode=ALWAYS, size=104, memory=*, for_prune=False)
    UTXOCacheFlush(duration=*, mode=ALWAYS, size=0, memory=*, for_prune=False)
  now it causes these flushes:
    UTXOCacheFlush(duration=*, mode=ALWAYS, size=2, memory=*, for_prune=False)
    UTXOCacheFlush(duration=*, mode=ALWAYS, size=0, memory=*, for_prune=False)
  The 104 UTXOs flushed previously were mainly coinbase UTXOs generated
  in previous tests and the test setup. These are now already flushed.
- In the 'for_prune' test we previously hooked into the tracepoint
  before mining blocks. This changed to only get notified about the
  tracepoint being triggered for the prune. Here, the utxo cache is
  empty already as it has just been flushed in 'generate()'.
  old:
    UTXOCacheFlush(duration=*, mode=NONE, size=350, memory=*, for_prune=True)
  new:
    UTXOCacheFlush(duration=*, mode=NONE, size=0, memory=*, for_prune=True)
2022-07-02 14:37:32 +02:00
0xb10c
220a5a2841
test: hook into PID in tracing tests
This makes sure to NOT hook into other bitcoind binaries run in
paralell in the test framework. We only want to trace the intended
binary.

In interface_usdt_utxocache.py:
While testing the utxocache flush with pruning, bitcoind is
restarted and we need to hook into the new PID again.
2022-07-02 14:37:29 +02:00
Ayush Sharma
eac1099e00 test: remove wallet dependency from mempool_updatefromblock.py
This functional  test can now be run with the wallet disabled.
2022-07-01 19:27:34 +05:30
MacroFake
fa5059b7df
test: Make the scriptPubKey of MiniWallet created txs mutable
This makes individual bytes of the scriptPubKey mutable, previously it
could only be re-assigned as a whole.
2022-07-01 12:29:23 +02:00
MacroFake
fa29245827
test: Allow setting sequence per input in MiniWallet create_self_transfer_multi
Previously it was only possible to set the same sequence in all inputs
2022-07-01 12:29:22 +02:00
MacroFake
fac3800d2c
test: Allow amount_per_output in MiniWallet create_self_transfer_multi 2022-07-01 12:29:14 +02:00
MacroFake
2222842ae7
test: Allow absolute fee in MiniWallet create_self_transfer 2022-07-01 12:29:00 +02:00
MacroFake
5d68d6840d
Merge bitcoin/bitcoin#25364: test: remove wallet dependency from feature_nulldummy.py
50ba6697f3 remove unused functions (Ayush Sharma)
eec23dad1e test: remove wallet dependency from feature_nulldummy.py (Ayush Sharma)

Pull request description:

  This PR enables one of the non-wallet functional tests (`feature_nulldummy.py`) to be run even with the Bitcoin Core wallet disabled.

  Commit 1: removes wallet dependency and `test_runner.py` is edited to make sure the test only runs once.
  Commit 2: the functions `create_transaction()` and `create_raw_transaction()` in `blocktools.py` are no longer needed and hence removed.

ACKs for top commit:
  kouloumos:
    re-ACK 50ba6697f3, all comments have been addressed.

Tree-SHA512: 3bc3d2766e53dba3d56a03f2c476442608ac693f51d84f4632a22a2cf169bc02c10bf92b676f7d57acb4f0ad86f307d37ab63f936b44b3585ee3c9d08cd0335f
2022-06-30 17:39:45 +02:00
fanquake
6adae27f8c
Merge bitcoin/bitcoin#24836: add RPC (-regtest only) for testing package policy
e866f0d066 [functional test] submitrawpackage RPC (glozow)
fa076515b0 [rpc] add new submitpackage RPC (glozow)

Pull request description:

  It would be nice for LN/wallet/app devs to test out package policy, package RBF, etc., but the only interface to do so right now is through unit tests. This PR adds a `-regtest` only RPC interface so people can test by submitting raw transaction data. It is regtest-only, as it would be unsafe/confusing to create an actual mainnet interface while package relay doesn't exist.

  Note that the functional tests are there to ensure the RPC interface is working properly; they aren't for testing policy itself. See src/test/txpackage_tests.cpp.

ACKs for top commit:
  t-bast:
    Tested ACK against eclair e866f0d066
  ariard:
    Code Review ACK e866f0d0
  instagibbs:
    code review ACK e866f0d066

Tree-SHA512: 824a26b10d2240e0fd85e5dd25bf499ee3dd9ba8ef4f522533998fcf767ddded9f001f7a005fe3ab07ec95e696448484e26599803e6034ed2733125c8c376c84
2022-06-30 15:43:50 +01:00
MacroFake
1ee597817f
Merge bitcoin/bitcoin#25503: test: pass datacarriersize option for tests using large outputs (instead of acceptnonstdtxn)
475aae846e test: pass `datacarriersize` option for tests using large outputs (instead of `acceptnonstdtxn`) (Sebastian Falbesoner)
b1ba3ed155 test: let `gen_return_txouts` create a single large OP_RETURN output (Sebastian Falbesoner)
f319287d81 test: assert serialized txouts size of `gen_return_txouts` helper (Sebastian Falbesoner)

Pull request description:

  By specifying the `datacarriersize` option instead of the more generic `acceptnonstdtxn` for functional tests, we can be more specific about what part of the transaction is non-standard and can be sure that all other aspects follow the standard policy. Transactions with more than one OP_RETURN output are [never considered standard](749b80b29e/src/policy/policy.cpp (L149-L153)), i.e. we have to change the `gen_return_txouts` helper to create only a single output in order to get rid of the `acceptnonstdxtn` option. Note that on master there is currently no test using the `datacarriersize` parameter, so this PR indirectly also increases the test coverage.

  The change affects the tests `mempool_limit.py`, `mining_prioritisetransaction.py` (call `gen_return_txouts` directly) and `feature_maxuploadtarget.py` (calls `gen_return_txouts` indirectly via the `mine_large_block(...)` helper).

Top commit has no ACKs.

Tree-SHA512: c17f032e00d28f5e5880a4d378773fbc8b1995ea9c377f237598d412628fe117f497a44ebdfa8af8cd8a3b1e3127e0cf7692efbf5c833c713764a71a85301f23
2022-06-30 16:37:49 +02:00
Ayush Sharma
0ee43d13e9 test: refactor rpc_signrawtransaction.py
rpc_signrawtransaction.py is split into rpc_signrawtransactionwithkey.py and wallet_signrawtransactionwithwallet.py.
rpc_signrawtransactionwithkey.py can be run with the wallet disabled.
2022-06-30 19:12:01 +05:30
brunoerg
d22bd543cc test: passing a non-positive integer value to -peertimeout should throw an error 2022-06-30 10:18:36 -03:00
Sebastian Falbesoner
475aae846e test: pass datacarriersize option for tests using large outputs (instead of acceptnonstdtxn)
By specifying the `datacarriersize` option instead of the more
generic `acceptnonstdtxn`, we can be more specific about what
part of the transaction is non-standard and can be sure that all
other aspects follow the standard policy.
2022-06-29 18:05:59 +02:00
Sebastian Falbesoner
b1ba3ed155 test: let gen_return_txouts create a single large OP_RETURN output
Transactions with more than one datacarrier (OP_RETURN) output
are never considered standard, i.e. this change is necessary in
order to to get rid of the `acceptnonstdtxn` option for some
tests.
2022-06-29 17:42:51 +02:00
Sebastian Falbesoner
f319287d81 test: assert serialized txouts size of gen_return_txouts helper
This assures that changing the internals of the helper function
still leads to the expected outcome sizewise (preparation for the
next commit).
2022-06-29 17:28:33 +02:00
MacroFake
6666803c89
streams: Add AutoFile without ser-type and ser-version
The moved parts can be reviewed with "--color-moved=dimmed-zebra".
The one-char changes can be reviewed with "--word-diff-regex=.".
2022-06-29 10:31:53 +02:00
MacroFake
e4e201dfd9
Merge bitcoin/bitcoin#25290: [kernel 3a/n] Decouple CTxMemPool from ArgsManager
d1684beabe fees: Pass in a filepath instead of referencing gArgs (Carl Dong)
9a3d825c30 init: Remove redundant -*mempool*, -limit* queries (Carl Dong)
6c5c60c412 mempool: Use m_limit for UpdateTransactionsFromBlock (Carl Dong)
9e93b10301 node/ifaces: Use existing MemPoolLimits (Carl Dong)
38af2bcf35 mempoolaccept: Use limits from mempool in constructor (Carl Dong)
9333427014 mempool: Introduce (still-unused) MemPoolLimits (Carl Dong)
716bb5fbd3 scripted-diff: Rename anc/desc size limit vars to indicate SI unit (Carl Dong)
1ecc77321d scripted-diff: Rename DEFAULT_MEMPOOL_EXPIRY to indicate time unit (Carl Dong)
aa9141cd81 mempool: Pass in -mempoolexpiry instead of referencing gArgs (Carl Dong)
51c7a41a5e init: Only determine maxmempool once (Carl Dong)
386c9472c8 mempool: Make GetMinFee() with custom size protected (Carl Dong)
82f00de7a6 mempool: Pass in -maxmempool instead of referencing gArgs (Carl Dong)
f1941e8bfd pool: Add and use MemPoolOptions, ApplyArgsManOptions (Carl Dong)
0199bd35bb fuzz/rbf: Add missing TestingSetup (Carl Dong)
ccbaf546a6 scripted-diff: Rename DEFAULT_MAX_MEMPOOL_SIZE to indicate SI unit (Carl Dong)
fc02f77ca6 ArgsMan: Add Get*Arg functions returning optional (Carl Dong)

Pull request description:

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

  -----

  As mentioned in the Stage 1 Step 2 description of [the `libbitcoinkernel` project](https://github.com/bitcoin/bitcoin/issues/24303), `ArgsManager` will not be part of `libbitcoinkernel`. Therefore, it is important that we remove any dependence on `ArgsManager` by code that will be part of `libbitcoinkernel`. This is the first in a series of PRs aiming to achieve this.

  This PR removes `CTxMemPool+MempoolAccept`'s dependency on `ArgsManager` by introducing a `CTxMemPool::Options` struct, which is used to specify `CTxMemPool`'s various options at construction time.

  These options are:
  - `-maxmempool` -> `CTxMemPool::Options::max_size`
  - `-mempoolexpiry` -> `CTxMemPool::Options::expiry`
  - `-limitancestorcount` -> `CTxMemPool::Options::limits::ancestor_count`
  - `-limitancestorsize` -> `CTxMemPool::Options::limits::ancestor_size`
  - `-limitdescendantcount` -> `CTxMemPool::Options::limits::descendant_count`
  - `-limitdescendantsize` -> `CTxMemPool::Options::limits::descendant_size`

  More context can be gleaned from the commit messages. The important commits are:

  - 56eb479ded8bfb2ef635bb6f3b484f9d5952c70d "pool: Add and use MemPoolOptions, ApplyArgsManOptions"
  - a1e08b70f3068f4e8def1c630d8f50cd54da7832 "mempool: Pass in -maxmempool instead of referencing gArgs"
  - 6f4bf3ede5812b374828f08fc728ceded2f10024 "mempool: Pass in -mempoolexpiry instead of referencing gArgs"
  - 5958a7fe4806599fc620ee8c1a881ca10fa2dd16 "mempool: Introduce (still-unused) MemPoolLimits"

  Reviewers: Help needed in the following commits (see commit messages):
  - a1e08b70f3068f4e8def1c630d8f50cd54da7832 "mempool: Pass in -maxmempool instead of referencing gArgs"
  - 0695081a797e9a5d7787b78b0f8289dafcc6bff7 "node/ifaces: Use existing MemPoolLimits"

  Note to Reviewers: There are perhaps an infinite number of ways to architect `CTxMemPool::Options`, the current one tries to keep it simple, usable, and flexible. I hope we don't spend too much time arguing over the design here since that's not the point. In the case that you're 100% certain that a different design is strictly better than this one in every regard, please show us a fully-implemented branch.

  -----

  TODO:
  - [x] Use the more ergonomic `CTxMemPool::Options` where appropriate
  - [x] Doxygen comments for `ApplyArgsManOptions`, `MemPoolOptions`

  -----

  Questions for Reviewers:
  1. Should we use `std::chrono::seconds` for `CTxMemPool::Options::expiry` and `CTxMemPool::m_expiry` instead of an `int64_t`? Something else? (`std::chrono::hours`?)
  2. Should I merge `CTxMemPool::Limits` inside `CTxMemPool::Options`?

ACKs for top commit:
  MarcoFalke:
    ACK d1684beabe 🍜
  ryanofsky:
    Code review ACK d1684beabe. Just minor cleanups since last review, mostly switching to brace initialization

Tree-SHA512: 2c138e52d69f61c263f1c3648f01c801338a8f576762c815f478ef5148b8b2f51e91ded5c1be915e678c0b14f6cfba894b82afec58d999d39a7bb7c914736e0b
2022-06-29 09:13:31 +02:00
Suhas Daftuar
abf5d16c24 Don't send getheaders message when another request is outstanding
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.

p2p_segwit.py is modified to use this same strategy, as the test logic (of
expecting a getheaders after a block inv) would otherwise be broken.
2022-06-28 15:53:25 -04:00
Carl Dong
1ecc77321d scripted-diff: Rename DEFAULT_MEMPOOL_EXPIRY to indicate time unit
Better to be explicit when it comes to time to avoid unintentional bugs.

-BEGIN VERIFY SCRIPT-
find_regex="DEFAULT_MEMPOOL_EXPIRY" \
    && git grep -l -E "$find_regex" \
        | xargs sed -i -E "s@$find_regex@\0_HOURS@g"
-END VERIFY SCRIPT-
2022-06-28 15:42:40 -04:00
laanwj
5bf65ec66e
Merge bitcoin/bitcoin#22558: psbt: Taproot fields for PSBT
b80de4c505 test: Test signing psbts without explicitly having scripts (Andrew Chow)
a73b56888a wallet: also search taproot pubkeys in FillPSBT (Andrew Chow)
6cff82722f sign: Use sigdata taproot spenddata when signing (Andrew Chow)
5f12fe3f36 psbt: Implement merge for Taproot fields (Andrew Chow)
1ece9a3715 psbt, test: Check for taproot fields in taproot psbt test (Andrew Chow)
496a1bbe5e taproot: Use pre-existing signatures if available (Andrew Chow)
0ad21e7c55 tests: Test taproot fields for PSBT (Andrew Chow)
103c6fd279 psbt: Remove non_witness_utxo for segwit v1+ (Andrew Chow)
7dccdd3157 Implement decodepsbt for Taproot fields (Andrew Chow)
ac7747585f Fill PSBT Taproot output data to/from SignatureData (Andrew Chow)
25b6ae46e7 Assert that TaprootBuilder is Finalized during GetSpendData (Andrew Chow)
3ae5b6af21 Store TaprootBuilder in SigningProviders instead of TaprootSpendData (Andrew Chow)
4d1223e512 Fetch key origins for Taproot keys (Andrew Chow)
52e3f2f88e Fill PSBT Taproot input data to/from SignatureData (Andrew Chow)
05e2cc9a30 Implement de/ser of PSBT's Taproot fields (Andrew Chow)
d557eff2ad Add serialization methods to XOnlyPubKey (Andrew Chow)
d43923c381 Add TaprootBuilder::GetTreeTuples (Andrew Chow)
ce911204e4 Move individual KeyOriginInfo de/ser to separate function (Andrew Chow)

Pull request description:

  Implements the Taproot fields for PSBT described in [BIP 371](https://github.com/bitcoin/bips/blob/master/bip-0371.mediawiki).

ACKs for top commit:
  laanwj:
    Code review ACK b80de4c505

Tree-SHA512: 50b79bb44f353c9ec2ef4c98aac08a81eba560987e5264a5684caa370e9c4e7a8255c06747fc47749511be45b32d01492e015f92b82be8d22bc8bf192073bd26
2022-06-28 16:44:03 +02:00
Andrew Chow
b80de4c505 test: Test signing psbts without explicitly having scripts 2022-06-27 16:48:04 -04:00
Andrew Chow
1ece9a3715 psbt, test: Check for taproot fields in taproot psbt test 2022-06-27 16:47:48 -04:00
Andrew Chow
496a1bbe5e taproot: Use pre-existing signatures if available
Actually use pre-existing signatures in CreateTaprootScriptSig if a
signature is found for the given key and leaf hash.
2022-06-27 16:47:48 -04:00
Andrew Chow
0ad21e7c55 tests: Test taproot fields for PSBT 2022-06-27 16:47:48 -04:00
Sebastian Falbesoner
f665c6ecda test: fix failing test interface_usdt_utxocache.py
The `from_node` argument doesn't exist anymore for
`MiniWallet.create_self_transfer` since PR #25435 (commit
fa8421bc5b).
2022-06-27 19:40:28 +02:00
Jon Atack
2ef5294a5b rpc: add RPCTypeCheck for getblockfrompeer inputs 2022-06-27 13:03:24 +02:00
MacroFake
fa83c0c44f
test: Remove unused call to generate in rpc_mempool_info
There are already enough blocks
2022-06-27 11:09:01 +02:00
MacroFake
fa13375aa3
test: Sync MiniWallet utxo state after each generate call 2022-06-27 11:08:50 +02:00
MacroFake
dddd7c4d39
test: Drop spent utxos in MiniWallet scan_tx 2022-06-27 11:08:29 +02:00
MacroFake
fa04ff61b6
test: Return new_utxos from create_self_transfer_multi in MiniWallet 2022-06-27 11:07:34 +02:00
MacroFake
fa34e44e98
test: Return new_utxo from create_self_transfer in MiniWallet 2022-06-27 11:07:29 +02:00
MacroFake
f52d074363
Merge bitcoin/bitcoin#25439: rpc: Return incrementalrelayfee in getmempoolinfo
fafee78188 rpc: Return incrementalrelayfee in getmempoolinfo (MacroFake)

Pull request description:

  Seems odd to return other policy info, but not the incremental relay fee

ACKs for top commit:
  1440000bytes:
    ACK fafee78188
  w0xlt:
    Code Review ACK fafee78188
  jarolrod:
    tACK fafee78188

Tree-SHA512: faad0af6c039b8257acbeac913bc5dcdb2ea2db304c95e52601536c8de60eb1186e9fbb4a64a68adf476605f18022aeda16a5644a0d7912592b0977e4c029638
2022-06-27 08:19:14 +02:00
MacroFake
c1acd34984
Merge bitcoin/bitcoin#25476: test: Remove unnecessary mining from importdescriptors test
e3d8d72703 test: Remove unnecessary block mining from importdescriptors test (Fabian Jahr)

Pull request description:

  This removes generation of 6 blocks and replaces is with a `sync_all` in the `importdescriptors` test.

  The generated blocks themself don't seem to serve any purpose in the test. Instead they could make the test flaky (although I did not find open issues pointing to this happening in practice in the CI). Right before the blocks being generated a transaction is created (L454) and later in the test this tx is assumed to be still in the mempool. If the nodes were to sync their mempools before the blocks are generated, the test fails. It currently only seems to work because one node sends the tx while the other generates the blocks and the mempools are not synced fast enough.

  The `sync_all` is still needed to let nodes catch up at that point. Otherwise races happen further below which the generate call seems to have prevented so far.

ACKs for top commit:
  laanwj:
    Code review ACK e3d8d72703

Tree-SHA512: 14f3dc2938d779d1ad43e09a7e046523fc3c92f41df012833f279a2e88e74c2fcab301fe4f3fcc038bd8460ea1360725a8d1eb5b59acd1039495bacb484fd790
2022-06-27 08:16:28 +02:00
Fabian Jahr
e3d8d72703
test: Remove unnecessary block mining from importdescriptors test 2022-06-26 16:34:11 +02:00
Ayush Sharma
50ba6697f3 remove unused functions
the functions `create_transaction()` and `create_raw_transaction()` were no longer used hence removed.
2022-06-24 18:04:48 +05:30
Ayush Sharma
eec23dad1e test: remove wallet dependency from feature_nulldummy.py
This test can now be run even with the Bitcoin Core wallet disabled.
2022-06-24 17:56:53 +05:30
glozow
e866f0d066 [functional test] submitrawpackage RPC 2022-06-23 14:39:47 +01:00
MacroFake
01e9e2d1ca
Merge bitcoin/bitcoin#25451: test: -whitebind and -bind with -listen=0 should throw an error
ceec6808d3 test: `-whitebind` and `-bind`  with `-listen=0` should throw an error (brunoerg)

Pull request description:

  This PR adds test coverage for the following init error:
  b9122e95f0/src/init.cpp (L872-L875)

ACKs for top commit:
  laanwj:
    Code review ACK ceec6808d3

Tree-SHA512: 03068abe7199b1235f029871ab87a3dd4943738c592ad62d82cdcd3e0201e627624960bd3ea1fc6fc1e7da4b8e215ba3393d1cb8130e1108049f764e51dc75c0
2022-06-23 12:08:19 +02:00
brunoerg
ceec6808d3 test: -whitebind and -bind with -listen=0 should throw an error 2022-06-22 15:22:25 -03:00
furszy
d69045e291
test: add coverage for 'listreceivedbyaddress' no change addrs return 2022-06-22 12:51:30 -03:00
MacroFake
faee330c7b
test: Fail if connect_nodes fails
Also replace the use of wait_until_helper, which is not allowed to be
called directly. Otherwise, --timeout-factor will not be honoured.
2022-06-22 09:15:33 +02:00
MacroFake
fafee78188
rpc: Return incrementalrelayfee in getmempoolinfo 2022-06-21 18:03:29 +02:00
MacroFake
fa8421bc5b
test: Remove from_node from create_self_transfer* MiniWallet helpers
The from_node argument is no longer used as of commit
a55606c3bd
2022-06-21 12:02:01 +02:00
Sebastian Falbesoner
be8d0dba15 test: refactor: save MiniWallet mode explicitly
Rather than abusing the member variables self._priv_key and
self._address to determine the MiniWallet mode, save it explicitly
instead in the constructor to increase the readability and
maintainability of the code.
2022-06-21 10:54:42 +02:00
laanwj
f8586b25f6
Merge bitcoin/bitcoin#25289: test: implement 'bech32m' mode for getnewdestination() helper
dcf36fe8e3 test: implement 'bech32m' mode for `getnewdestination()` helper (Sebastian Falbesoner)
1999dcfa40 test: add helpers for creating P2TR scripts/addresses from output key (Sebastian Falbesoner)

Pull request description:

  This PR adds the missing 'bech32m' mode for the `getnewdestination()` helper and sets it as default, i.e. the function returns a tuple (output x-only-pubkey, scriptPubKey, taproot address) now if not specified otherwise. In a preparation commit, the helpers `output_key_to_p2tr{_script}` are introduced. Note that in contrast to all other common script output types, there are usually _two_ keys involved in creating a taproot output (internal key and output key), hence the prefix `output_` is used to clarify that the  output key is expected and the helpers don't do any key tweaking.

  Thanks to michaelfolkson (for pointing out this TODO that I forgot about) and sipa (for patiently explaining basic things about BIP341).

ACKs for top commit:
  michaelfolkson:
    ACK dcf36fe8e3
  w0xlt:
    reACK dcf36fe8e3

Tree-SHA512: 5bb8d5fd96c63092ede10c3f022ffb2e13c14e333c4aa73348d95deb70cbf0a74745218dc4a7c419eb846793dd69e8217a7b4332a13ae2b2758e100b51fb1a9f
2022-06-17 22:51:42 +02:00
Andrew Chow
b0c8306349
Merge bitcoin/bitcoin#24649: wallet: do not count wallet utxos as external
7832e9438f test: fundrawtransaction preset input weight calculation (S3RK)
c3981e379f wallet: do not count wallet utxos as external (S3RK)

Pull request description:

  Correctly differentiating between external vs non-external utxos in coin control produces more accurate weight and fee estimations.

  Weight for external utxos is estimated based on the maximum signature size, while for the wallet utxos we expect minimal signature due to signature grinding.

ACKs for top commit:
  achow101:
    re-ACK 7832e9438f
  Xekyo:
    re-ACK 7832e9438f
  furszy:
    ACK 7832e943

Tree-SHA512: bb5635b0bd85fa9a76922a53ad3fa062286424c06a695a0e87407c665713e80a33555b644fbb13bcc1ab503dcd7f53aacbdc368d69ac0ecff8005603623ac94f
2022-06-16 14:11:19 -04:00
Andrew Chow
51eebe082d
Merge bitcoin/bitcoin#25368: doc: Update importaddress mention incompatibility with descriptor wallet
e3609cdc01 doc: Update importaddress mention incompatibility with descriptor wallet (BrokenProgrammer)

Pull request description:

  This is related to #25363 and offers a small update to the error messages from `EnsureLegacyScriptPubKeyMan` and `EnsureConstLegacyScriptPubKeyMan` to mention that they only are compatible with legacy wallets.

  The RPC documentation for `importaddress` is also updated to mention this as well as guide the user to the alternative `importdescriptors` for cases when using descriptor wallets.

  I'm thinking that we can introduce a "porting guide" document mentioned in #25363 in a separate PR since I would have to make myself more familiar with the subject before being able to tackle that.

ACKs for top commit:
  laanwj:
    Code review ACK e3609cdc01
  achow101:
    ACK e3609cdc01

Tree-SHA512: c7a924a7283fe59dc4e04c8c8fa034c15601f0b25eff09d975e98e2e8db5268ff470336b2d978d6916af9f782f9257b840d64bd15485b1742b4a8b8bfd0bb50f
2022-06-15 13:40:32 -04:00
MacroFake
6acba84603
Merge bitcoin/bitcoin#25358: test: passing a value below 5 MB to -maxmempool should throw an error
216c9b00ec test: passing a value below 5 MB to -maxmempool should throw an error (brunoerg)

Pull request description:

  This PR adds test coverage for the following init error:
  5174a139c9/src/init.cpp (L931-L935)

  By default, the minimum value is 5 MB. See:
  https://github.com/bitcoin/bitcoin/blob/master/doc/reduce-memory.md#memory-pool

ACKs for top commit:
  laanwj:
    Code review ACK 216c9b00ec
  furszy:
    Code review ACK 216c9b00

Tree-SHA512: 0c8fdcefb85e3dabb986a6294ad18503168a04246926614cbfa2d09d9e997312c937b01994f2999b1dc583e2eac5cdb8058bd58577baeb3eb23fdc690400cab9
2022-06-15 19:24:14 +02:00
MacroFake
4c0d1fec16
Merge bitcoin/bitcoin#25374: test: remove unused create_confirmed_utxos helper
42b2fdfd5f test: remove unused `create_confirmed_utxos` helper (Sebastian Falbesoner)

Pull request description:

  After more and more non-wallet tests have been converted to use MiniWallet (#25087, #24839, #24749 etc.), the `create_confirmed_utxos` helper is now not used anymore and can be removed. An alternative would be to create a MiniWallet version of `create_confirmed_utxos`, but it seems that it's not worth it, considering that would be only two lines (calling MiniWallet's `send_self_transfer_multi` with a subsequent `generate` call), see comment https://github.com/bitcoin/bitcoin/pull/24839#discussion_r896472729.

ACKs for top commit:
  MarcoFalke:
    cr ACK 42b2fdfd5f

Tree-SHA512: 274418156265a6071940f53cbcd77f6779af5e951cfa1e5efbf07a5c61487b521ee19f36b4105e5c0a808139d121e5e262e77525ea3d1486a0421f01abcf58fd
2022-06-15 08:38:19 +02:00
MacroFake
a57492f65d
Merge bitcoin/bitcoin#25370: test: check for getblocktxn request with out-of-bounds tx index
5a8c321444 test: check for `getblocktxn` request with out-of-bounds tx index (Sebastian Falbesoner)

Pull request description:

  This PR adds missing test coverage for the `getblocktxn` message handler, in the case that any of the contained indices is out-of-bounds:
  a05876619a/src/net_processing.cpp (L2180-L2183)

ACKs for top commit:
  dunxen:
    ACK 5a8c321

Tree-SHA512: 2743c2c6d8aed57b22f825aefd60ba3e670321b60625a42ea7248e7b0fc41c73e9a5945153567c02824ba3b5f0fce7f4125bffc974973fc608b6ffbe49e14b65
2022-06-15 08:19:45 +02:00
Sebastian Falbesoner
42b2fdfd5f test: remove unused create_confirmed_utxos helper
Confirmed UTXOs in functional tests can simply be created by using
MiniWallet's `send_self_transfer_multi` method with a subsequent
`generate` call to mine a block.
2022-06-15 00:58:02 +02:00
BrokenProgrammer
e3609cdc01 doc: Update importaddress mention incompatibility with descriptor wallet 2022-06-14 20:54:45 +02:00
Sebastian Falbesoner
5a8c321444 test: check for getblocktxn request with out-of-bounds tx index 2022-06-14 18:11:22 +02:00
Sebastian Falbesoner
dcf36fe8e3 test: implement 'bech32m' mode for getnewdestination() helper 2022-06-14 13:37:18 +02:00
Sebastian Falbesoner
1999dcfa40 test: add helpers for creating P2TR scripts/addresses from output key 2022-06-14 13:32:57 +02:00
MacroFake
fafddafc2c
refactor: Introduce PeerManagerImpl::RejectIncomingTxs
Currently there are some confusions in net_processing:

* There is confusion between `-blocksonly mode` and `block-relay-only`,
  so adjust all comments to use the same nomenclature.
* Whether to disconnect peers for providing invs/txs is implemented
  differently. For example, it seems a bit confusing to disconnect
  `block-relay-only` peers with `relay` permission when they send a tx
  message, but not when they send an inv message. Also, keeping track of
  their inv announcements seems both wasteful and confusing, as it does
  nothing. This isn't possible in practice, as outbound connections do
  not have permissions assigned, but sees fragile to rely on. Especially
  in light of proposed changes to make that possible:
  https://github.com/bitcoin/bitcoin/pull/17167
2022-06-14 08:39:55 +02:00
MacroFake
fa779de665
test: Remove MiniWallet mempool_valid option 2022-06-13 18:09:16 +02:00
MacroFake
506d9b25a3
Merge bitcoin/bitcoin#24839: test: use MiniWallet for mining_prioritisetransaction.py
b167e536d0 test: refactor: use `create_lots_of_big_transactions` to dedup where possible (Sebastian Falbesoner)
8973eeb412 test: use MiniWallet for mining_prioritisetransaction.py (Sebastian Falbesoner)

Pull request description:

  This PR enables one more of the non-wallet functional tests (mining_prioritisetransaction.py) to be run even with the Bitcoin Code wallet by using the MiniWallet instead, as proposed in #20078. Note that the adapted helper function `create_lots_of_big_transactions` is currently only used in this test, i.e. there was no need to change any others.

ACKs for top commit:
  ayush933:
    tACK b167e53
  danielabrozzoni:
    tACK b167e536d0
  kouloumos:
    ACK b167e536d0
  furszy:
    ACK b167e536

Tree-SHA512: ccae20d7d414a720efdeea9c2ae399aa53a3a0e7db72bff8d0cb75d90621a7ae7c019ba68d24f9d06f7b111f87ff33bb9d8e5aa08b763e606cf10268780e205c
2022-06-13 17:59:01 +02:00
brunoerg
216c9b00ec test: passing a value below 5 MB to -maxmempool should throw an error 2022-06-13 09:58:22 -03:00
MacroFake
fa7a711a30
test: Fix out-of-range port collisions 2022-06-10 15:56:07 +02:00
amadeuszpawlik
292b1a3e9c GetExternalSigner(): fail if multiple signers are found
If there are multiple external signers, `GetExternalSigner()` will
just pick the first one in the list. If the user has two or more
hardware wallets connected at the same time, he might not notice this.

This PR adds a check and fails with suitable message.
2022-06-09 20:34:46 +02:00
dergoegge
ea54ba2f42 [test] Fix port collisions caused by p2p_getaddr_caching.py 2022-06-08 21:00:45 +02:00
dergoegge
f9682e75ac [test_framework] Set PortSeed.n directly after initialising params
This allows us to use `p2p_port()` with `set_test_params()`.
2022-06-08 21:00:18 +02:00
MacroFake
455780b1ae
Merge bitcoin/bitcoin#25294: test: Fix wait_for_debug_log UnicodeDecodeError
fa74b63c01 test: Fix wait_for_debug_log UnicodeDecodeError (MacroFake)

Pull request description:

  Fix the intermittent `UnicodeDecodeError` when the debug log is truncated on an (multi-byte) unicode character by treating everything as bytes.

  Also, remove the `ignore_case` option and the`re.search+re.escape` wrap. All of this is unused and doesn't exist on raw byte strings.

  Fixes https://github.com/bitcoin/bitcoin/issues/24575

ACKs for top commit:
  jonatack:
    ACK fa74b63c01
  brunoerg:
    ACK fa74b63c01

Tree-SHA512: c67c9355073e784fa8d9d48b8e79ff0c98f5ae9cd4d704ad12a76d2604733946054bc74b8ab346aa2184db23d740b85c8c13eb892d76cba92e42ebfd73f2f1bf
2022-06-08 17:53:06 +02:00
fanquake
b9416c3847
Merge bitcoin/bitcoin#25096: [net] Minor improvements to addr caching
292828cd77 [test] Test addr cache for multiple onion binds (dergoegge)
3382905bef [net] Seed addr cache randomizer with port from binding address (dergoegge)
f10e80b6e4 [net] Use ConnectedThroughNetwork() instead of GetNetwork() to seed addr cache randomizer (dergoegge)

Pull request description:

  The addr cache id randomizer is currently supposed to be seeded with the network of the inbound connection and the local socket (only the address is used not the port):  a8098f2cef/src/net.cpp (L2800-L2804)

  For inbound onion connections `CNode::addr.GetNetwork()` returns `NET_UNROUTABLE` and `CNode::addrBind` is set to `127.0.0.1:<onion bind port>`. This results in the same addr cache for all inbound connections on 127.0.0.1 binds.

  To avoid the same addr cache across all onion and other 127.0.0.1 binds, we should seed the addr cache randomizer with the correct network for inbound onion connections (using `CNode::ConnectedThroughNetwork()`) as well as the port of `CNode::addrBind`.

ACKs for top commit:
  sipa:
    utACK 292828cd77
  mzumsande:
    Code Review ACK 292828cd77
  naumenkogs:
    utACK 292828cd77

Tree-SHA512: d0be13bab6bc121c2926d4b168687f6c2ed4ce0c9dd19be71eb4886adeba8afc3daacdc4e232a0ba3b03a89d69b618abc5595b69abd1ad0c476d825bc6ea1f9f
2022-06-08 11:21:38 +01:00
MacroFake
fa74b63c01
test: Fix wait_for_debug_log UnicodeDecodeError 2022-06-07 20:54:37 +02:00
laanwj
e282764e04
Merge bitcoin/bitcoin#25228: test: add BIP-125 rule 5 testcase with default mempool
687addaf13 test: add BIP-125 rule 5 testcase with default mempool (James O'Beirne)
6120e8e287 test: allow passing sequence through create_self_transfer_multi (James O'Beirne)

Pull request description:

  Currently, we only test rule 5 of BIP-125 (replacement transactions cannot evict more than 100 transactions) by changing default mempool parameters to allow for more descendants. The current test works on a single transaction graph that has over 100 descendants.

  This patch adds a test to exercise rule 5 using the default mempool parameters. The case is a little more sophisticated: instead of working on a single transaction graph, it uses a replacement transaction to "unite" several UTXOs which join independent transaction graphs. The total number of transactions in these graphs sum to more than the max allowable replacement.

  I think the difference in transaction topology makes this a worthwhile testcase to have, setting aside the fact that this testcase works without having to use atypical mempool params.

  See also: [relevant discussion from IRC](https://www.erisian.com.au/bitcoin-core-dev/log-2022-05-27.html#l-126)

ACKs for top commit:
  laanwj:
    Code review ACK 687addaf13
  LarryRuane:
    ACK 687addaf13

Tree-SHA512: e589aeaf9d6f137d546b7809f8795d6f6043d87b15e97c2efe85b42ce8b49d977ee7d79440c542ca4b0b5ca2de527488029841a1ffc0d96c5771897df4b3f324
2022-06-07 20:49:33 +02:00
MacroFake
581e2bdbac
Merge bitcoin/bitcoin#24629: Bugfix: RPC/blockchain: pruneblockchain: Return the height of the actual last pruned block
e593ae07c4 Bugfix: RPC/blockchain: pruneblockchain: Return the height of the actual last pruned block (Luke Dashjr)

Pull request description:

  From 0.14 (2017 Mar) until before 0.19 (2019 Nov), the height of the last block pruned was returned, subject to a bug if there were blocks left unpruned due to sharing files with later blocks.

  In #15991, this was "fixed" to the current implementation, introducing a new bug: now, it returns the first *unpruned* block.

  Since the user provides the parameter as a block to include in pruning, it makes more sense to fix the behaviour to match the documentation.

  ~~(Additionally, the description of "pruneheight" in getblockchaininfo is fixed to be technically correct)~~

ACKs for top commit:
  fjahr:
    utACK e593ae07c4
  ryanofsky:
    Code review ACK e593ae07c4. Just rebased since last review. Maybe some of the original reviewers of #15991 will want to take a look at this to correct the mistake that was introduced there!

Tree-SHA512: c2d511df80682d57260aae8af1665f9d7eaed16448f185f4c9f23c78fa9b8289a02053da7a0b83643fef57610d601ea63b59ff39661a51f4827f1eb27cc30594
2022-06-07 08:04:51 +02:00
laanwj
06ea2783a2
Merge bitcoin/bitcoin#25220: rpc: fix incorrect warning for address type p2sh-segwit in createmultisig
3a9b9bb38e test: ensure createmultisig and addmultisigaddress are not returning any warning for expected cases (brunoerg)
eaf6f630c0 rpc: fix inappropriate warning for address type p2sh-segwit in createmultisig and addmultisigaddress (brunoerg)

Pull request description:

  Fixes #25127

  If there are any uncompressed keys when calling `AddAndGetMultisigDestination`, it will just default to a legacy address regardless of the chosen `address_type`. So, #23113 added a warnings field which will warn the user why their address format is different.

  However, when creating a multisig (p2sh-segwit), it is returning an inappropriate warning, because when getting the output type from destination (`OutputTypeFromDestination`), it returns `ScriptHash` for both legacy and `P2SH_SEGWIT`. So, since `P2SH_SEGWIT` is different from `ScriptHash`, it returns the warning:
  192d639a6b/src/rpc/output_script.cpp (L166-L169)

  So, to avoid this mistake I changed `OutputTypeFromDestination` to `descriptor->GetOutputType()` to get the appropriate output type.

ACKs for top commit:
  jonatack:
    ACK 3a9b9bb38e
  laanwj:
    Code review ACK 3a9b9bb38e

Tree-SHA512: 49f717479c2b8906277e7591ddd4747f7961c2d5c77494b5124045de9036a4277d46b9ad99279d51f0c4484284c445f1e1d3c55c49bbf0716741bad426a89369
2022-06-06 17:13:22 +02:00
brunoerg
3a9b9bb38e test: ensure createmultisig and addmultisigaddress are not returning any warning for expected cases 2022-06-06 09:46:42 -03:00
Luke Dashjr
e593ae07c4 Bugfix: RPC/blockchain: pruneblockchain: Return the height of the actual last pruned block
From 0.14 (2017 Mar) until before 0.19 (2019 Nov), the height of the last
block pruned was returned, subject to a bug if there were blocks left unpruned
due to sharing files with later blocks.

In #15991, this was "fixed" to the current implementation, introducing a new
bug: now, it returns the first *unpruned* block.

Since the user provides the parameter as a block to include in pruning, it
makes more sense to fix the behaviour to match the documentation.
2022-06-03 07:20:07 +00:00
laanwj
00ce8543f1
Merge bitcoin/bitcoin#24171: p2p: Sync chain more readily from inbound peers during IBD
48262a00f5 Add functional test for block sync from inbound peers (Suhas Daftuar)
0569b5c4bb Sync chain more readily from inbound peers during IBD (Suhas Daftuar)

Pull request description:

  When in IBD, if the honest chain is only known by inbound peers, then we must
  eventually sync from them in order to learn it. This change allows us to
  perform initial headers sync and fetch blocks from inbound peers, if we have no
  blocks in flight.

  The restriction on having no blocks in flight means that we will naturally
  throttle our block downloads to any such inbound peers that we may be
  downloading from, until we leave IBD. This is a tradeoff between preferring
  outbound peers for most of our block download, versus making sure we always
  eventually will get blocks we need that are only known by inbound peers even
  during IBD, as otherwise we may be stuck in IBD indefinitely (which could have
  cascading failure on the network, if a large fraction of the network managed to
  get stuck in IBD).

  Note that the test in the second commit fails on master, without the first commit.

ACKs for top commit:
  ajtowns:
    ACK 48262a00f5
  sipa:
    ACK 48262a00f5

Tree-SHA512: ffad3a05fa9a32a92226843c9128f52c275e8d51930fde7368badc340227f2ed680561c4c9f2937b4e3bd722474464849ec9b624f912f5e380ce98d71b55764d
2022-06-02 22:35:05 +02:00
dergoegge
292828cd77 [test] Test addr cache for multiple onion binds 2022-06-02 19:14:17 +02:00
James O'Beirne
687addaf13 test: add BIP-125 rule 5 testcase with default mempool
This testcase exercises rule 5 of BIP-125 (no more than 100 evictions
due to replacement) without having to test under non-default mempool
parametmers.
2022-06-02 10:19:24 -04:00
Sebastian Falbesoner
1bace0cfee test: check replaceable mismatch error in createrawtransaction RPC 2022-06-02 12:59:13 +02:00
MacroFake
fafaad98f7
test: Set maxfeerate=0 in MiniWallet sendrawtransaction() 2022-06-01 17:07:05 +02:00
MacroFake
9cc010f5a9
Merge bitcoin/bitcoin#25087: test: use MiniWallet for feature_dbcrash.py
1da5e45725 test: use MiniWallet for feature_dbcrash.py (Sebastian Falbesoner)

Pull request description:

  This PR enables one more of the non-wallet functional tests (feature_dbcrash.py) to be run even with the Bitcoin Code wallet by using the MiniWallet instead, as proposed in https://github.com/bitcoin/bitcoin/issues/20078.

ACKs for top commit:
  laanwj:
    Code review ACK 1da5e45725
  brunoerg:
    crACK 1da5e45725

Tree-SHA512: 75ee9a32fd1451254004797d695d18032bd0fcb66ebd88cf737e147e43812525f6e884ec05fcc4f76f566dc71174c8ed7347bcdce16567db6511746ae64cead0
2022-06-01 16:43:49 +02:00
Sebastian Falbesoner
7d0f67a0d5 test: check pre-segwit peer error in getblockfrompeer RPC 2022-05-31 23:04:13 +02:00
brunoerg
ebfc308ea4 test: add coverage for non-hex value to -minimumchainwork 2022-05-31 08:23:38 -03:00
MacroFake
5f65afff9c
Merge bitcoin/bitcoin#24178: p2p: Respond to getheaders if we have sufficient chainwork
a35f963edf Add test for getheaders behavior (Suhas Daftuar)
ef6dbe6863 Respond to getheaders if we have sufficient chainwork (Suhas Daftuar)

Pull request description:

  Previously, we would check to see if we were in IBD and ignore getheaders requests accordingly. However, the IBD criteria -- an optimization mostly targeted at behavior when we have peers serving us many blocks we need to download -- is difficult to reason about in edge-case scenarios, such as if the network were to go a long time without any blocks found and nodes are getting restarted during that time.

  To make things simpler to reason about, just use `nMinimumChainWork` as our anti-DoS threshold for responding to a getheaders request; as long as our chain has that much work, it should be fine to respond to a peer asking for our headers (and this should allow such a peer to request blocks from us if needed).

ACKs for top commit:
  klementtan:
    crACK a35f963edf
  naumenkogs:
    ACK a35f963edf
  MarcoFalke:
    review ACK a35f963edf 🗯

Tree-SHA512: 131e3872e7fe80382ea9c1ec202d6c2dc59c006355c69000aa3f4ce6bccd02a6c689c8cb8f3542b5d9bc48bfa61edcbd1a78535c0b79018971d02bed2655d284
2022-05-31 12:05:46 +02:00
MacroFake
269fa667f2
Merge bitcoin/bitcoin#25044: test: Use MiniWallet in rpc_rawtransaction.py
e8959000b6 test: Use MiniWallet in rpc_rawtransaction.py (Daniela Brozzoni)
e93046c10b MOVEONLY: Move signrawtransactionwithwallet test (Daniela Brozzoni)

Pull request description:

  This PR allows `rpc_rawtransaction.py` to be run even without the Core wallet by using the MiniWallet instead, as proposed in https://github.com/bitcoin/bitcoin/issues/20078.
  This test was previously run twice, once with `--legacy-wallet` and once with
  `--descriptors`. Since this would have meant running the same test twice
  if the wallet wasn't compiled, now we run it just once with the legacy
  wallet.

ACKs for top commit:
  jonatack:
    ACK e8959000b6

Tree-SHA512: d1580570a54dad8e30a5df1ab7d03ecb3f824efe6843323e1f3aef63592045d823c7d54fc86321dc7c1d414854a253431a01a7baa9f30426ea9a09ef11ae3a04
2022-05-30 16:57:47 +02:00
Daniela Brozzoni
e8959000b6
test: Use MiniWallet in rpc_rawtransaction.py
This test was previously run twice, once with `--legacy-wallet` and once with
`--descriptors`.
Now we run it only with `--legacy-wallet`, as all the tests has been
ported to the MiniWallet but `raw_multisig_transaction_legacy_tests`,
which can be run only with the legacy wallet.
We also decrease the number of nodes used from 4 to 3, making the test
run slightly faster.
2022-05-30 16:25:18 +02:00
Daniela Brozzoni
e93046c10b
MOVEONLY: Move signrawtransactionwithwallet test
Put signrawtransactionwithwallet_tests in rpc_signrawtransaction.py,
as the test is mainly testing the signrawtransaction RPC.
Review with `git show --color-moved=dimmed-zebra`
2022-05-30 16:25:17 +02:00
James O'Beirne
6120e8e287 test: allow passing sequence through create_self_transfer_multi
And some little type annotation additions.
2022-05-27 13:40:06 -04:00
Sebastian Falbesoner
387ae8bc09 rpc: remove deprecated fee fields from mempool entries 2022-05-27 17:29:04 +02:00
MacroFake
3ba6dd6f4b
Merge bitcoin/bitcoin#24408: rpc: add rpc to get mempool txs spending specific prevouts
4185570340 Add RPC to get mempool txs spending outputs (t-bast)

Pull request description:

  We add an RPC to fetch mempool transactions spending any of the given outpoints.

  Without this RPC, application developers need to first call `getrawmempool` which returns a long list of `txid`, then fetch each of these transactions individually (`getrawtransaction`) to check whether they spend the given outpoints, which wastes a lot of bandwidth (in the worst case we need to transfer the whole mempool).

  For example in lightning, when we discover that one of our channel funding transactions has been spent, we need to find the spending transaction to claim our outputs from it. We are currently forced to fetch the whole mempool to do the analysis ourselves, which is quite costly.

  I believe that this RPC is also generally useful when doing some introspection on your mempool after one of your transactions failed to broadcast, for example when you implement RBF at the application level. Fetching and analyzing the conflicting transaction gives you more information to successfully replace it.

ACKs for top commit:
  darosior:
    re-utACK 4185570340
  vincenzopalazzo:
    re-ACK 4185570340
  danielabrozzoni:
    re-tACK 4185570340
  w0xlt:
    reACK 4185570340

Tree-SHA512: 206687efb720308b7e0b6cf16dd0a994006c0b5a290c8eb386917a80130973a6356d0d5cae1c63a01bb29e066dd721594969db106cba7249214fcac90d2c3dbc
2022-05-27 15:16:00 +02:00
brunoerg
295ff61934 test: add coverage for unknown -blockfilterindex 2022-05-23 18:06:13 -03:00
Andrew Chow
5ebff43025
Merge bitcoin/bitcoin#25122: rpc: getreceivedbylabel, return early if no addresses were found in the address book
baa3ddc49c doc: add release notes about `getreceivedbylabel` returning an error if the label is not in the address book. (furszy)
8897a21658 rpc: getreceivedbylabel, don't loop over the entire wallet txs map if no destinations were found for the input label. (furszy)

Pull request description:

  Built on top of #23662, coming from comment https://github.com/bitcoin/bitcoin/pull/23662#pullrequestreview-971407999.

  If `wallet.GetLabelAddresses()` returns an empty vector (the wallet does not have stored destinations with that label in the addressbook) or if none of the returned destinations are from the wallet, we can return the function right away.
  Otherwise, we are walking through all the wallet txs + outputs for no reason (`output_scripts` is empty).

ACKs for top commit:
  achow101:
    ACK baa3ddc49c
  theStack:
    re-ACK baa3ddc49c
  w0xlt:
    ACK baa3ddc49c

Tree-SHA512: 00e10365b179bf008da2f3ef8fbb3ee04a330426374020e3f2d0151b16991baba4ef2b944e4659452f3e4d6cb20f128d0918ddf0453933a25a4d9fd8414a1911
2022-05-23 12:15:14 -04:00
furszy
8897a21658
rpc: getreceivedbylabel, don't loop over the entire wallet txs map if no destinations were found for the input label.
If wallet.GetLabelAddresses() returns an empty vector (the wallet does not have addresses with that label in the addressbook) or if none of the returned destinations are from the wallet, we can return the function right away.
2022-05-20 16:32:09 -03:00
MacroFake
a7e3afb221
Merge bitcoin/bitcoin#25171: rpc: wallet: remove -deprecatedrpc=exclude_coinbase logic
a4703ce9d7 doc: add release notes about removal of the `deprecatedrpc=exclude_coinbase` (Sebastian Falbesoner)
ef0aa74836 rpc: wallet: remove `-deprecatedrpc=exclude_coinbase` logic (Sebastian Falbesoner)

Pull request description:

  Including coinbase transactions in `receivedby` RPCs and adding the `-deprecatedrpc=exclude_coinbase` was done in PR #14707 (released in v23.0). For the next release v24.0, this configuration option can be removed.

ACKs for top commit:
  fanquake:
    ACK a4703ce9d7

Tree-SHA512: 97cd4e78501e64f678c78d2ebb5be5376688c023e34fced71dd24e432d27aa31a74b5483545f49ba0bdf48656d8b8b7bee74e3db26cf6daf112613f1caa4dfa4
2022-05-20 08:48:09 +01:00
MacroFake
4a8709821e
Merge bitcoin/bitcoin#24830: init: Allow -proxy="" setting values
1d4122dfef init: Allow -proxy="" setting values (Ryan Ofsky)

Pull request description:

  This drops the `No proxy server specified. Use -proxy=<ip> or -proxy=<ip:port>` error when a empty `-proxy=` command line argument, `bitcoin.conf` value, or `settings.json` value is specified, and just makes bitcoin connect and listen normally in these cases.

  The error was originally added in https://github.com/bitcoin/bitcoin/pull/20003 to prevent a bare `-proxy` command line argument with no assignment from clearing proxy settings. But it was implemented in an overbroad way breaking empty `-proxy=` assignments as well.

  The motivation for this change is to prevent a GUI bug that happens with https://github.com/bitcoin/bitcoin/pull/15936, reported in https://github.com/bitcoin/bitcoin/pull/15936#pullrequestreview-937685759 by vasild, that happens after a proxy setting is enabled and disabled in the GUI. But this change also makes sense on its own to remove a potentially confusing error message.

ACKs for top commit:
  hebasto:
    re-ACK 1d4122dfef, only rebased since my recent [review](https://github.com/bitcoin/bitcoin/pull/24830#pullrequestreview-941255672).

Tree-SHA512: 753adfce199ed078a6cd9e0ea78e76c0b14070f8fcfe2a4632cd0c6dfe6b4e135ddffbe11a97e5e30520ea9e5bda00bad1493cbaef74cf425aa8613249167f53
2022-05-20 08:28:08 +01:00
MacroFake
d433f59f1e
Merge bitcoin/bitcoin#25173: test: add coverage for unknown network in -onlynet
055d94d1ab test: add coverage for unknown network in -onlynet (brunoerg)

Pull request description:

  This PR adds test coverage for the following init error by passing an unknown network in -onlynet
  0de36941ec/src/init.cpp (L1311)

ACKs for top commit:
  MarcoFalke:
    rACK 055d94d1ab

Tree-SHA512: 01bbb297afff371f6345889fa04117ff195b68f0bbf934878ba446049791fdbd7d2ce119ee4f9b3616cc0a81330d7055507dc81151acf68532c077f3575258e9
2022-05-20 08:18:02 +01:00
brunoerg
055d94d1ab test: add coverage for unknown network in -onlynet 2022-05-19 18:39:23 -03:00
Sebastian Falbesoner
1da5e45725 test: use MiniWallet for feature_dbcrash.py
This test can now be run even with the Bitcoin Core wallet disabled.
2022-05-19 17:53:30 +02:00
Sebastian Falbesoner
ef0aa74836 rpc: wallet: remove -deprecatedrpc=exclude_coinbase logic 2022-05-19 16:10:59 +02:00
fanquake
fdb82a30be
Merge bitcoin/bitcoin#25147: Net processing: follow ups to #20799 (removing support for v1 compact blocks)
bf6526f4a0 [test] Remove segwit argument from build_block_on_tip() (John Newbery)
c65bf50b44 Remove fUseWTXID parameter from CBlockHeaderAndShortTxIDs constructor (John Newbery)

Pull request description:

  This implements two of the suggestions from code reviews of PR 20799:

  - Remove fUseWTXID parameter from CBlockHeaderAndShortTxIDs constructor
  - Remove segwit argument from build_block_on_tip()

ACKs for top commit:
  dergoegge:
    Code review ACK bf6526f4a0
  naumenkogs:
    ACK bf6526f4a0

Tree-SHA512: d553791d1364b9e655183755e829b195c9b47f59c62371dbae49d9c0f8d84fec58cf18f4dde89591672ef5658e18c9cf0206c2efd70606980f87e506bc3bd4e5
2022-05-19 09:37:32 +01:00
MacroFake
bb83aba6c9
Merge bitcoin/bitcoin#25161: rpc: Put undocumented JSON failure mode behind a runtime flag
b953ea6cc6 rpc: Put undocumented JSON failure mode behind a runtime flag (Suhail Saqan)

Pull request description:

  Fixes #24695 (Put undocumented JSON failure mode behind a runtime flag)

ACKs for top commit:
  luke-jr:
    utACK b953ea6cc6
  vincenzopalazzo:
    ACK b953ea6cc6

Tree-SHA512: 2005ee1b1f3b637918390b2ecd4166f2fd8c86e3c59fba3da8a0cbd5b1dffd03190c92f6dca3c489ecce4276eaf3108b2edcf9cd6224b713adb52f5bb848163b
2022-05-19 06:44:55 +02:00
Suhail Saqan
b953ea6cc6 rpc: Put undocumented JSON failure mode behind a runtime flag
rpc: Put undocumented JSON failure mode behind a runtime flag
2022-05-18 10:50:59 -07:00
MacroFake
e016c00e98
Merge bitcoin/bitcoin#25126: test: add BIP157 message parsing support (via MESSAGEMAP)
5dc6d92077 test: make BIP157 messages default-constructible (MESSAGEMAP compatibility) (Sebastian Falbesoner)
71e4cfefe7 test: p2p: add missing BIP157 message types to MESSAGEMAP (Sebastian Falbesoner)

Pull request description:

  The script [message-capture-parser.py](https://github.com/bitcoin/bitcoin/blob/master/contrib/message-capture/message-capture-parser.py) currently doesn't support parsing the BIP157 messages `getcfilters`, `getcfheaders` and `getcfcheckpt`, e.g.
  ```
  $ ./contrib/message-capture/message-capture-parser.py msgs_recv.dat
  ...
      WARNING - Unrecognized message type b'getcfcheckpt' in /home/thestack/bitcoin/msgs_recv.dat
  ...
  ```

  This PR fixes this by adding the missing message type mappings to the [`MESSAGEMAP`](225e5b57b2/test/functional/test_framework/p2p.py (L95-L127)) in the test framework and add default-constructors for the corresponding `msg_`... classes.

  Without the second commit, the following error message would occur:
  ```
    File "/home/thestack/bitcoin/./contrib/message-capture/message-capture-parser.py", line 141, in process_file
      msg = MESSAGEMAP[msgtype]()
  TypeError: __init__() missing 2 required positional arguments: 'filter_type' and 'stop_hash'
  ```

ACKs for top commit:
  dunxen:
    tACK [5dc6d92](5dc6d92077)

Tree-SHA512: d656c4d38a856373f01d7c293ae7d2b27378a9fc248048ebf2a64725ef8b498b3ddf4f420704abdb20d0c68ca548f1777602c5e73b66821a20c97ae618f1d63f
2022-05-18 19:08:48 +02:00
MacroFake
139f789d7a
Merge bitcoin/bitcoin#25124: test: Fix intermittent race in p2p_unrequested_blocks.py
faac67cab0 test: Fix intermittent race in p2p_unrequested_blocks.py (MacroFake)

Pull request description:

  Disconnect may also result in an `OSError`, not only an `AssertionError`. Instead of maintaining a dead code path and enumerating disconnect reasons, just assume disconnection happens every time.

ACKs for top commit:
  jamesob:
    Code review ACK faac67cab0

Tree-SHA512: d2cec003168e421a5faed275cb2e1ef9fc63f9e8514f41d21da17e8964c79e5b453ccd72cd7ec62805f45293cf877be5bc8124ae98a515c0aa42d6e053409653
2022-05-18 15:39:20 +02:00
John Newbery
bf6526f4a0 [test] Remove segwit argument from build_block_on_tip()
The only place that segwit=True is for a block that contains only the
coinbase transaction. Since the witness commitment is optional if none
of the transactions have a witness, we can leave it out. This doesn't
change the test coverage, which is testing p2p compact block logic.

Suggested in https://github.com/bitcoin/bitcoin/pull/20799#discussion_r867782119
2022-05-18 13:47:54 +01:00
S3RK
7832e9438f test: fundrawtransaction preset input weight calculation 2022-05-18 08:25:08 +02:00
ishaanam
c6122f560b test: use sendall in wallet_taproot.py tests
Fixes #25129 (subtractfeefromamount=true fails with insufficient
funds)
2022-05-17 13:40:15 -04:00