Skip to content

Commit 74ea881

Browse files
committed
Merge #35: fix: missing example in psbt segwit example
b369269 fix: missing example in psbt segwit example (Carlos Garcia Ortiz karliatto) Pull request description: The example `cookbook/src/psbt/multiple_inputs_segwit-v0.md` had some missing imports and some unnecessary ones. ACKs for top commit: tcharding: ACK b369269 Tree-SHA512: 83e29abdfb9b8e1bddab8a7f822e2f12fa874679e75cfc5bf64e088e3efc6b848f5f0e7bc9b5b5a6b98644d77eb69d921a84d429511626fc36ada183af5391fb
2 parents d62ce10 + b369269 commit 74ea881

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

cookbook/src/psbt/multiple_inputs_segwit-v0.md

+10-15
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,13 @@ First we'll need to import the following:
3333
use std::collections::BTreeMap;
3434
use std::str::FromStr;
3535

36-
use bitcoin::bip32::{ChildNumber, IntoDerivationPath, Fingerprint, Xpriv, Xpub};
36+
use bitcoin::bip32::{ChildNumber, Fingerprint, IntoDerivationPath as _, Xpriv, Xpub};
3737
use bitcoin::hashes::Hash;
3838
use bitcoin::locktime::absolute;
39-
use bitcoin::psbt::Input;
40-
use bitcoin::secp256k1::{self, Message, Secp256k1, Signing};
41-
use bitcoin::consensus;
42-
use bitcoin::transaction::{self, OutPoint, TxIn, TxOut};
39+
use bitcoin::secp256k1::{Secp256k1, Signing};
4340
use bitcoin::{
44-
Address, Amount, EcdsaSighashType, Network, Psbt, ScriptBuf, Sequence,
45-
Txid, WPubkeyHash, Witness, XOnlyPublicKey,
41+
consensus, psbt, transaction, Address, Amount, EcdsaSighashType, Network, OutPoint, Psbt,
42+
ScriptBuf, Sequence, Transaction, TxIn, TxOut, Txid, WPubkeyHash, Witness,
4643
};
4744
```
4845

@@ -53,10 +50,9 @@ Here is the logic behind these imports:
5350
- `bitcoin::bip32` is used to derive keys according to [BIP 32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki)
5451
- `bitcoin::hashes::Hash` is used to hash data
5552
- `bitcoin::locktime::absolute` is used to create a locktime
56-
- `bitcoin::psbt` is used to construct and manipulate PSBTs
5753
- `bitcoin::secp256k1` is used to sign transactions
58-
- `bitcoin::sighash` is used to create SegWit V0 sighashes
5954
- `bitcoin::consensus` is used to serialize the final signed transaction to a raw transaction
55+
- `bitcoin::psbt` is used to construct and manipulate PSBTs
6056
- `bitcoin::transaction` and `bitcoin::{Address, Network, OutPoint, ScriptBuf, Sequence, Transaction, TxIn, TxOut, Txid, Witness}` are used to construct transactions
6157
- `bitcoin::WPubkeyHash` is used to construct SegWit V0 inputs
6258

@@ -204,14 +200,13 @@ while also extracting a transaction that spends the `p2wpkh`s unspent outputs:
204200
# use std::collections::BTreeMap;
205201
# use std::str::FromStr;
206202
#
207-
# use bitcoin::bip32::{ChildNumber, IntoDerivationPath, Fingerprint, Xpriv, Xpub};
203+
# use bitcoin::bip32::{ChildNumber, Fingerprint, IntoDerivationPath as _, Xpriv, Xpub};
208204
# use bitcoin::hashes::Hash;
209205
# use bitcoin::locktime::absolute;
210-
# use bitcoin::psbt::{Input, PsbtSighashType};
211206
# use bitcoin::secp256k1::{Secp256k1, Signing};
212207
# use bitcoin::{
213-
# consensus, transaction, Address, Amount, EcdsaSighashType, Network, OutPoint, Psbt, ScriptBuf, Sequence,
214-
# Transaction, TxIn, TxOut, Txid, WPubkeyHash, Witness,
208+
# consensus, psbt, transaction, Address, Amount, EcdsaSighashType, Network, OutPoint, Psbt,
209+
# ScriptBuf, Sequence, Transaction, TxIn, TxOut, Txid, WPubkeyHash, Witness,
215210
# };
216211
#
217212
# const XPRIV: &str = "xprv9tuogRdb5YTgcL3P8Waj7REqDuQx4sXcodQaWTtEVFEp6yRKh1CjrWfXChnhgHeLDuXxo2auDZegMiVMGGxwxcrb2PmiGyCngLxvLeGsZRq";
@@ -379,14 +374,14 @@ fn main() {
379374
bip32_derivations.push(map);
380375
}
381376
psbt.inputs = vec![
382-
Input {
377+
psbt::Input {
383378
witness_utxo: Some(utxos[0].clone()),
384379
redeem_script: Some(ScriptBuf::new_p2wpkh(&wpkhs[0])),
385380
bip32_derivation: bip32_derivations[0].clone(),
386381
sighash_type: Some(ty),
387382
..Default::default()
388383
},
389-
Input {
384+
psbt::Input {
390385
witness_utxo: Some(utxos[1].clone()),
391386
redeem_script: Some(ScriptBuf::new_p2wpkh(&wpkhs[1])),
392387
bip32_derivation: bip32_derivations[1].clone(),

0 commit comments

Comments
 (0)