Skip to content

Commit b4a847f

Browse files
committed
Merge #1441: Remove duplicated InsufficientFunds error member
29c8a00 chore(wallet): remove duplicated InsufficientFunds error member from CreateTxError (e1a0a0ea) Pull request description: closes #1440 ### Description - Replace `CreateTxError::InsufficientFunds` use by `coin_selection::Error::InsufficientFunds` - Remove `InsufficientFunds` member from `CreateTxError` enum - Rename `coin_selection::Error` to `coin_selection::CoinSelectionError` ### Notes to the reviewers - We could also keep both members but rename one of them to avoid confusion ### Checklists #### All Submissions: * [X] I've signed all my commits * [X] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [X] I ran `cargo fmt` and `cargo clippy` before committing ACKs for top commit: evanlinjin: ACK 29c8a00 notmandatory: ACK 29c8a00 Tree-SHA512: a1132d09929f99f0a5e82d3ccfaa85695ae50d7d4d5d9e8fd9ef847313918ed8c7a01005f45483fef6aeae36730a0da2fed9a9f10c3ce2f0a679527caf798bfe
2 parents c5a3b62 + 29c8a00 commit b4a847f

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

crates/wallet/src/wallet/error.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,6 @@ pub enum CreateTxError {
9292
OutputBelowDustLimit(usize),
9393
/// There was an error with coin selection
9494
CoinSelection(coin_selection::Error),
95-
/// Wallet's UTXO set is not enough to cover recipient's requested plus fee
96-
InsufficientFunds {
97-
/// Sats needed for some transaction
98-
needed: u64,
99-
/// Sats available for spending
100-
available: u64,
101-
},
10295
/// Cannot build a tx without recipients
10396
NoRecipients,
10497
/// Partially signed bitcoin transaction error
@@ -176,13 +169,6 @@ impl fmt::Display for CreateTxError {
176169
write!(f, "Output below the dust limit: {}", limit)
177170
}
178171
CreateTxError::CoinSelection(e) => e.fmt(f),
179-
CreateTxError::InsufficientFunds { needed, available } => {
180-
write!(
181-
f,
182-
"Insufficient funds: {} sat available of {} sat needed",
183-
available, needed
184-
)
185-
}
186172
CreateTxError::NoRecipients => {
187173
write!(f, "Cannot build tx without recipients")
188174
}

crates/wallet/src/wallet/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ use crate::types::*;
7373
use crate::wallet::coin_selection::Excess::{Change, NoChange};
7474
use crate::wallet::error::{BuildFeeBumpError, CreateTxError, MiniscriptPsbtError};
7575

76+
use self::coin_selection::Error;
77+
7678
const COINBASE_MATURITY: u32 = 100;
7779

7880
/// A Bitcoin wallet
@@ -1562,10 +1564,10 @@ impl Wallet {
15621564
change_fee,
15631565
} = excess
15641566
{
1565-
return Err(CreateTxError::InsufficientFunds {
1567+
return Err(CreateTxError::CoinSelection(Error::InsufficientFunds {
15661568
needed: *dust_threshold,
15671569
available: remaining_amount.saturating_sub(*change_fee),
1568-
});
1570+
}));
15691571
}
15701572
} else {
15711573
return Err(CreateTxError::NoRecipients);

0 commit comments

Comments
 (0)