mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
Merge 69416ee29e
into c5e44a0435
This commit is contained in:
commit
c7d46f2418
2 changed files with 15 additions and 13 deletions
|
@ -1230,8 +1230,7 @@ bool MemPoolAccept::PolicyScriptChecks(const ATMPArgs& args, Workspace& ws)
|
||||||
AssertLockHeld(m_pool.cs);
|
AssertLockHeld(m_pool.cs);
|
||||||
const CTransaction& tx = *ws.m_ptx;
|
const CTransaction& tx = *ws.m_ptx;
|
||||||
TxValidationState& state = ws.m_state;
|
TxValidationState& state = ws.m_state;
|
||||||
|
const unsigned int scriptVerifyFlags = (m_pool.m_opts.require_standard ? STANDARD_SCRIPT_VERIFY_FLAGS : MANDATORY_SCRIPT_VERIFY_FLAGS);
|
||||||
constexpr unsigned int scriptVerifyFlags = STANDARD_SCRIPT_VERIFY_FLAGS;
|
|
||||||
|
|
||||||
// Check input scripts and signatures.
|
// Check input scripts and signatures.
|
||||||
// This is done last to help prevent CPU exhaustion denial-of-service attacks.
|
// This is done last to help prevent CPU exhaustion denial-of-service attacks.
|
||||||
|
@ -2396,6 +2395,10 @@ static unsigned int GetBlockScriptFlags(const CBlockIndex& block_index, const Ch
|
||||||
{
|
{
|
||||||
const Consensus::Params& consensusparams = chainman.GetConsensus();
|
const Consensus::Params& consensusparams = chainman.GetConsensus();
|
||||||
|
|
||||||
|
// Note that any flags returned from this function (ie, specified
|
||||||
|
// here or in script_flag_exceptions) must also be included in
|
||||||
|
// MANDATORY_SCRIPT_VERIFY_FLAGS in policy/policy.h
|
||||||
|
|
||||||
// BIP16 didn't become active until Apr 1 2012 (on mainnet, and
|
// BIP16 didn't become active until Apr 1 2012 (on mainnet, and
|
||||||
// retroactively applied to testnet)
|
// retroactively applied to testnet)
|
||||||
// However, only one historical block violated the P2SH rules (on both
|
// However, only one historical block violated the P2SH rules (on both
|
||||||
|
|
|
@ -1389,14 +1389,13 @@ class SegWitTest(BitcoinTestFramework):
|
||||||
# Now the node will no longer ask for getdata of this transaction when advertised by same txid
|
# Now the node will no longer ask for getdata of this transaction when advertised by same txid
|
||||||
self.std_node.announce_tx_and_wait_for_getdata(tx3, success=False)
|
self.std_node.announce_tx_and_wait_for_getdata(tx3, success=False)
|
||||||
|
|
||||||
# Spending a higher version witness output is not allowed by policy,
|
# Spending a higher version witness output is allowed on the node with -acceptnonstdtxn
|
||||||
# even with the node that accepts non-standard txs.
|
test_transaction_acceptance(self.nodes[0], self.test_node, tx3, with_witness=True, accepted=True)
|
||||||
test_transaction_acceptance(self.nodes[0], self.test_node, tx3, with_witness=True, accepted=False, reason="reserved for soft-fork upgrades")
|
|
||||||
|
|
||||||
# Building a block with the transaction must be valid, however.
|
# Building a block with the transaction must be valid, however even without -acceptnonstdtxn.
|
||||||
block = self.build_next_block()
|
block = self.build_next_block()
|
||||||
self.update_witness_block_with_transactions(block, [tx2, tx3])
|
self.update_witness_block_with_transactions(block, [tx2, tx3])
|
||||||
test_witness_block(self.nodes[0], self.test_node, block, accepted=True)
|
test_witness_block(self.nodes[1], self.std_node, block, accepted=True)
|
||||||
self.sync_blocks()
|
self.sync_blocks()
|
||||||
|
|
||||||
# Add utxo to our list
|
# Add utxo to our list
|
||||||
|
@ -1477,11 +1476,11 @@ class SegWitTest(BitcoinTestFramework):
|
||||||
sign_input_segwitv0(tx2, 0, script, tx.vout[0].nValue, key)
|
sign_input_segwitv0(tx2, 0, script, tx.vout[0].nValue, key)
|
||||||
|
|
||||||
# Should fail policy test.
|
# Should fail policy test.
|
||||||
test_transaction_acceptance(self.nodes[0], self.test_node, tx2, True, False, 'non-mandatory-script-verify-flag (Using non-compressed keys in segwit)')
|
test_transaction_acceptance(self.nodes[1], self.std_node, tx2, True, False, 'non-mandatory-script-verify-flag (Using non-compressed keys in segwit)')
|
||||||
# But passes consensus.
|
# But passes consensus.
|
||||||
block = self.build_next_block()
|
block = self.build_next_block()
|
||||||
self.update_witness_block_with_transactions(block, [tx2])
|
self.update_witness_block_with_transactions(block, [tx2])
|
||||||
test_witness_block(self.nodes[0], self.test_node, block, accepted=True)
|
test_witness_block(self.nodes[1], self.std_node, block, accepted=True)
|
||||||
|
|
||||||
# Test 2: P2WSH
|
# Test 2: P2WSH
|
||||||
# Try to spend the P2WSH output created in last test.
|
# Try to spend the P2WSH output created in last test.
|
||||||
|
@ -1496,11 +1495,11 @@ class SegWitTest(BitcoinTestFramework):
|
||||||
sign_p2pk_witness_input(witness_script, tx3, 0, SIGHASH_ALL, tx2.vout[0].nValue, key)
|
sign_p2pk_witness_input(witness_script, tx3, 0, SIGHASH_ALL, tx2.vout[0].nValue, key)
|
||||||
|
|
||||||
# Should fail policy test.
|
# Should fail policy test.
|
||||||
test_transaction_acceptance(self.nodes[0], self.test_node, tx3, True, False, 'non-mandatory-script-verify-flag (Using non-compressed keys in segwit)')
|
test_transaction_acceptance(self.nodes[1], self.std_node, tx3, True, False, 'non-mandatory-script-verify-flag (Using non-compressed keys in segwit)')
|
||||||
# But passes consensus.
|
# But passes consensus.
|
||||||
block = self.build_next_block()
|
block = self.build_next_block()
|
||||||
self.update_witness_block_with_transactions(block, [tx3])
|
self.update_witness_block_with_transactions(block, [tx3])
|
||||||
test_witness_block(self.nodes[0], self.test_node, block, accepted=True)
|
test_witness_block(self.nodes[1], self.std_node, block, accepted=True)
|
||||||
|
|
||||||
# Test 3: P2SH(P2WSH)
|
# Test 3: P2SH(P2WSH)
|
||||||
# Try to spend the P2SH output created in the last test.
|
# Try to spend the P2SH output created in the last test.
|
||||||
|
@ -1513,10 +1512,10 @@ class SegWitTest(BitcoinTestFramework):
|
||||||
sign_p2pk_witness_input(witness_script, tx4, 0, SIGHASH_ALL, tx3.vout[0].nValue, key)
|
sign_p2pk_witness_input(witness_script, tx4, 0, SIGHASH_ALL, tx3.vout[0].nValue, key)
|
||||||
|
|
||||||
# Should fail policy test.
|
# Should fail policy test.
|
||||||
test_transaction_acceptance(self.nodes[0], self.test_node, tx4, True, False, 'non-mandatory-script-verify-flag (Using non-compressed keys in segwit)')
|
test_transaction_acceptance(self.nodes[1], self.std_node, tx4, True, False, 'non-mandatory-script-verify-flag (Using non-compressed keys in segwit)')
|
||||||
block = self.build_next_block()
|
block = self.build_next_block()
|
||||||
self.update_witness_block_with_transactions(block, [tx4])
|
self.update_witness_block_with_transactions(block, [tx4])
|
||||||
test_witness_block(self.nodes[0], self.test_node, block, accepted=True)
|
test_witness_block(self.nodes[1], self.std_node, block, accepted=True)
|
||||||
|
|
||||||
# Test 4: Uncompressed pubkeys should still be valid in non-segwit
|
# Test 4: Uncompressed pubkeys should still be valid in non-segwit
|
||||||
# transactions.
|
# transactions.
|
||||||
|
|
Loading…
Add table
Reference in a new issue