Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2093,11 +2093,11 @@ impl Wallet {
.0
}

/// Informs the wallet that you no longer intend to broadcast a tx that was built from it.
/// Unreserves the change address used in a transaction that will not be broadcast.
///
/// This frees up the change address used when creating the tx for use in future transactions.
// TODO: Make this free up reserved utxos when that's implemented
pub fn cancel_tx(&mut self, tx: &Transaction) {
pub fn unreserve_change_address(&mut self, tx: &Transaction) {
let txout_index = &mut self.indexed_graph.index;
for txout in &tx.output {
if let Some((keychain, index)) = txout_index.index_of_spk(txout.script_pubkey.clone()) {
Expand Down
4 changes: 2 additions & 2 deletions tests/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2801,7 +2801,7 @@ fn test_tx_cancellation() {
.unwrap();
assert_eq!(change_derivation_2, (KeychainKind::Internal, 1));

wallet.cancel_tx(&psbt1.extract_tx().expect("failed to extract tx"));
wallet.unreserve_change_address(&psbt1.extract_tx().expect("failed to extract tx"));

let psbt3 = new_tx!(wallet);
let change_derivation_3 = psbt3
Expand All @@ -2821,7 +2821,7 @@ fn test_tx_cancellation() {
.unwrap();
assert_eq!(change_derivation_3, (KeychainKind::Internal, 2));

wallet.cancel_tx(&psbt3.extract_tx().expect("failed to extract tx"));
wallet.unreserve_change_address(&psbt3.extract_tx().expect("failed to extract tx"));

let psbt3 = new_tx!(wallet);
let change_derivation_4 = psbt3
Expand Down