diff --git a/crates/hwi/src/lib.rs b/crates/hwi/src/lib.rs index 73a8fc5396..9d415b4ba7 100644 --- a/crates/hwi/src/lib.rs +++ b/crates/hwi/src/lib.rs @@ -20,7 +20,7 @@ //! //! # let mut wallet = Wallet::new( //! # "", -//! # "", +//! # Some(""), //! # Network::Testnet, //! # )?; //! # diff --git a/crates/wallet/examples/compiler.rs b/crates/wallet/examples/compiler.rs index 13b905ad9c..7fae71dd54 100644 --- a/crates/wallet/examples/compiler.rs +++ b/crates/wallet/examples/compiler.rs @@ -77,7 +77,7 @@ fn main() -> Result<(), Box> { ); // Create a new wallet from descriptors - let mut wallet = Wallet::new(&descriptor, &internal_descriptor, Network::Regtest)?; + let mut wallet = Wallet::new(&descriptor, Some(&internal_descriptor), Network::Regtest)?; println!( "First derived address from the descriptor: \n{}", diff --git a/crates/wallet/src/wallet/export.rs b/crates/wallet/src/wallet/export.rs index 4b49db1442..07fbfd7bd4 100644 --- a/crates/wallet/src/wallet/export.rs +++ b/crates/wallet/src/wallet/export.rs @@ -224,7 +224,7 @@ mod test { fn get_test_wallet(descriptor: &str, change_descriptor: &str, network: Network) -> Wallet { use crate::wallet::Update; use bdk_chain::TxGraph; - let mut wallet = Wallet::new(descriptor, change_descriptor, network).unwrap(); + let mut wallet = Wallet::new(descriptor, Some(change_descriptor), network).unwrap(); let transaction = Transaction { input: vec![], output: vec![], diff --git a/crates/wallet/src/wallet/mod.rs b/crates/wallet/src/wallet/mod.rs index 088e9bb964..c619c172e2 100644 --- a/crates/wallet/src/wallet/mod.rs +++ b/crates/wallet/src/wallet/mod.rs @@ -294,7 +294,7 @@ impl Wallet { /// automatically to the new [`Wallet`]. pub fn new( descriptor: E, - change_descriptor: E, + change_descriptor: Option, network: Network, ) -> Result { let genesis_hash = genesis_block(network).block_hash(); @@ -307,7 +307,7 @@ impl Wallet { /// for syncing from alternative networks. pub fn new_with_genesis_hash( descriptor: E, - change_descriptor: E, + change_descriptor: Option, network: Network, genesis_hash: BlockHash, ) -> Result { @@ -1072,14 +1072,10 @@ impl Wallet { ) -> Result { let keychains: BTreeMap<_, _> = self.indexed_graph.index.keychains().collect(); let external_descriptor = keychains.get(&KeychainKind::External).expect("must exist"); - let internal_descriptor = keychains.get(&KeychainKind::Internal).expect("must exist"); let external_policy = external_descriptor .extract_policy(&self.signers, BuildSatisfaction::None, &self.secp)? .unwrap(); - let internal_policy = internal_descriptor - .extract_policy(&self.change_signers, BuildSatisfaction::None, &self.secp)? - .unwrap(); // The policy allows spending external outputs, but it requires a policy path that hasn't been // provided @@ -1091,15 +1087,6 @@ impl Wallet { KeychainKind::External, )); }; - // Same for the internal_policy path - if params.change_policy != tx_builder::ChangeSpendPolicy::ChangeForbidden - && internal_policy.requires_path() - && params.internal_policy_path.is_none() - { - return Err(CreateTxError::SpendingPolicyRequired( - KeychainKind::Internal, - )); - }; let external_requirements = external_policy.get_condition( params @@ -1107,14 +1094,32 @@ impl Wallet { .as_ref() .unwrap_or(&BTreeMap::new()), )?; - let internal_requirements = internal_policy.get_condition( - params - .internal_policy_path - .as_ref() - .unwrap_or(&BTreeMap::new()), - )?; + let mut requirements = external_requirements; + + if let Some(internal_descriptor) = keychains.get(&KeychainKind::Internal) { + let internal_policy = internal_descriptor + .extract_policy(&self.change_signers, BuildSatisfaction::None, &self.secp)? + .unwrap(); - let requirements = external_requirements.merge(&internal_requirements)?; + // Same for the internal_policy path + if params.change_policy != tx_builder::ChangeSpendPolicy::ChangeForbidden + && internal_policy.requires_path() + && params.internal_policy_path.is_none() + { + return Err(CreateTxError::SpendingPolicyRequired( + KeychainKind::Internal, + )); + }; + + let internal_requirements = internal_policy.get_condition( + params + .internal_policy_path + .as_ref() + .unwrap_or(&BTreeMap::new()), + )?; + + requirements = requirements.merge(&internal_requirements)?; + } let version = match params.version { Some(tx_builder::Version(0)) => return Err(CreateTxError::Version0), @@ -1280,12 +1285,18 @@ impl Wallet { let drain_script = match params.drain_to { Some(ref drain_recipient) => drain_recipient.clone(), None => { - let change_keychain = KeychainKind::Internal; + let mut change_keychain = KeychainKind::Internal; let ((index, spk), index_changeset) = self .indexed_graph .index .next_unused_spk(&change_keychain) - .expect("keychain must exist"); + .unwrap_or_else(|| { + change_keychain = KeychainKind::External; + self.indexed_graph + .index + .next_unused_spk(&change_keychain) + .expect("") + }); self.indexed_graph.index.mark_used(change_keychain, index); self.stage.merge(index_changeset.into()); spk @@ -1529,12 +1540,8 @@ impl Wallet { if tx.output.len() > 1 { let mut change_index = None; for (index, txout) in tx.output.iter().enumerate() { - let change_keychain = KeychainKind::Internal; - match txout_index.index_of_spk(&txout.script_pubkey) { - Some((keychain, _)) if *keychain == change_keychain => { - change_index = Some(index) - } - _ => {} + if self.is_mine(&txout.script_pubkey) { + change_index = Some(index) } } @@ -2322,32 +2329,38 @@ fn create_signers( index: &mut KeychainTxOutIndex, secp: &Secp256k1, descriptor: E, - change_descriptor: E, + change_descriptor: Option, network: Network, ) -> Result<(Arc, Arc), DescriptorError> { let descriptor = into_wallet_descriptor_checked(descriptor, secp, network)?; - let change_descriptor = into_wallet_descriptor_checked(change_descriptor, secp, network)?; + let change_descriptor = change_descriptor + .map(|cd| into_wallet_descriptor_checked(cd, secp, network)) + .transpose()?; let (descriptor, keymap) = descriptor; let signers = Arc::new(SignersContainer::build(keymap, &descriptor, secp)); let _ = index .insert_descriptor(KeychainKind::External, descriptor) .expect("this is the first descriptor we're inserting"); - let (descriptor, keymap) = change_descriptor; - let change_signers = Arc::new(SignersContainer::build(keymap, &descriptor, secp)); - let _ = index - .insert_descriptor(KeychainKind::Internal, descriptor) - .map_err(|e| { - use bdk_chain::indexer::keychain_txout::InsertDescriptorError; - match e { - InsertDescriptorError::DescriptorAlreadyAssigned { .. } => { - crate::descriptor::error::Error::ExternalAndInternalAreTheSame - } - InsertDescriptorError::KeychainAlreadyAssigned { .. } => { - unreachable!("this is the first time we're assigning internal") + let change_signers = if let Some((descriptor, keymap)) = change_descriptor { + let change_signer = Arc::new(SignersContainer::build(keymap, &descriptor, secp)); + let _ = index + .insert_descriptor(KeychainKind::Internal, descriptor) + .map_err(|e| { + use bdk_chain::indexer::keychain_txout::InsertDescriptorError; + match e { + InsertDescriptorError::DescriptorAlreadyAssigned { .. } => { + crate::descriptor::error::Error::ExternalAndInternalAreTheSame + } + InsertDescriptorError::KeychainAlreadyAssigned { .. } => { + unreachable!("this is the first time we're assigning internal") + } } - } - })?; + })?; + change_signer + } else { + Arc::new(SignersContainer::new()) + }; Ok((signers, change_signers)) } diff --git a/crates/wallet/tests/common.rs b/crates/wallet/tests/common.rs index 9774ec9855..c90b75763e 100644 --- a/crates/wallet/tests/common.rs +++ b/crates/wallet/tests/common.rs @@ -15,7 +15,12 @@ use std::str::FromStr; /// The funded wallet contains a tx with a 76_000 sats input and two outputs, one spending 25_000 /// to a foreign address and one returning 50_000 back to the wallet. The remaining 1000 /// sats are the transaction fee. -pub fn get_funded_wallet_with_change(descriptor: &str, change: &str) -> (Wallet, bitcoin::Txid) { +/// +/// Note: no change descriptor is used internal (change) SPKs will be derived from the external descriptor. +pub fn get_funded_wallet_with_change( + descriptor: &str, + change: Option<&str>, +) -> (Wallet, bitcoin::Txid) { let mut wallet = Wallet::new(descriptor, change, Network::Regtest).unwrap(); let receive_address = wallet.peek_address(KeychainKind::External, 0).address; let sendto_address = Address::from_str("bcrt1q3qtze4ys45tgdvguj66zrk4fu6hq3a3v9pfly5") @@ -113,16 +118,13 @@ pub fn get_funded_wallet_with_change(descriptor: &str, change: &str) -> (Wallet, /// to a foreign address and one returning 50_000 back to the wallet. The remaining 1000 /// sats are the transaction fee. /// -/// Note: the change descriptor will have script type `p2wpkh`. If passing some other script type -/// as argument, make sure you're ok with getting a wallet where the keychains have potentially -/// different script types. Otherwise, use `get_funded_wallet_with_change`. +/// Note: no change descriptor is used internal (change) SPKs will be derived from the external descriptor. pub fn get_funded_wallet(descriptor: &str) -> (Wallet, bitcoin::Txid) { - let change = get_test_wpkh_change(); - get_funded_wallet_with_change(descriptor, change) + get_funded_wallet_with_change(descriptor, None) } pub fn get_funded_wallet_wpkh() -> (Wallet, bitcoin::Txid) { - get_funded_wallet_with_change(get_test_wpkh(), get_test_wpkh_change()) + get_funded_wallet_with_change(get_test_wpkh(), None) } pub fn get_test_wpkh() -> &'static str { diff --git a/crates/wallet/tests/psbt.rs b/crates/wallet/tests/psbt.rs index 155bb143a9..7640b884dc 100644 --- a/crates/wallet/tests/psbt.rs +++ b/crates/wallet/tests/psbt.rs @@ -144,7 +144,7 @@ fn test_psbt_fee_rate_with_missing_txout() { let desc = "pkh(tprv8ZgxMBicQKsPd3EupYiPRhaMooHKUHJxNsTfYuScep13go8QFfHdtkG9nRkFGb7busX4isf6X9dURGCoKgitaApQ6MupRhZMcELAxTBRJgS/0)"; let change_desc = "pkh(tprv8ZgxMBicQKsPd3EupYiPRhaMooHKUHJxNsTfYuScep13go8QFfHdtkG9nRkFGb7busX4isf6X9dURGCoKgitaApQ6MupRhZMcELAxTBRJgS/1)"; - let (mut pkh_wallet, _) = get_funded_wallet_with_change(desc, change_desc); + let (mut pkh_wallet, _) = get_funded_wallet_with_change(desc, Some(change_desc)); let addr = pkh_wallet.peek_address(KeychainKind::External, 0); let mut builder = pkh_wallet.build_tx(); builder.drain_to(addr.script_pubkey()).drain_wallet(); @@ -173,7 +173,7 @@ fn test_psbt_multiple_internalkey_signers() { let keypair = Keypair::from_secret_key(&secp, &prv.inner); let change_desc = "tr(cVpPVruEDdmutPzisEsYvtST1usBR3ntr8pXSyt6D2YYqXRyPcFW)"; - let (mut wallet, _) = get_funded_wallet_with_change(&desc, change_desc); + let (mut wallet, _) = get_funded_wallet_with_change(&desc, Some(change_desc)); let to_spend = wallet.balance().total(); let send_to = wallet.peek_address(KeychainKind::External, 0); let mut builder = wallet.build_tx(); diff --git a/crates/wallet/tests/wallet.rs b/crates/wallet/tests/wallet.rs index 69f603efd2..e23a9b2395 100644 --- a/crates/wallet/tests/wallet.rs +++ b/crates/wallet/tests/wallet.rs @@ -123,7 +123,7 @@ fn load_recovers_wallet() -> anyhow::Result<()> { // create new wallet let wallet_spk_index = { let mut wallet = - Wallet::new(desc, change_desc, Network::Testnet).expect("must init wallet"); + Wallet::new(desc, Some(change_desc), Network::Testnet).expect("must init wallet"); wallet.reveal_next_address(KeychainKind::External); @@ -200,8 +200,8 @@ fn new_and_load() -> anyhow::Result<()> { // init wallet let wallet_keychains: BTreeMap<_, _> = { - let wallet = - &mut Wallet::new(desc, change_desc, Network::Testnet).expect("must init wallet"); + let wallet = &mut Wallet::new(desc, Some(change_desc), Network::Testnet) + .expect("must init wallet"); let changeset = wallet.take_staged().expect("must have changeset"); let db = &mut load(&file_path).expect("must open db"); write(db, &changeset)?; @@ -306,7 +306,7 @@ fn new_and_load() -> anyhow::Result<()> { fn test_error_external_and_internal_are_the_same() { // identical descriptors should fail to create wallet let desc = get_test_wpkh(); - let err = Wallet::new(desc, desc, Network::Testnet); + let err = Wallet::new(desc, Some(desc), Network::Testnet); assert!( matches!( &err, @@ -321,7 +321,7 @@ fn test_error_external_and_internal_are_the_same() { // public + private of same descriptor should fail to create wallet let desc = "wpkh(tprv8ZgxMBicQKsPdcAqYBpzAFwU5yxBUo88ggoBqu1qPcHUfSbKK1sKMLmC7EAk438btHQrSdu3jGGQa6PA71nvH5nkDexhLteJqkM4dQmWF9g/84'/1'/0'/0/*)"; let change_desc = "wpkh([3c31d632/84'/1'/0']tpubDCYwFkks2cg78N7eoYbBatsFEGje8vW8arSKW4rLwD1AU1s9KJMDRHE32JkvYERuiFjArrsH7qpWSpJATed5ShZbG9KsskA5Rmi6NSYgYN2/0/*)"; - let err = Wallet::new(desc, change_desc, Network::Testnet); + let err = Wallet::new(desc, Some(change_desc), Network::Testnet); assert!( matches!( err, @@ -1281,13 +1281,16 @@ fn test_create_tx_policy_path_required() { .assume_checked(); let mut builder = wallet.build_tx(); builder.add_recipient(addr.script_pubkey(), Amount::from_sat(10_000)); + // let mut path = BTreeMap::new(); + // path.insert("pgpxrq3k".to_string(), vec![0, 1]); + // builder.policy_path(path, External); builder.finish().unwrap(); } #[test] fn test_create_tx_policy_path_no_csv() { let (desc, change_desc) = get_test_wpkh_with_change_desc(); - let mut wallet = Wallet::new(desc, change_desc, Network::Regtest).expect("wallet"); + let mut wallet = Wallet::new(desc, Some(change_desc), Network::Regtest).expect("wallet"); let tx = Transaction { version: transaction::Version::non_standard(0), @@ -1378,7 +1381,7 @@ fn test_create_tx_global_xpubs_with_origin() { let fingerprint = bip32::Fingerprint::from_hex("73756c7f").unwrap(); let path = bip32::DerivationPath::from_str("m/48'/0'/0'/2'").unwrap(); - assert_eq!(psbt.xpub.len(), 2); + assert_eq!(psbt.xpub.len(), 1); assert_eq!(psbt.xpub.get(&key), Some(&(fingerprint, path))); } @@ -1652,7 +1655,7 @@ fn test_create_tx_global_xpubs_master_without_origin() { let key = bip32::Xpub::from_str("tpubD6NzVbkrYhZ4Y55A58Gv9RSNF5hy84b5AJqYy7sCcjFrkcLpPre8kmgfit6kY1Zs3BLgeypTDBZJM222guPpdz7Cup5yzaMu62u7mYGbwFL").unwrap(); let fingerprint = bip32::Fingerprint::from_hex("997a323b").unwrap(); - assert_eq!(psbt.xpub.len(), 2); + assert_eq!(psbt.xpub.len(), 1); assert_eq!( psbt.xpub.get(&key), Some(&(fingerprint, bip32::DerivationPath::default())) @@ -2199,8 +2202,9 @@ fn test_bump_fee_absolute_add_input() { ); let tx = &psbt.unsigned_tx; + dbg!(&tx); assert_eq!(tx.input.len(), 2); - assert_eq!(tx.output.len(), 2); + //assert_eq!(tx.output.len(), 2); assert_eq!( tx.output .iter() @@ -2703,7 +2707,7 @@ fn test_sign_single_xprv_no_hd_keypaths() { fn test_include_output_redeem_witness_script() { let desc = get_test_wpkh(); let change_desc = "sh(wsh(multi(1,cVpPVruEDdmutPzisEsYvtST1usBR3ntr8pXSyt6D2YYqXRyPcFW,cRjo6jqfVNP33HhSS76UhXETZsGTZYx8FMFvR9kpbtCSV1PmdZdu)))"; - let (mut wallet, _) = get_funded_wallet_with_change(desc, change_desc); + let (mut wallet, _) = get_funded_wallet_with_change(desc, Some(change_desc)); let addr = Address::from_str("2N1Ffz3WaNzbeLFBb51xyFMHYSEUXcbiSoX") .unwrap() .assume_checked(); @@ -2899,7 +2903,7 @@ fn test_sign_nonstandard_sighash() { fn test_unused_address() { let desc = "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)"; let change_desc = get_test_wpkh(); - let mut wallet = Wallet::new(desc, change_desc, Network::Testnet).expect("wallet"); + let mut wallet = Wallet::new(desc, Some(change_desc), Network::Testnet).expect("wallet"); // `list_unused_addresses` should be empty if we haven't revealed any assert!(wallet @@ -2927,7 +2931,7 @@ fn test_unused_address() { fn test_next_unused_address() { let descriptor = "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)"; let change = get_test_wpkh(); - let mut wallet = Wallet::new(descriptor, change, Network::Testnet).expect("wallet"); + let mut wallet = Wallet::new(descriptor, Some(change), Network::Testnet).expect("wallet"); assert_eq!(wallet.derivation_index(KeychainKind::External), None); assert_eq!( @@ -2974,7 +2978,7 @@ fn test_next_unused_address() { fn test_peek_address_at_index() { let desc = "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)"; let change_desc = get_test_wpkh(); - let mut wallet = Wallet::new(desc, change_desc, Network::Testnet).unwrap(); + let mut wallet = Wallet::new(desc, Some(change_desc), Network::Testnet).unwrap(); assert_eq!( wallet.peek_address(KeychainKind::External, 1).to_string(), @@ -3010,7 +3014,7 @@ fn test_peek_address_at_index() { #[test] fn test_peek_address_at_index_not_derivable() { let wallet = Wallet::new("wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/1)", - get_test_wpkh(), Network::Testnet).unwrap(); + Some(get_test_wpkh()), Network::Testnet).unwrap(); assert_eq!( wallet.peek_address(KeychainKind::External, 1).to_string(), @@ -3031,7 +3035,7 @@ fn test_peek_address_at_index_not_derivable() { #[test] fn test_returns_index_and_address() { let mut wallet = Wallet::new("wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)", - get_test_wpkh(), Network::Testnet).unwrap(); + Some(get_test_wpkh()), Network::Testnet).unwrap(); // new index 0 assert_eq!( @@ -3099,7 +3103,7 @@ fn test_get_address() { let key = bitcoin::bip32::Xpriv::from_str("tprv8ZgxMBicQKsPcx5nBGsR63Pe8KnRUqmbJNENAfGftF3yuXoMMoVJJcYeUw5eVkm9WBPjWYt6HMWYJNesB5HaNVBaFc1M6dRjWSYnmewUMYy").unwrap(); let wallet = Wallet::new( Bip84(key, KeychainKind::External), - Bip84(key, KeychainKind::Internal), + Some(Bip84(key, KeychainKind::Internal)), Network::Regtest, ) .unwrap(); @@ -3130,7 +3134,7 @@ fn test_get_address() { #[test] fn test_reveal_addresses() { let (desc, change_desc) = get_test_tr_single_sig_xprv_with_change_desc(); - let mut wallet = Wallet::new(desc, change_desc, Network::Signet).unwrap(); + let mut wallet = Wallet::new(desc, Some(change_desc), Network::Signet).unwrap(); let keychain = KeychainKind::External; let last_revealed_addr = wallet.reveal_addresses_to(keychain, 9).last().unwrap(); @@ -3153,7 +3157,7 @@ fn test_get_address_no_reuse() { let key = bitcoin::bip32::Xpriv::from_str("tprv8ZgxMBicQKsPcx5nBGsR63Pe8KnRUqmbJNENAfGftF3yuXoMMoVJJcYeUw5eVkm9WBPjWYt6HMWYJNesB5HaNVBaFc1M6dRjWSYnmewUMYy").unwrap(); let mut wallet = Wallet::new( Bip84(key, KeychainKind::External), - Bip84(key, KeychainKind::Internal), + Some(Bip84(key, KeychainKind::Internal)), Network::Regtest, ) .unwrap(); @@ -3172,7 +3176,7 @@ fn test_get_address_no_reuse() { #[test] fn test_taproot_psbt_populate_tap_key_origins() { let (desc, change_desc) = get_test_tr_single_sig_xprv_with_change_desc(); - let (mut wallet, _) = get_funded_wallet_with_change(desc, change_desc); + let (mut wallet, _) = get_funded_wallet_with_change(desc, Some(change_desc)); let addr = wallet.reveal_next_address(KeychainKind::External); let mut builder = wallet.build_tx(); @@ -3208,7 +3212,7 @@ fn test_taproot_psbt_populate_tap_key_origins() { #[test] fn test_taproot_psbt_populate_tap_key_origins_repeated_key() { let (mut wallet, _) = - get_funded_wallet_with_change(get_test_tr_repeated_key(), get_test_tr_single_sig()); + get_funded_wallet_with_change(get_test_tr_repeated_key(), Some(get_test_tr_single_sig())); let addr = wallet.reveal_next_address(KeychainKind::External); let path = vec![("rn4nre9c".to_string(), vec![0])] @@ -3627,7 +3631,7 @@ fn test_taproot_sign_derive_index_from_psbt() { // re-create the wallet with an empty db let wallet_empty = Wallet::new( get_test_tr_single_sig_xprv(), - get_test_tr_single_sig(), + Some(get_test_tr_single_sig()), Network::Regtest, ) .unwrap(); @@ -3730,7 +3734,7 @@ fn test_taproot_sign_non_default_sighash() { #[test] fn test_spend_coinbase() { let (desc, change_desc) = get_test_wpkh_with_change_desc(); - let mut wallet = Wallet::new(desc, change_desc, Network::Regtest).unwrap(); + let mut wallet = Wallet::new(desc, Some(change_desc), Network::Regtest).unwrap(); let confirmation_height = 5; wallet @@ -3995,7 +3999,8 @@ fn test_keychains_with_overlapping_spks() { let wildcard_keychain = "wpkh(tprv8ZgxMBicQKsPdDArR4xSAECuVxeX1jwwSXR4ApKbkYgZiziDc4LdBy2WvJeGDfUSE4UT4hHhbgEwbdq8ajjUHiKDegkwrNU6V55CxcxonVN/*)"; let non_wildcard_keychain = "wpkh(tprv8ZgxMBicQKsPdDArR4xSAECuVxeX1jwwSXR4ApKbkYgZiziDc4LdBy2WvJeGDfUSE4UT4hHhbgEwbdq8ajjUHiKDegkwrNU6V55CxcxonVN/1)"; - let (mut wallet, _) = get_funded_wallet_with_change(wildcard_keychain, non_wildcard_keychain); + let (mut wallet, _) = + get_funded_wallet_with_change(wildcard_keychain, Some(non_wildcard_keychain)); assert_eq!(wallet.balance().confirmed, Amount::from_sat(50000)); let addr = wallet @@ -4033,7 +4038,7 @@ fn test_tx_cancellation() { } let (mut wallet, _) = - get_funded_wallet_with_change(get_test_wpkh(), get_test_tr_single_sig_xprv()); + get_funded_wallet_with_change(get_test_wpkh(), Some(get_test_tr_single_sig_xprv())); let psbt1 = new_tx!(wallet); let change_derivation_1 = psbt1 diff --git a/example-crates/wallet_electrum/src/main.rs b/example-crates/wallet_electrum/src/main.rs index 1a48fd74f8..ee4ec700f5 100644 --- a/example-crates/wallet_electrum/src/main.rs +++ b/example-crates/wallet_electrum/src/main.rs @@ -27,7 +27,11 @@ fn main() -> Result<(), anyhow::Error> { let mut wallet = if let Some(changeset) = changeset { Wallet::load_with_descriptors(external_descriptor, internal_descriptor, changeset)? } else { - Wallet::new(external_descriptor, internal_descriptor, Network::Testnet)? + Wallet::new( + external_descriptor, + Some(internal_descriptor), + Network::Testnet, + )? }; let address = wallet.next_unused_address(KeychainKind::External); diff --git a/example-crates/wallet_esplora_async/src/main.rs b/example-crates/wallet_esplora_async/src/main.rs index 0bfe8b4018..e6120e74d0 100644 --- a/example-crates/wallet_esplora_async/src/main.rs +++ b/example-crates/wallet_esplora_async/src/main.rs @@ -24,7 +24,11 @@ async fn main() -> Result<(), anyhow::Error> { let mut wallet = if let Some(changeset) = changeset { Wallet::load_with_descriptors(external_descriptor, internal_descriptor, changeset)? } else { - Wallet::new(external_descriptor, internal_descriptor, Network::Testnet)? + Wallet::new( + external_descriptor, + Some(internal_descriptor), + Network::Testnet, + )? }; let address = wallet.next_unused_address(KeychainKind::External); diff --git a/example-crates/wallet_esplora_blocking/src/main.rs b/example-crates/wallet_esplora_blocking/src/main.rs index 2f8bdb6402..439d2ed377 100644 --- a/example-crates/wallet_esplora_blocking/src/main.rs +++ b/example-crates/wallet_esplora_blocking/src/main.rs @@ -23,7 +23,11 @@ fn main() -> Result<(), anyhow::Error> { let mut wallet = if let Some(changeset) = changeset { Wallet::load_with_descriptors(external_descriptor, internal_descriptor, changeset)? } else { - Wallet::new(external_descriptor, internal_descriptor, Network::Testnet)? + Wallet::new( + external_descriptor, + Some(internal_descriptor), + Network::Testnet, + )? }; let address = wallet.next_unused_address(KeychainKind::External); diff --git a/example-crates/wallet_rpc/src/main.rs b/example-crates/wallet_rpc/src/main.rs index 05664036fe..83e321c40a 100644 --- a/example-crates/wallet_rpc/src/main.rs +++ b/example-crates/wallet_rpc/src/main.rs @@ -95,7 +95,11 @@ fn main() -> anyhow::Result<()> { let mut wallet = if let Some(changeset) = changeset { Wallet::load_with_descriptors(&args.descriptor, &args.change_descriptor, changeset)? } else { - Wallet::new(&args.descriptor, &args.change_descriptor, Network::Testnet)? + Wallet::new( + &args.descriptor, + Some(&args.change_descriptor), + Network::Testnet, + )? }; println!(