From 04c8750f54075014af10b92aa800fb7dc596cfa7 Mon Sep 17 00:00:00 2001 From: valued mammal Date: Wed, 27 Mar 2024 13:34:18 -0400 Subject: [PATCH] test(wallet): Clarify docs for get_funded_wallet --- crates/bdk/tests/common.rs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/crates/bdk/tests/common.rs b/crates/bdk/tests/common.rs index da11e7dab5..84b9108b98 100644 --- a/crates/bdk/tests/common.rs +++ b/crates/bdk/tests/common.rs @@ -7,11 +7,11 @@ use bitcoin::hashes::Hash; use bitcoin::{Address, BlockHash, FeeRate, Network, OutPoint, Transaction, TxIn, TxOut, Txid}; use std::str::FromStr; -// Return a fake wallet that appears to be funded for testing. -// -// The funded wallet containing 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 as change. The remaining 1000 -// sats are the transaction fee. +/// Return a fake wallet that appears to be funded for testing. +/// +/// 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) { let mut wallet = Wallet::new_no_persist(descriptor, change, Network::Regtest).unwrap(); let receive_address = wallet.get_address(AddressIndex::New).address; @@ -96,11 +96,15 @@ pub fn get_funded_wallet_with_change(descriptor: &str, change: &str) -> (Wallet, (wallet, tx1.txid()) } -// Return a fake wallet that appears to be funded for testing. -// -// The funded wallet containing 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 as change. The remaining 1000 -// sats are the transaction fee. +/// Return a fake wallet that appears to be funded for testing. +/// +/// 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. +/// +/// 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`. pub fn get_funded_wallet(descriptor: &str) -> (Wallet, bitcoin::Txid) { let change = get_test_wpkh_change(); get_funded_wallet_with_change(descriptor, change)