Commit graph

103 commits

Author SHA1 Message Date
Ava Chow
4b301666ff Merge bitcoin/bitcoin#33050: net, validation: don't punish peers for consensus-invalid txs
876dbdfb4702410dfd4037614dc9298a0c09c63e tests: drop expect_disconnect behaviour for tx relay (Anthony Towns)
b29ae9efdfeeff774e32ee433ce67d8ed8ecd49f validation: only check input scripts once (Anthony Towns)
266dd0e10d08c0bfde63205db15d6c210a021b90 net_processing: drop MaybePunishNodeForTx (Anthony Towns)

Pull request description:

  Because we do not discourage nodes for transactions we consider non-standard, we don't get any DoS protection from this check in adversarial scenarios, so remove the check entirely both to simplify the code and reduce the risk of splitting the network due to changes in tx relay policy.

  Then, because we no longer make use of the distinction between consensus and standardness failures during script validation, don't re-validate each script with only-consensus rules, reducing the cost to us of transactions that we won't relay.

ACKs for top commit:
  achow101:
    ACK 876dbdfb4702410dfd4037614dc9298a0c09c63e
  darosior:
    re-ACK 876dbdfb4702410dfd4037614dc9298a0c09c63e
  sipa:
    re-ACK 876dbdfb4702410dfd4037614dc9298a0c09c63e
  glozow:
    ACK 876dbdfb4702410dfd4037614dc9298a0c09c63e

