diff options
author | MarcoFalke <falke.marco@gmail.com> | 2019-11-21 10:11:02 -0500 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2019-11-21 10:11:06 -0500 |
commit | 5ff798c39b8a72d64bd2c23f400d1c35ca27a1ed (patch) | |
tree | 8eb1961757a281d339ac4563b85817c92ca65bf3 | |
parent | b7bc9b8330096d1f4f1fa563b855b88da425226e (diff) | |
parent | cb9d830a00995ee60e71780c04f6193efd02c511 (diff) |
Merge #17439: refactor: Use proper MAX_SCRIPT_ELEMENT_SIZE constants consistently
cb9d830a00995ee60e71780c04f6193efd02c511 test: Use proper MAX_SCRIPT_ELEMENT_SIZE (Hennadii Stepanov)
402ee706d8afab3d8d883cd15a660740fcebeb55 refactor: Use proper MAX_SCRIPT_ELEMENT_SIZE const (Hennadii Stepanov)
Pull request description:
This PR replaces well-known "magic" numbers with proper `MAX_SCRIPT_ELEMENT_SIZE` constants.
ACKs for top commit:
practicalswift:
ACK cb9d830a00995ee60e71780c04f6193efd02c511 -- diff looks correct and change appears to be complete
instagibbs:
utACK https://github.com/bitcoin/bitcoin/pull/17439/commits/cb9d830a00995ee60e71780c04f6193efd02c511
Tree-SHA512: 5fa033275d6df7e35962c38bfdf09a7b5cd7ef2ccdd5e30a39ba47d0c21ac779a5559c23f5ef5bfd4293be0fc639e836a308bbedf0e34717e1eead983b389bbd
-rw-r--r-- | src/script/descriptor.cpp | 4 | ||||
-rwxr-xr-x | test/functional/p2p_segwit.py | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/script/descriptor.cpp b/src/script/descriptor.cpp index 13cdd6c61a..32b388b7fa 100644 --- a/src/script/descriptor.cpp +++ b/src/script/descriptor.cpp @@ -815,8 +815,8 @@ std::unique_ptr<DescriptorImpl> ParseScript(Span<const char>& sp, ParseScriptCon } } if (ctx == ParseScriptContext::P2SH) { - if (script_size + 3 > 520) { - error = strprintf("P2SH script is too large, %d bytes is larger than 520 bytes", script_size + 3); + if (script_size + 3 > MAX_SCRIPT_ELEMENT_SIZE) { + error = strprintf("P2SH script is too large, %d bytes is larger than %d bytes", script_size + 3, MAX_SCRIPT_ELEMENT_SIZE); return nullptr; } } diff --git a/test/functional/p2p_segwit.py b/test/functional/p2p_segwit.py index 0c7edbf434..fdb70097ee 100755 --- a/test/functional/p2p_segwit.py +++ b/test/functional/p2p_segwit.py @@ -1116,7 +1116,7 @@ class SegWitTest(BitcoinTestFramework): MAX_PROGRAM_LENGTH = 10000 # This program is 19 max pushes (9937 bytes), then 64 more opcode-bytes. - long_witness_program = CScript([b'a' * 520] * 19 + [OP_DROP] * 63 + [OP_TRUE]) + long_witness_program = CScript([b'a' * MAX_SCRIPT_ELEMENT_SIZE] * 19 + [OP_DROP] * 63 + [OP_TRUE]) assert len(long_witness_program) == MAX_PROGRAM_LENGTH + 1 long_witness_hash = sha256(long_witness_program) long_script_pubkey = CScript([OP_0, long_witness_hash]) @@ -1140,7 +1140,7 @@ class SegWitTest(BitcoinTestFramework): test_witness_block(self.nodes[0], self.test_node, block, accepted=False) # Try again with one less byte in the witness program - witness_program = CScript([b'a' * 520] * 19 + [OP_DROP] * 62 + [OP_TRUE]) + witness_program = CScript([b'a' * MAX_SCRIPT_ELEMENT_SIZE] * 19 + [OP_DROP] * 62 + [OP_TRUE]) assert len(witness_program) == MAX_PROGRAM_LENGTH witness_hash = sha256(witness_program) script_pubkey = CScript([OP_0, witness_hash]) |