diff --git a/crates/bdk/src/error.rs b/crates/bdk/src/error.rs index 7a164120f9..14157f2877 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"), @@ -144,6 +139,8 @@ impl_error!(bitcoin::psbt::Error, Psbt); #[derive(Debug)] /// Error returned from [`TxBuilder::finish`] +/// +/// [`TxBuilder::finish`]: crate::wallet::tx_builder::TxBuilder::finish pub enum CreateTxError
{ /// There was a problem with the descriptors passed in Descriptor(DescriptorError), @@ -342,3 +339,40 @@ impl
From {
#[cfg(feature = "std")]
impl {}
+
+//
+
+#[derive(Debug)]
+/// Error returned from [`Wallet::build_fee_bump`]
+///
+/// [`Wallet::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