File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 77//! taken as NOT PROVEN CORRECT.
88
99use std:: collections:: BTreeMap ;
10+ use std:: str:: FromStr ;
1011
12+ use psbt_v2:: bitcoin:: bip32:: { DerivationPath , Fingerprint } ;
1113use psbt_v2:: bitcoin:: hashes:: Hash as _;
1214use psbt_v2:: bitcoin:: locktime:: absolute;
1315use psbt_v2:: bitcoin:: opcodes:: all:: OP_CHECKMULTISIG ;
@@ -86,6 +88,17 @@ fn main() -> anyhow::Result<()> {
8688 psbt. inputs [ 0 ] . witness_utxo = Some ( alice. input_utxo ( ) ) ;
8789 psbt. inputs [ 1 ] . witness_utxo = Some ( bob. input_utxo ( ) ) ;
8890
91+ // Add BIP32 derivation information for signing.
92+ // Without this, psbt.sign() will not sign the inputs because bip32_sign_ecdsa() iterates
93+ // over psbt.bip32_derivation to determine which keys should sign.
94+ let fake_fp: [ u8 ; 4 ] = [ 0 ; 4 ] ;
95+ psbt. inputs [ 0 ]
96+ . bip32_derivation
97+ . insert ( alice. 0 . pk , ( Fingerprint :: from ( fake_fp) , DerivationPath :: from_str ( "m" ) ?) ) ;
98+ psbt. inputs [ 1 ]
99+ . bip32_derivation
100+ . insert ( bob. 0 . pk , ( Fingerprint :: from ( fake_fp) , DerivationPath :: from_str ( "m" ) ?) ) ;
101+
89102 // Since we are spending 2 p2wpkh inputs there are no other updates needed.
90103
91104 // Each party signs a copy of the PSBT.
You can’t perform that action at this time.
0 commit comments