27
27
PSBT_IN_SHA256 ,
28
28
PSBT_IN_HASH160 ,
29
29
PSBT_IN_HASH256 ,
30
+ PSBT_OUT_TAP_TREE ,
30
31
)
31
32
from test_framework .test_framework import BitcoinTestFramework
32
33
from test_framework .util import (
@@ -779,9 +780,18 @@ def test_psbt_input_keys(psbt_input, keys):
779
780
self .generate (self .nodes [0 ], 1 )
780
781
self .nodes [0 ].importdescriptors ([{"desc" : descsum_create ("tr({})" .format (privkey )), "timestamp" :"now" }])
781
782
782
- psbt = watchonly .sendall ([wallet .getnewaddress ()])["psbt" ]
783
+ psbt = watchonly .sendall ([wallet .getnewaddress (), addr ])["psbt" ]
783
784
psbt = self .nodes [0 ].walletprocesspsbt (psbt )["psbt" ]
784
- self .nodes [0 ].sendrawtransaction (self .nodes [0 ].finalizepsbt (psbt )["hex" ])
785
+ txid = self .nodes [0 ].sendrawtransaction (self .nodes [0 ].finalizepsbt (psbt )["hex" ])
786
+ vout = find_vout_for_address (self .nodes [0 ], txid , addr )
787
+
788
+ # Make sure tap tree is in psbt
789
+ parsed_psbt = PSBT .from_base64 (psbt )
790
+ assert_greater_than (len (parsed_psbt .o [vout ].map [PSBT_OUT_TAP_TREE ]), 0 )
791
+ assert "taproot_tree" in self .nodes [0 ].decodepsbt (psbt )["outputs" ][vout ]
792
+ parsed_psbt .make_blank ()
793
+ comb_psbt = self .nodes [0 ].combinepsbt ([psbt , parsed_psbt .to_base64 ()])
794
+ assert_equal (comb_psbt , psbt )
785
795
786
796
self .log .info ("Test that walletprocesspsbt both updates and signs a non-updated psbt containing Taproot inputs" )
787
797
addr = self .nodes [0 ].getnewaddress ("" , "bech32m" )
@@ -793,6 +803,14 @@ def test_psbt_input_keys(psbt_input, keys):
793
803
self .nodes [0 ].sendrawtransaction (rawtx )
794
804
self .generate (self .nodes [0 ], 1 )
795
805
806
+ # Make sure tap tree is not in psbt
807
+ parsed_psbt = PSBT .from_base64 (psbt )
808
+ assert PSBT_OUT_TAP_TREE not in parsed_psbt .o [0 ].map
809
+ assert "taproot_tree" not in self .nodes [0 ].decodepsbt (psbt )["outputs" ][0 ]
810
+ parsed_psbt .make_blank ()
811
+ comb_psbt = self .nodes [0 ].combinepsbt ([psbt , parsed_psbt .to_base64 ()])
812
+ assert_equal (comb_psbt , psbt )
813
+
796
814
self .log .info ("Test decoding PSBT with per-input preimage types" )
797
815
# note that the decodepsbt RPC doesn't check whether preimages and hashes match
798
816
hash_ripemd160 , preimage_ripemd160 = random_bytes (20 ), random_bytes (50 )
0 commit comments