Tree-SHA512: 8bb0395766dde54fc48f7077b80b88e35581aa6e3054d6d65735965147abefffa7348f0850bb3d46f6c2541fd384ecd40a00a57fa653adabff8a35582e2d1811
2025-11-26 10:22:33 +00:00
James Dorfman
dabea18f29
rpc: fix bug in 'utxo_size_inc' calculation 2023-09-13 09:27:52 +02:00
Byron Hambly
62697be8d9 Merge 3d223712d3 into merged_master (Bitcoin PR bitcoin/bitcoin#16795) 2023-06-28 16:32:17 +00:00
Byron Hambly
c53eb39edf Merge 807169e10b into merged_master (Bitcoin PR bitcoin/bitcoin#24035) 2023-06-20 09:57:58 +00:00
James Dorfman
b0afaee332 Merge eb63b8fab9 into merged_master (Bitcoin PR bitcoin/bitcoin#23718) 2023-06-13 05:47:02 +00:00
Byron Hambly
207616f18e Merge 695ba2fe54 into merged_master (Bitcoin PR bitcoin/bitcoin#23486)
Added the additional elements output types of "true" and "fee" to the
decodescript lambdas, we should confirm that this is correct for the fee
outputs. ie. that it is acceptable to permit fee outputs to be wrapped
2023-06-02 10:09:13 +00:00
Byron Hambly
e129d42b92 Merge d20d6ac545 into merged_master (Bitcoin PR bitcoin/bitcoin#23672)
Updated the addresses and scripts in rpc_decodescript.json to work with
elements
2023-06-02 08:14:30 +00:00
Byron Hambly
bd68371fb6 Merge ffdab41f94 into merged_master (Bitcoin PR bitcoin/bitcoin#23474) 2023-05-26 10:32:04 +00:00
Byron Hambly
31bb8332bc Merge 3bf40d06a2 into merged_master (Bitcoin PR bitcoin/bitcoin#23212) 2023-05-11 13:15:28 +00:00
Gregory Sanders
6498ba151b transaction decoding infer output descriptors 2022-01-26 09:56:51 +08:00
Sebastian Falbesoner
2f79786822 test: refactor: add constant for sequence number SEQUENCE_FINAL 2022-01-11 15:28:28 +01:00
Antoine Poinsot
a9256dc340
rpc: output all hash preimages in 'decodepsbt' 2021-12-11 18:32:17 +01:00
Andrew Chow
d8043ddf64 Add global xpub test vectors from BIP 2021-12-10 08:29:47 -05:00
Andrew Chow
94065cc6c5 Test for proprietary field 2021-12-10 08:29:47 -05:00
Andrew Chow
c3eb416b88 Implement PSBT versions 2021-12-10 08:29:26 -05:00
MarcoFalke
99993425af
rpc: Only allow specific types to be P2(W)SH wrapped in decodescript 2021-12-06 10:33:12 +01:00
Dimitri
b35942e500 tests: Add data-driven testcases to rpc_decodescript.py 2021-12-05 22:07:04 +01:00
MarcoFalke
fac23c2114
scripted-diff: Bump copyright headers
The previous diff touched most files in ./test/, so bump the headers to
avoid having to touch them again for a bump later.

-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./test/
-END VERIFY SCRIPT-
2021-11-10 11:10:24 +01:00
josibake
a46f71bb70
lint: enable mypy checking for missing imports
Achieve this by adding some ignore, and making data/ importable.

Co-authored-by: João Barbosa <joao.paulo.barbosa@gmail.com>
2021-10-16 09:14:37 +08:00
Andrew Poelstra
242586cea6 lint: fix pylint issues 2021-10-15 00:20:23 +00:00
Andrew Poelstra
ba8273ac94 lint: fix non-pylint linter errors
Includes fixing all the spelling mistakes that are our fault,
but not those present upstream in Core.
2021-10-15 00:20:20 +00:00
Andrew Poelstra
36e5e2a7f1 Merge 9a154599fe into merged_master (Elements PR ElementsProject/elements#900)
Surprisingly easy to do. Almost all of the diff resolution was mechanically
  * replacing boost::variant with std::variant
  * replacing Optional with std::optional
     * then replacing `nullopt` with `std::nullopt`
  * updating the RPC functions for the new RPCArg::Default type
  * update the tests/ directory to make new (since 22) tests use arrays for
    createrawtransaction outputs
  * other ad-hoc changes to function parameters etc (not too many of these)

I had to "really" change the code in PrecomputePSBTData, which was introduced
in 22.0 and affected by PSET, but this function was like 8 lines long so it
was easy.

Reviewing the diff may be a bit difficult because of the mix of mechanical
changes and ad-hoc things. Probably the most straightforward thing to do
is to redo the merge, `sed -i` to fix the boost::variant and Optional stuff,
then diff the remaining conflicts against this commit.

TODO: grep for `blindpsbt` and you will see that this RPC is still referenced
in documentation and help text even though it was deleted. Need to fix this
in 0.21 in a separate PR.
2021-09-04 19:34:14 +00:00
Andrew Poelstra
2e6ff43f2d Merge d1e4c56309 into merged_master (Bitcoin PR bitcoin/bitcoin#22363) 2021-07-31 15:28:34 +00:00
Andrew Poelstra
cf9d252d10 Merge df2b5dadfb into merged_master (Bitcoin PR bitcoin/bitcoin#22408) 2021-07-31 03:33:34 +00:00
MarcoFalke
d1e4c56309
Merge bitcoin/bitcoin#22363: test: refactor: use script_util helpers for creating P2{PKH,SH,WPKH,WSH} scripts
905d672b74 test: use script_util helpers for creating P2W{PKH,SH} scripts (Sebastian Falbesoner)
285a65ccfd test: use script_util helpers for creating P2SH scripts (Sebastian Falbesoner)
b57b633b94 test: use script_util helpers for creating P2PKH scripts (Sebastian Falbesoner)
61b6a017a9 test: wallet util: fix multisig P2SH-P2WSH script creation (Sebastian Falbesoner)

Pull request description:

  PR #18788 (commit 08067aebfd) introduced functions to generate output scripts for various types. This PR replaces all manual CScript creations in the P2PKH, P2SH, P2WPKH, P2WSH formats with those helpers in order to increase readability and maintainability over the functional test codebase. The first commit fixes a bug in the wallet_util helper module w.r.t. to P2SH-P2WSH script creation (the result is not used in any test so far, hence it can still be seen as refactoring).

  The following table shows a summary of the output script patterns tackled in this PR:

  | Type | master branch  | PR branch |
  | ---------- | ------------- | ------------- |
  | P2PKH | `CScript([OP_DUP, OP_HASH160, hash160(key), OP_EQUALVERIFY, OP_CHECKSIG])` | `key_to_p2pkh_script(key)`  |
  |             | `CScript([OP_DUP, OP_HASH160, keyhash, OP_EQUALVERIFY, OP_CHECKSIG])` | `keyhash_to_p2pkh_script(keyhash)` |
  | P2SH  | `CScript([OP_HASH160, hash160(script), OP_EQUAL])`  | `script_to_p2sh_script(script)` |
  | P2WPKH | `CScript([OP_0, hash160(key)])` | `key_to_p2wpkh_script(key)` |
  | P2WSH | `CScript([OP_0, sha256(script)])` | `script_to_p2wsh_script(script)` |

  Note that the `key_to_...` helpers can't be used if an invalid key size (not 33 or 65 bytes) is passed, which is the case in some rare instances where the scripts still have to be created manually.

  Possible follow-up ideas:
  * further simplify by identifying P2SH-wrapped scripts and using `key_to_p2sh_p2wpkh_script()` and `script_to_p2sh_p2wsh_script()` helpers
  * introduce and use `key_to_p2pk_script()` helper for P2PK scripts

ACKs for top commit:
  rajarshimaitra:
    tACK https://github.com/bitcoin/bitcoin/pull/22363/commits/905d672b743edf31531d095ffe800449eaffec69
  LarryRuane:
    tACK 905d672b74
  0xB10C:
    ACK 905d672b74
  MarcoFalke:
    review ACK 905d672b74 🕹

Tree-SHA512: 7ccfe69699bc81168ac122b03536720013355c1b2fbb088355b616015318644c4d1cd27e20c4f56c89ad083ae609add4bc838cf6316794d0edb0ce9cf7fa0fd8
2021-07-09 11:17:58 +02:00
Sebastian Falbesoner
aa0a5bb70d test: add bad-txns-prevout-null test case to invalid_txs.py
This reject reason is triggered for non-coinbase transactions with
a coinbase-like outpoint, i.e. hash=0, n=0xffffffff.

Note that the invalid tx templates are currently used in the
functional tests feature_block.py and p2p_invalid_tx.py.
2021-07-05 23:00:41 +02:00
Sebastian Falbesoner
285a65ccfd test: use script_util helpers for creating P2SH scripts 2021-07-05 20:40:47 +02:00
Andrew Chow
0ca0b7e040 Update rpc_psbt.py to test PSBTv0 explicitly in some places 2021-06-22 13:54:50 -04:00
Andrew Chow
8c624438ca Change PSBT unknown fields test to use higher numbers
Previously these tests were using 0x0f as the field number. Changed to
use 0xf0 instead as it is unlikely we will hit that anytime soon.
2021-06-22 13:54:50 -04:00
Andrew Chow
bc2651d200 Add global xpub test vectors from BIP 2021-06-22 13:54:50 -04:00
Andrew Poelstra
323f9bf6cd Merge b401b09355 into merged_master (Bitcoin PR #21107) 2021-06-21 08:23:27 +00:00
Andrew Chow
31a7e0a744 Test for proprietary field 2021-06-03 15:44:20 -04:00
Andrew Chow
50c281fc12 Implement PSBT versions 2021-06-03 15:44:19 -04:00
Andrew Poelstra
68bfd70b43 ci: various linter / CI compiler error fixes
Includes changing TRUE to OP_TRUE for anyone-can-spend output name,
to avoid symbol conflict on win64 builds, which is really obnoxious.
2021-03-26 17:33:04 +00:00
fanquake
9913419cc9
test: remove type: comments in favour of actual annotations
Now that we require Python 3.6+, we should be using variable type
annotations directly rather than # type: comments.

Also takes care of the discarded value issue in p2p_message_capture.py.
See: https://github.com/bitcoin/bitcoin/pull/19509/files#r571674446.
2021-02-08 13:24:44 +08:00
Andrew Poelstra
29c7f63764 Merge c48e788246 into merged_master (Bitcoin PR #18836) 2020-12-02 15:51:02 +00:00
Andrew Poelstra
67f55c5173 Merge 234fabab90 into merged_master (Bitcoin PR #18210) 2020-11-26 01:08:57 +00:00
Andrew Poelstra
fd37b7c5d6 Merge 54f812d9d2 into merged_master (Bitcoin PR #18673) 2020-11-26 01:08:23 +00:00
Andrew Poelstra
7bc1e4d084 Merge 24a727e23e into merged_master (Bitcoin PR #18255) 2020-11-26 01:07:53 +00:00
Andrew Poelstra
009bc2fdfb Merge 99813a9745 into merged_master (Bitcoin PR #17829) 2020-11-14 16:52:02 +00:00
Andrew Poelstra
3dbd855a2d Merge b1de33d29a into merged_master (Bitcoin PR #16821) 2020-11-09 21:20:35 +00:00
Andrew Poelstra
382e167ab3 Merge 520d140e6e into merged_master (Bitcoin PR #17056)
Recreated addresses for functional tests using `hal elements address create --script`
with the given script from data/rpc_bip67.json, taking the P2SH output
2020-11-09 21:20:35 +00:00
Andrew Poelstra
084729aa3d Merge 9bf5768dd6 into merged_master (Bitcoin PR #16885) 2020-11-09 21:20:27 +00:00
Andrew Poelstra
ca7b7f3810 Merge feb162d500 into merged_master (Bitcoin PR #14696) 2020-11-09 21:20:26 +00:00
Andrew Poelstra
d3c16a64a8 Merge 796b713633 into merged_master (Bitcoin PR #16845) 2020-11-09 21:20:25 +00:00
Andrew Poelstra
e413b2ebbb Merge ca97d292ce into merged_master (Bitcoin PR #16551) 2020-11-09 21:20:24 +00:00
Andrew Poelstra
8fa52e84b0 Merge 8af835a72d into merged_master (Bitcoin PR #16796) 2020-11-09 21:20:23 +00:00
MarcoFalke
a314271f08 test: Remove unused wallet.dat 2020-11-04 12:16:57 -05:00
Andrew Poelstra
2d57dcb681 Merge d7d7d31506 into merged_master (Bitcoin PR #15141) 2020-10-29 02:10:39 +00:00
Andrew Poelstra
83a6652c4d Merge 653b2b4426 into merged_master (Bitcoin PR #15893) 2020-10-28 22:34:13 +00:00