diff --git a/crates/bdk/src/error.rs b/crates/bdk/src/error.rs index 7a164120f9..3f9f151c71 100644 --- a/crates/bdk/src/error.rs +++ b/crates/bdk/src/error.rs @@ -26,12 +26,12 @@ pub enum Error { Generic(String), /// Happens when trying to spend an UTXO that is not in the internal database UnknownUtxo, - /// Thrown when a tx is not found in the internal database - TransactionNotFound, - /// Happens when trying to bump a transaction that is already confirmed - TransactionConfirmed, - /// Trying to replace a tx that has a sequence >= `0xFFFFFFFE` - IrreplaceableTransaction, + // /// Thrown when a tx is not found in the internal database + // TransactionNotFound, + // /// Happens when trying to bump a transaction that is already confirmed + // TransactionConfirmed, + // /// Trying to replace a tx that has a sequence >= `0xFFFFFFFE` + // IrreplaceableTransaction, /// Node doesn't have data to estimate a fee rate FeeRateUnavailable, /// Error while working with [`keys`](crate::keys) @@ -84,11 +84,6 @@ impl fmt::Display for Error { match self { Self::Generic(err) => write!(f, "Generic error: {}", err), Self::UnknownUtxo => write!(f, "UTXO not found in the internal database"), - Self::TransactionNotFound => { - write!(f, "Transaction not found in the internal database") - } - Self::TransactionConfirmed => write!(f, "Transaction already confirmed"), - Self::IrreplaceableTransaction => write!(f, "Transaction can't be replaced"), Self::FeeRateUnavailable => write!(f, "Fee rate unavailable"), Self::Key(err) => write!(f, "Key error: {}", err), Self::ChecksumMismatch => write!(f, "Descriptor checksum mismatch"), @@ -342,3 +337,40 @@ impl
From {
#[cfg(feature = "std")]
impl {}
+
+//
+
+#[derive(Debug)]
+/// Error returned from [`Wallet::build_fee_bump`]
+///
+/// [`TxBuilder::build_fee_bump`]: wallet::Wallet::build_fee_bump
+pub enum BuildFeeBumpError {
+ /// Happens when trying to spend an UTXO that is not in the internal database
+ UnknownUtxo,
+ /// Thrown when a tx is not found in the internal database
+ TransactionNotFound,
+ /// Happens when trying to bump a transaction that is already confirmed
+ TransactionConfirmed,
+ /// Trying to replace a tx that has a sequence >= `0xFFFFFFFE`
+ IrreplaceableTransaction,
+ /// Node doesn't have data to estimate a fee rate
+ FeeRateUnavailable,
+}
+
+#[cfg(feature = "std")]
+impl fmt::Display for BuildFeeBumpError {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ match self {
+ Self::UnknownUtxo => write!(f, "UTXO not found in the internal database"),
+ Self::TransactionNotFound => {
+ write!(f, "Transaction not found in the internal database")
+ }
+ Self::TransactionConfirmed => write!(f, "Transaction already confirmed"),
+ Self::IrreplaceableTransaction => write!(f, "Transaction can't be replaced"),
+ Self::FeeRateUnavailable => write!(f, "Fee rate unavailable"),
+ }
+ }
+}
+
+#[cfg(feature = "std")]
+impl std::error::Error for BuildFeeBumpError {}
diff --git a/crates/bdk/src/wallet/mod.rs b/crates/bdk/src/wallet/mod.rs
index cc41addc6e..d32ba5d694 100644
--- a/crates/bdk/src/wallet/mod.rs
+++ b/crates/bdk/src/wallet/mod.rs
@@ -67,7 +67,7 @@ use crate::descriptor::{
calc_checksum, into_wallet_descriptor_checked, DerivedDescriptor, DescriptorMeta,
ExtendedDescriptor, ExtractPolicy, IntoWalletDescriptor, Policy, XKeyUtils,
};
-use crate::error::{CreateTxError, Error, MiniscriptPsbtError};
+use crate::error::{BuildFeeBumpError, CreateTxError, Error, MiniscriptPsbtError};
use crate::psbt::PsbtUtils;
use crate::signer::SignerError;
use crate::types::*;
@@ -1254,6 +1254,7 @@ impl