Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions examples/v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
//! taken as NOT PROVEN CORRECT.

use std::collections::BTreeMap;
use std::str::FromStr;

use psbt_v2::bitcoin::bip32::{DerivationPath, Fingerprint};
use psbt_v2::bitcoin::hashes::Hash as _;
use psbt_v2::bitcoin::locktime::absolute;
use psbt_v2::bitcoin::opcodes::all::OP_CHECKMULTISIG;
Expand Down Expand Up @@ -86,6 +88,17 @@ fn main() -> anyhow::Result<()> {
psbt.inputs[0].witness_utxo = Some(alice.input_utxo());
psbt.inputs[1].witness_utxo = Some(bob.input_utxo());

// Add BIP32 derivation information for signing.
// Without this, psbt.sign() will not sign the inputs because bip32_sign_ecdsa() iterates
// over psbt.bip32_derivation to determine which keys should sign.
let fake_fp: [u8; 4] = [0; 4];
psbt.inputs[0]
.bip32_derivation
.insert(alice.0.pk, (Fingerprint::from(fake_fp), DerivationPath::from_str("m")?));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for your learning

"m".parse::<DerivationPath>()?

Works without the import of FromStr, and is more hard core ;)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the turbofish

psbt.inputs[1]
.bip32_derivation
.insert(bob.0.pk, (Fingerprint::from(fake_fp), DerivationPath::from_str("m")?));

// Since we are spending 2 p2wpkh inputs there are no other updates needed.

// Each party signs a copy of the PSBT.
Expand Down