Skip to content

Commit

Permalink
test addition of unknown segwit spends to txid reject filter
Browse files Browse the repository at this point in the history
Github-Pull: bitcoin#19620
Rebased-From: 9f88ded
  • Loading branch information
instagibbs authored and Bushstar committed Oct 21, 2020
1 parent 211f854 commit 08e3601
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions test/functional/p2p_segwit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1393,16 +1393,24 @@ def test_segwit_versions(self):
temp_utxo.pop() # last entry in temp_utxo was the output we just spent
temp_utxo.append(UTXO(tx2.sha256, 0, tx2.vout[0].nValue))

# Spend everything in temp_utxo back to an OP_TRUE output.
# Spend everything in temp_utxo into an segwit v1 output.
tx3 = CTransaction()
total_value = 0
for i in temp_utxo:
tx3.vin.append(CTxIn(COutPoint(i.sha256, i.n), b""))
tx3.wit.vtxinwit.append(CTxInWitness())
total_value += i.nValue
tx3.wit.vtxinwit[-1].scriptWitness.stack = [witness_program]
tx3.vout.append(CTxOut(total_value - 1000, CScript([OP_TRUE])))
tx3.vout.append(CTxOut(total_value - 1000, script_pubkey))
tx3.rehash()

# First we test this transaction against fRequireStandard=true node
# making sure the txid is added to the reject filter
self.std_node.announce_tx_and_wait_for_getdata(tx3)
test_transaction_acceptance(self.nodes[1], self.std_node, tx3, with_witness=True, accepted=False, reason="bad-txns-nonstandard-inputs")
# 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, timeout=5, success=False)

# Spending a higher version witness output is not allowed by policy,
# even with fRequireStandard=false.
test_transaction_acceptance(self.nodes[0], self.test_node, tx3, with_witness=True, accepted=False, reason="reserved for soft-fork upgrades")
Expand Down

0 comments on commit 08e3601

Please sign in to comment.