]> Untitled Git - bdk/commitdiff
Merge bitcoindevkit/bdk#1441: Remove duplicated InsufficientFunds error member
author志宇 <hello@evanlinjin.me>
Thu, 6 Jun 2024 04:17:19 +0000 (12:17 +0800)
committer志宇 <hello@evanlinjin.me>
Thu, 6 Jun 2024 04:17:46 +0000 (12:17 +0800)
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

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

index 3504b7d2f2a53700bca0f0722189cd382664dc68,6935deab97489694cbe0522eaafe7706d809baef..7b19a2ec5b0a5d950183d37ac499351cd0866a7d
@@@ -90,15 -90,10 +90,8 @@@ pub enum CreateTxError 
      NoUtxosSelected,
      /// Output created is under the dust limit, 546 satoshis
      OutputBelowDustLimit(usize),
 -    /// The `change_policy` was set but the wallet does not have a change_descriptor
 -    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
@@@ -175,14 -170,13 +168,7 @@@ impl fmt::Display for CreateTxError 
              CreateTxError::OutputBelowDustLimit(limit) => {
                  write!(f, "Output below the dust limit: {}", limit)
              }
 -            CreateTxError::ChangePolicyDescriptor => {
 -                write!(
 -                    f,
 -                    "The `change_policy` can be set only if the wallet has a change_descriptor"
 -                )
 -            }
              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")
              }
Simple merge