@@ -584,6 +584,29 @@ def run_test(self):
584
584
self .nodes [0 ].importprivkey ("cTW5mR5M45vHxXkeChZdtSPozrFwFgmEvTNnanCW6wrqwaCZ1X7K" )
585
585
self .create_and_mine_tx_from_txids (solvable_txid )
586
586
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
+
587
610
def mine_and_test_listunspent (self , script_list , ismine ):
588
611
utxo = find_unspent (self .nodes [0 ], 50 )
589
612
tx = CTransaction ()
0 commit comments