Skip to content

Commit 29c8a00

Browse files
e1a0a0eaevanlinjin
authored andcommitted
chore(wallet): remove duplicated InsufficientFunds error member from CreateTxError
review: move back to old error naming
1 parent 8eef350 commit 29c8a00

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
@@ -94,13 +94,6 @@ pub enum CreateTxError {
9494
ChangePolicyDescriptor,
9595
/// There was an error with coin selection
9696
CoinSelection(coin_selection::Error),
97-
/// Wallet's UTXO set is not enough to cover recipient's requested plus fee
98-
InsufficientFunds {
99-
/// Sats needed for some transaction
100-
needed: u64,
101-
/// Sats available for spending
102-
available: u64,
103-
},
10497
/// Cannot build a tx without recipients
10598
NoRecipients,
10699
/// Partially signed bitcoin transaction error
@@ -184,13 +177,6 @@ impl fmt::Display for CreateTxError {
184177
)
185178
}
186179
CreateTxError::CoinSelection(e) => e.fmt(f),
187-
CreateTxError::InsufficientFunds { needed, available } => {
188-
write!(
189-
f,
190-
"Insufficient funds: {} sat available of {} sat needed",
191-
available, needed
192-
)
193-
}
194180
CreateTxError::NoRecipients => {
195181
write!(f, "Cannot build tx without recipients")
196182
}

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
@@ -1595,10 +1597,10 @@ impl Wallet {
15951597
change_fee,
15961598
} = excess
15971599
{
1598-
return Err(CreateTxError::InsufficientFunds {
1600+
return Err(CreateTxError::CoinSelection(Error::InsufficientFunds {
15991601
needed: *dust_threshold,
16001602
available: remaining_amount.saturating_sub(*change_fee),
1601-
});
1603+
}));
16021604
}
16031605
} else {
16041606
return Err(CreateTxError::NoRecipients);

0 commit comments

Comments
 (0)