Merge bitcoindevkit/bdk#1441: Remove duplicated InsufficientFunds error member
29c8a00b435bdf2fa1d7c707ad09c1a47edc07b3 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 29c8a00b435bdf2fa1d7c707ad09c1a47edc07b3 notmandatory: ACK 29c8a00b435bdf2fa1d7c707ad09c1a47edc07b3 Tree-SHA512: a1132d09929f99f0a5e82d3ccfaa85695ae50d7d4d5d9e8fd9ef847313918ed8c7a01005f45483fef6aeae36730a0da2fed9a9f10c3ce2f0a679527caf798bfe
This commit is contained in:
commit
b4a847f801
@ -92,13 +92,6 @@ pub enum CreateTxError {
|
|||||||
OutputBelowDustLimit(usize),
|
OutputBelowDustLimit(usize),
|
||||||
/// There was an error with coin selection
|
/// There was an error with coin selection
|
||||||
CoinSelection(coin_selection::Error),
|
CoinSelection(coin_selection::Error),
|
||||||
/// Wallet's UTXO set is not enough to cover recipient's requested plus fee
|
|
||||||
InsufficientFunds {
|
|
||||||
/// Sats needed for some transaction
|
|
||||||
needed: u64,
|
|
||||||
/// Sats available for spending
|
|
||||||
available: u64,
|
|
||||||
},
|
|
||||||
/// Cannot build a tx without recipients
|
/// Cannot build a tx without recipients
|
||||||
NoRecipients,
|
NoRecipients,
|
||||||
/// Partially signed bitcoin transaction error
|
/// Partially signed bitcoin transaction error
|
||||||
@ -176,13 +169,6 @@ impl fmt::Display for CreateTxError {
|
|||||||
write!(f, "Output below the dust limit: {}", limit)
|
write!(f, "Output below the dust limit: {}", limit)
|
||||||
}
|
}
|
||||||
CreateTxError::CoinSelection(e) => e.fmt(f),
|
CreateTxError::CoinSelection(e) => e.fmt(f),
|
||||||
CreateTxError::InsufficientFunds { needed, available } => {
|
|
||||||
write!(
|
|
||||||
f,
|
|
||||||
"Insufficient funds: {} sat available of {} sat needed",
|
|
||||||
available, needed
|
|
||||||
)
|
|
||||||
}
|
|
||||||
CreateTxError::NoRecipients => {
|
CreateTxError::NoRecipients => {
|
||||||
write!(f, "Cannot build tx without recipients")
|
write!(f, "Cannot build tx without recipients")
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,8 @@ use crate::types::*;
|
|||||||
use crate::wallet::coin_selection::Excess::{Change, NoChange};
|
use crate::wallet::coin_selection::Excess::{Change, NoChange};
|
||||||
use crate::wallet::error::{BuildFeeBumpError, CreateTxError, MiniscriptPsbtError};
|
use crate::wallet::error::{BuildFeeBumpError, CreateTxError, MiniscriptPsbtError};
|
||||||
|
|
||||||
|
use self::coin_selection::Error;
|
||||||
|
|
||||||
const COINBASE_MATURITY: u32 = 100;
|
const COINBASE_MATURITY: u32 = 100;
|
||||||
|
|
||||||
/// A Bitcoin wallet
|
/// A Bitcoin wallet
|
||||||
@ -1562,10 +1564,10 @@ impl Wallet {
|
|||||||
change_fee,
|
change_fee,
|
||||||
} = excess
|
} = excess
|
||||||
{
|
{
|
||||||
return Err(CreateTxError::InsufficientFunds {
|
return Err(CreateTxError::CoinSelection(Error::InsufficientFunds {
|
||||||
needed: *dust_threshold,
|
needed: *dust_threshold,
|
||||||
available: remaining_amount.saturating_sub(*change_fee),
|
available: remaining_amount.saturating_sub(*change_fee),
|
||||||
});
|
}));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Err(CreateTxError::NoRecipients);
|
return Err(CreateTxError::NoRecipients);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user