Merge bitcoin/bitcoin#30562: PayToAnchor(P2A) followups

2a3a24296e test: check that P2A with witness data is still consensus-legal (Greg Sanders)
68bd86cd7c test: P2A is a destination type with an address (Greg Sanders)

Pull request description:

  Followups for https://github.com/bitcoin/bitcoin/pull/30352

  Suggestions taken:
  https://github.com/bitcoin/bitcoin/pull/30352#discussion_r1698542647
  https://github.com/bitcoin/bitcoin/pull/30352#discussion_r1698563426

ACKs for top commit:
  tdb3:
    ACK 2a3a24296e
  glozow:
    ACK 2a3a24296e
  theStack:
    ACK 2a3a24296e

Tree-SHA512: 5de865b2c300fa504dbdbd5879649a6fc328da052ad8bf9479e3fea0c49c516d824908a87523ec1fb30cc536bffe2e116dd523a9b66a07f81f93429e42879f14
This commit is contained in:
merge-script 2024-08-05 13:27:36 +01:00
commit 1afa3c84fc
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1
2 changed files with 18 additions and 4 deletions

View file

@ -409,10 +409,19 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
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')}}],

View file

@ -166,6 +166,11 @@ VALID_DATA = [
"bc1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vqzk5jj0",
"512079be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
),
# PayToAnchor(P2A)
(
"bc1pfeessrawgf",
"51024e73",
),
]