]> Untitled Git - bdk/commitdiff
chore(wallet): remove duplicated InsufficientFunds error member from CreateTxError
authore1a0a0ea <e1a0a0ea.axfv0@passmail.net>
Mon, 13 May 2024 07:28:43 +0000 (09:28 +0200)
committer志宇 <hello@evanlinjin.me>
Thu, 6 Jun 2024 03:08:23 +0000 (11:08 +0800)
review: move back to old error naming

crates/wallet/src/wallet/error.rs
crates/wallet/src/wallet/mod.rs

index 56612c54e046d0303f9e6386d4afc51de4222874..6935deab97489694cbe0522eaafe7706d809baef 100644 (file)
@@ -94,13 +94,6 @@ pub enum CreateTxError {
     ChangePolicyDescriptor,
     /// There was an error with coin selection
     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
     NoRecipients,
     /// Partially signed bitcoin transaction error
@@ -184,13 +177,6 @@ impl fmt::Display for CreateTxError {
                 )
             }
             CreateTxError::CoinSelection(e) => e.fmt(f),
-            CreateTxError::InsufficientFunds { needed, available } => {
-                write!(
-                    f,
-                    "Insufficient funds: {} sat available of {} sat needed",
-                    available, needed
-                )
-            }
             CreateTxError::NoRecipients => {
                 write!(f, "Cannot build tx without recipients")
             }
index 73fcaa218d15597a635fcb8cb850bc27aa2b7aab..1d4969b430d0e653b35c7452146b486e0352fe51 100644 (file)
@@ -73,6 +73,8 @@ use crate::types::*;
 use crate::wallet::coin_selection::Excess::{Change, NoChange};
 use crate::wallet::error::{BuildFeeBumpError, CreateTxError, MiniscriptPsbtError};
 
+use self::coin_selection::Error;
+
 const COINBASE_MATURITY: u32 = 100;
 
 /// A Bitcoin wallet
@@ -1595,10 +1597,10 @@ impl Wallet {
                     change_fee,
                 } = excess
                 {
-                    return Err(CreateTxError::InsufficientFunds {
+                    return Err(CreateTxError::CoinSelection(Error::InsufficientFunds {
                         needed: *dust_threshold,
                         available: remaining_amount.saturating_sub(*change_fee),
-                    });
+                    }));
                 }
             } else {
                 return Err(CreateTxError::NoRecipients);