Skip to content

Commit 06eaca6

Browse files
NicolasDoriersipa
authored andcommitted
[RPC] Wallet: test importing of native witness scripts
Integration into segwit.py test by Pieter Wuille.
1 parent fd0041a commit 06eaca6

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/functional/segwit.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,29 @@ def run_test(self):
584584
self.nodes[0].importprivkey("cTW5mR5M45vHxXkeChZdtSPozrFwFgmEvTNnanCW6wrqwaCZ1X7K")
585585
self.create_and_mine_tx_from_txids(solvable_txid)
586586

587+
# Test that importing native P2WPKH/P2WSH scripts works
588+
for use_p2wsh in [False, True]:
589+
if use_p2wsh:
590+
scriptPubKey = "00203a59f3f56b713fdcf5d1a57357f02c44342cbf306ffe0c4741046837bf90561a"
591+
transaction = "01000000000100e1f505000000002200203a59f3f56b713fdcf5d1a57357f02c44342cbf306ffe0c4741046837bf90561a00000000"
592+
else:
593+
scriptPubKey = "a9142f8c469c2f0084c48e11f998ffbe7efa7549f26d87"
594+
transaction = "01000000000100e1f5050000000017a9142f8c469c2f0084c48e11f998ffbe7efa7549f26d8700000000"
595+
596+
self.nodes[1].importaddress(scriptPubKey, "", False)
597+
rawtxfund = self.nodes[1].fundrawtransaction(transaction)['hex']
598+
rawtxfund = self.nodes[1].signrawtransaction(rawtxfund)["hex"]
599+
txid = self.nodes[1].sendrawtransaction(rawtxfund)
600+
601+
assert_equal(self.nodes[1].gettransaction(txid, True)["txid"], txid)
602+
assert_equal(self.nodes[1].listtransactions("*", 1, 0, True)[0]["txid"], txid)
603+
604+
# Assert it is properly saved
605+
self.stop_node(1)
606+
self.start_node(1)
607+
assert_equal(self.nodes[1].gettransaction(txid, True)["txid"], txid)
608+
assert_equal(self.nodes[1].listtransactions("*", 1, 0, True)[0]["txid"], txid)
609+
587610
def mine_and_test_listunspent(self, script_list, ismine):
588611
utxo = find_unspent(self.nodes[0], 50)
589612
tx = CTransaction()

0 commit comments

Comments
 (0)