Skip to content

Commit 34645c4

Browse files
committed
Test txinwitness is accessible on coinbase vin
1 parent 3e44210 commit 34645c4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test/functional/feature_segwit.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from test_framework.test_framework import BitcoinTestFramework
2121
from test_framework.util import (
2222
assert_equal,
23+
assert_is_hex_string,
2324
assert_raises_rpc_error,
2425
connect_nodes,
2526
hex_str_to_bytes,
@@ -193,6 +194,14 @@ def run_test(self):
193194
assert self.nodes[1].getrawtransaction(tx_id, False, blockhash) == self.nodes[2].gettransaction(tx_id)["hex"]
194195
assert self.nodes[0].getrawtransaction(tx_id, False, blockhash) == tx.serialize_without_witness().hex()
195196

197+
# Coinbase contains the witness commitment nonce, check that RPC shows us
198+
coinbase_txid = self.nodes[2].getblock(blockhash)['tx'][0]
199+
coinbase_tx = self.nodes[2].gettransaction(txid=coinbase_txid, verbose=True)
200+
witnesses = coinbase_tx["decoded"]["vin"][0]["txinwitness"]
201+
assert_equal(len(witnesses), 1)
202+
assert_is_hex_string(witnesses[0])
203+
assert_equal(witnesses[0], '00'*32)
204+
196205
self.log.info("Verify witness txs without witness data are invalid after the fork")
197206
self.fail_accept(self.nodes[2], 'non-mandatory-script-verify-flag (Witness program hash mismatch)', wit_ids[NODE_2][P2WPKH][2], sign=False)
198207
self.fail_accept(self.nodes[2], 'non-mandatory-script-verify-flag (Witness program was passed an empty witness)', wit_ids[NODE_2][P2WSH][2], sign=False)

0 commit comments

Comments
 (0)