diff --git a/src/descriptor/policy.rs b/src/descriptor/policy.rs index de22fd3e..ba28bf4a 100644 --- a/src/descriptor/policy.rs +++ b/src/descriptor/policy.rs @@ -61,7 +61,7 @@ use crate::wallet::utils::{self, After, Older, SecpCtx}; use super::checksum::get_checksum; use super::error::Error; use super::XKeyUtils; -use bitcoin::util::psbt::PartiallySignedTransaction as PSBT; +use bitcoin::util::psbt::PartiallySignedTransaction as Psbt; use miniscript::psbt::PsbtInputSatisfier; /// Raw public key or extended key fingerprint @@ -760,7 +760,7 @@ fn signature( policy } -fn signature_in_psbt(psbt: &PSBT, key: &DescriptorPublicKey, secp: &SecpCtx) -> bool { +fn signature_in_psbt(psbt: &Psbt, key: &DescriptorPublicKey, secp: &SecpCtx) -> bool { //TODO check signature validity psbt.inputs.iter().all(|input| match key { DescriptorPublicKey::SinglePub(key) => input.partial_sigs.contains_key(&key.key), @@ -923,7 +923,7 @@ impl ExtractPolicy for Miniscript } } -fn psbt_inputs_sat(psbt: &PSBT) -> impl Iterator { +fn psbt_inputs_sat(psbt: &Psbt) -> impl Iterator { (0..psbt.inputs.len()).map(move |i| PsbtInputSatisfier::new(psbt, i)) } @@ -933,11 +933,11 @@ pub enum BuildSatisfaction<'a> { /// Don't generate `satisfaction` field None, /// Analyze the given PSBT to check for existing signatures - Psbt(&'a PSBT), + Psbt(&'a Psbt), /// Like `Psbt` variant and also check for expired timelocks PsbtTimelocks { /// Given PSBT - psbt: &'a PSBT, + psbt: &'a Psbt, /// Current blockchain height current_height: u32, /// The highest confirmation height between the inputs @@ -946,7 +946,7 @@ pub enum BuildSatisfaction<'a> { }, } impl<'a> BuildSatisfaction<'a> { - fn psbt(&self) -> Option<&'a PSBT> { + fn psbt(&self) -> Option<&'a Psbt> { match self { BuildSatisfaction::None => None, BuildSatisfaction::Psbt(psbt) => Some(psbt), @@ -1475,7 +1475,7 @@ mod test { let signers_container = Arc::new(SignersContainer::from(keymap)); - let psbt: PSBT = deserialize(&base64::decode(ALICE_SIGNED_PSBT).unwrap()).unwrap(); + let psbt: Psbt = deserialize(&base64::decode(ALICE_SIGNED_PSBT).unwrap()).unwrap(); let policy_alice_psbt = wallet_desc .extract_policy(&signers_container, BuildSatisfaction::Psbt(&psbt), &secp) @@ -1490,7 +1490,7 @@ mod test { ) ); - let psbt: PSBT = deserialize(&base64::decode(BOB_SIGNED_PSBT).unwrap()).unwrap(); + let psbt: Psbt = deserialize(&base64::decode(BOB_SIGNED_PSBT).unwrap()).unwrap(); let policy_bob_psbt = wallet_desc .extract_policy(&signers_container, BuildSatisfaction::Psbt(&psbt), &secp) .unwrap() @@ -1504,7 +1504,7 @@ mod test { ) ); - let psbt: PSBT = deserialize(&base64::decode(ALICE_BOB_SIGNED_PSBT).unwrap()).unwrap(); + let psbt: Psbt = deserialize(&base64::decode(ALICE_BOB_SIGNED_PSBT).unwrap()).unwrap(); let policy_alice_bob_psbt = wallet_desc .extract_policy(&signers_container, BuildSatisfaction::Psbt(&psbt), &secp) .unwrap() @@ -1545,7 +1545,7 @@ mod test { addr.to_string() ); - let psbt: PSBT = + let psbt: Psbt = deserialize(&base64::decode(PSBT_POLICY_CONSIDER_TIMELOCK_EXPIRED).unwrap()).unwrap(); let build_sat = BuildSatisfaction::PsbtTimelocks { @@ -1584,7 +1584,7 @@ mod test { ); //println!("{}", serde_json::to_string(&policy_expired).unwrap()); - let psbt_signed: PSBT = + let psbt_signed: Psbt = deserialize(&base64::decode(PSBT_POLICY_CONSIDER_TIMELOCK_EXPIRED_SIGNED).unwrap()) .unwrap(); diff --git a/src/psbt/mod.rs b/src/psbt/mod.rs index ff950db7..2bda4852 100644 --- a/src/psbt/mod.rs +++ b/src/psbt/mod.rs @@ -9,14 +9,14 @@ // You may not use this file except in accordance with one or both of these // licenses. -use bitcoin::util::psbt::PartiallySignedTransaction as PSBT; +use bitcoin::util::psbt::PartiallySignedTransaction as Psbt; use bitcoin::TxOut; pub trait PsbtUtils { fn get_utxo_for(&self, input_index: usize) -> Option; } -impl PsbtUtils for PSBT { +impl PsbtUtils for Psbt { fn get_utxo_for(&self, input_index: usize) -> Option { let tx = &self.global.unsigned_tx; @@ -42,7 +42,7 @@ impl PsbtUtils for PSBT { mod test { use crate::bitcoin::consensus::deserialize; use crate::bitcoin::TxIn; - use crate::psbt::PSBT; + use crate::psbt::Psbt; use crate::wallet::test::{get_funded_wallet, get_test_wpkh}; use crate::wallet::AddressIndex; use crate::SignOptions; @@ -53,7 +53,7 @@ mod test { #[test] #[should_panic(expected = "InputIndexOutOfRange")] fn test_psbt_malformed_psbt_input_legacy() { - let psbt_bip: PSBT = deserialize(&base64::decode(PSBT_STR).unwrap()).unwrap(); + let psbt_bip: Psbt = deserialize(&base64::decode(PSBT_STR).unwrap()).unwrap(); let (wallet, _, _) = get_funded_wallet(get_test_wpkh()); let send_to = wallet.get_address(AddressIndex::New).unwrap(); let mut builder = wallet.build_tx(); @@ -70,7 +70,7 @@ mod test { #[test] #[should_panic(expected = "InputIndexOutOfRange")] fn test_psbt_malformed_psbt_input_segwit() { - let psbt_bip: PSBT = deserialize(&base64::decode(PSBT_STR).unwrap()).unwrap(); + let psbt_bip: Psbt = deserialize(&base64::decode(PSBT_STR).unwrap()).unwrap(); let (wallet, _, _) = get_funded_wallet(get_test_wpkh()); let send_to = wallet.get_address(AddressIndex::New).unwrap(); let mut builder = wallet.build_tx(); @@ -102,7 +102,7 @@ mod test { #[test] fn test_psbt_sign_with_finalized() { - let psbt_bip: PSBT = deserialize(&base64::decode(PSBT_STR).unwrap()).unwrap(); + let psbt_bip: Psbt = deserialize(&base64::decode(PSBT_STR).unwrap()).unwrap(); let (wallet, _, _) = get_funded_wallet(get_test_wpkh()); let send_to = wallet.get_address(AddressIndex::New).unwrap(); let mut builder = wallet.build_tx(); diff --git a/src/wallet/mod.rs b/src/wallet/mod.rs index 53522695..cd78ed60 100644 --- a/src/wallet/mod.rs +++ b/src/wallet/mod.rs @@ -25,7 +25,7 @@ use bitcoin::consensus::encode::serialize; use bitcoin::util::base58; use bitcoin::util::psbt::raw::Key as PSBTKey; use bitcoin::util::psbt::Input; -use bitcoin::util::psbt::PartiallySignedTransaction as PSBT; +use bitcoin::util::psbt::PartiallySignedTransaction as Psbt; use bitcoin::{Address, Network, OutPoint, Script, SigHashType, Transaction, TxOut, Txid}; use miniscript::descriptor::DescriptorTrait; @@ -371,7 +371,7 @@ where &self, coin_selection: Cs, params: TxParams, - ) -> Result<(PSBT, TransactionDetails), Error> { + ) -> Result<(Psbt, TransactionDetails), Error> { let external_policy = self .descriptor .extract_policy(&self.signers, BuildSatisfaction::None, &self.secp)? @@ -857,7 +857,7 @@ where /// let finalized = wallet.sign(&mut psbt, SignOptions::default())?; /// assert!(finalized, "we should have signed all the inputs"); /// # Ok::<(), bdk::Error>(()) - pub fn sign(&self, psbt: &mut PSBT, sign_options: SignOptions) -> Result { + pub fn sign(&self, psbt: &mut Psbt, sign_options: SignOptions) -> Result { // this helps us doing our job later self.add_input_hd_keypaths(psbt)?; @@ -927,7 +927,7 @@ where /// Try to finalize a PSBT /// /// The [`SignOptions`] can be used to tweak the behavior of the finalizer. - pub fn finalize_psbt(&self, psbt: &mut PSBT, sign_options: SignOptions) -> Result { + pub fn finalize_psbt(&self, psbt: &mut Psbt, sign_options: SignOptions) -> Result { let tx = &psbt.global.unsigned_tx; let mut finished = true; @@ -1228,10 +1228,10 @@ where tx: Transaction, selected: Vec, params: TxParams, - ) -> Result { + ) -> Result { use bitcoin::util::psbt::serialize::Serialize; - let mut psbt = PSBT::from_unsigned_tx(tx)?; + let mut psbt = Psbt::from_unsigned_tx(tx)?; if params.add_global_xpubs { let mut all_xpubs = self.descriptor.get_extended_keys()?; @@ -1371,7 +1371,7 @@ where Ok(psbt_input) } - fn add_input_hd_keypaths(&self, psbt: &mut PSBT) -> Result<(), Error> { + fn add_input_hd_keypaths(&self, psbt: &mut Psbt) -> Result<(), Error> { let mut input_utxos = Vec::with_capacity(psbt.inputs.len()); for n in 0..psbt.inputs.len() { input_utxos.push(psbt.get_utxo_for(n).clone()); diff --git a/src/wallet/tx_builder.rs b/src/wallet/tx_builder.rs index 77ef5180..3d59c5a3 100644 --- a/src/wallet/tx_builder.rs +++ b/src/wallet/tx_builder.rs @@ -41,7 +41,7 @@ use std::collections::HashSet; use std::default::Default; use std::marker::PhantomData; -use bitcoin::util::psbt::{self, PartiallySignedTransaction as PSBT}; +use bitcoin::util::psbt::{self, PartiallySignedTransaction as Psbt}; use bitcoin::{OutPoint, Script, SigHashType, Transaction}; use miniscript::descriptor::DescriptorTrait; @@ -521,7 +521,7 @@ impl<'a, B, D: BatchDatabase, Cs: CoinSelectionAlgorithm, Ctx: TxBuilderConte /// Returns the [`BIP174`] "PSBT" and summary details about the transaction. /// /// [`BIP174`]: https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki - pub fn finish(self) -> Result<(PSBT, TransactionDetails), Error> { + pub fn finish(self) -> Result<(Psbt, TransactionDetails), Error> { self.wallet.create_tx(self.coin_selection, self.params) }