From 68bd86cd7c686e66d3eae12e17349a0e5ff88504 Mon Sep 17 00:00:00 2001 From: Greg Sanders Date: Wed, 31 Jul 2024 11:04:35 -0400 Subject: [PATCH 1/2] test: P2A is a destination type with an address --- test/functional/rpc_validateaddress.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/functional/rpc_validateaddress.py b/test/functional/rpc_validateaddress.py index dde07e7eadd12..bf094a7df893a 100755 --- a/test/functional/rpc_validateaddress.py +++ b/test/functional/rpc_validateaddress.py @@ -166,6 +166,11 @@ "bc1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vqzk5jj0", "512079be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", ), + # PayToAnchor(P2A) + ( + "bc1pfeessrawgf", + "51024e73", + ), ] From 2a3a24296ec21b4a27a73291fabae3a68974cd1a Mon Sep 17 00:00:00 2001 From: Greg Sanders Date: Wed, 31 Jul 2024 11:21:01 -0400 Subject: [PATCH 2/2] test: check that P2A with witness data is still consensus-legal --- test/functional/mempool_accept.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/test/functional/mempool_accept.py b/test/functional/mempool_accept.py index 4b9ff3d13813f..44a36697c6e68 100755 --- a/test/functional/mempool_accept.py +++ b/test/functional/mempool_accept.py @@ -409,10 +409,19 @@ def run_test(self): maxfeerate=0, ) - # Clear witness stuffing - anchor_spend = anchor_nonempty_wit_spend - anchor_spend.wit.vtxinwit[0].scriptWitness.stack = [] - anchor_spend.rehash() + # but is consensus-legal + self.generateblock(node, self.wallet.get_address(), [anchor_nonempty_wit_spend.serialize().hex()]) + + # Without witness elements it is standard + create_anchor_tx = self.wallet.send_to(from_node=node, scriptPubKey=PAY_TO_ANCHOR, amount=anchor_value) + self.generate(node, 1) + + anchor_spend = CTransaction() + anchor_spend.vin.append(CTxIn(COutPoint(int(create_anchor_tx["txid"], 16), create_anchor_tx["sent_vout"]), b"")) + anchor_spend.vout.append(CTxOut(anchor_value - int(fee*COIN), script_to_p2wsh_script(CScript([OP_TRUE])))) + anchor_spend.wit.vtxinwit.append(CTxInWitness()) + # It's "segwit" but txid == wtxid since there is no witness data + assert_equal(anchor_spend.rehash(), anchor_spend.getwtxid()) self.check_mempool_result( result_expected=[{'txid': anchor_spend.rehash(), 'allowed': True, 'vsize': anchor_spend.get_vsize(), 'fees': { 'base': Decimal('0.00000700')}}],