diff --git a/.github/workflows/cont_integration.yml b/.github/workflows/cont_integration.yml index 4bb31ffbea..684a500e16 100644 --- a/.github/workflows/cont_integration.yml +++ b/.github/workflows/cont_integration.yml @@ -43,10 +43,11 @@ jobs: cargo update -p rustls-webpki:0.101.6 --precise "0.101.1" cargo update -p zip:0.6.6 --precise "0.6.2" cargo update -p time --precise "0.3.13" - cargo update -p cc --precise "1.0.81" cargo update -p byteorder --precise "1.4.3" cargo update -p webpki --precise "0.22.2" + cargo update -p cc --precise "1.0.81" cargo update -p jobserver --precise "0.1.26" + cargo update -p os_str_bytes --precise "6.5.1" - name: Build run: cargo build ${{ matrix.features }} - name: Test diff --git a/README.md b/README.md index 4f97f10154..66c4bcb62a 100644 --- a/README.md +++ b/README.md @@ -91,14 +91,16 @@ cargo update -p rustls-webpki:0.101.6 --precise "0.101.1" cargo update -p zip:0.6.6 --precise "0.6.2" # time 0.3.14 has MSRV 1.59.0+ cargo update -p time --precise "0.3.13" -# cc 1.0.82 has MSRV 1.61.0+ -cargo update -p cc --precise "1.0.81" # byteorder 1.5.0 has MSRV 1.60.0+ cargo update -p byteorder --precise "1.4.3" # webpki 0.22.4 requires `ring:0.17.2` which has MSRV 1.61.0+ cargo update -p webpki --precise "0.22.2" -# jobserver 0.1.27 has MSRV 1.66.0+ +# cc 1.0.82 has MSRV 1.61.0+ +cargo update -p cc --precise "1.0.81" +# jobserver 0.1.27 has MSRV 1.66.0 cargo update -p jobserver --precise "0.1.26" +# os_str_bytes 6.6.0 has MSRV 1.61.0 +cargo update -p os_str_bytes --precise "6.5.1" ``` ## License diff --git a/crates/bdk/src/error.rs b/crates/bdk/src/error.rs index 14157f2877..d73ceb7228 100644 --- a/crates/bdk/src/error.rs +++ b/crates/bdk/src/error.rs @@ -16,7 +16,7 @@ use crate::descriptor::DescriptorError; use crate::wallet::coin_selection; use crate::{descriptor, wallet, FeeRate, KeychainKind}; use alloc::string::String; -use bitcoin::{absolute, psbt, OutPoint, Sequence}; +use bitcoin::{absolute, psbt, OutPoint, Sequence, Txid}; use core::fmt; /// Old catch-all errors enum that can be thrown by the [`Wallet`](crate::wallet::Wallet) @@ -26,12 +26,6 @@ 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, /// Node doesn't have data to estimate a fee rate FeeRateUnavailable, /// Error while working with [`keys`](crate::keys) @@ -348,13 +342,25 @@ impl std::error::Error for CreateTxErr /// [`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, + UnknownUtxo { + /// The outpoint of the missing UTXO + outpoint: OutPoint, + }, /// Thrown when a tx is not found in the internal database - TransactionNotFound, + TransactionNotFound { + /// The txid of the missing transaction + txid: Txid, + }, /// Happens when trying to bump a transaction that is already confirmed - TransactionConfirmed, + TransactionConfirmed { + /// The txid of the already confirmed transaction + txid: Txid, + }, /// Trying to replace a tx that has a sequence >= `0xFFFFFFFE` - IrreplaceableTransaction, + IrreplaceableTransaction { + /// The txid of the irreplaceable transaction + txid: Txid, + }, /// Node doesn't have data to estimate a fee rate FeeRateUnavailable, } @@ -363,12 +369,24 @@ pub enum BuildFeeBumpError { 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::UnknownUtxo { outpoint } => write!( + f, + "UTXO not found in the internal database with txid: {}, vout: {}", + outpoint.txid, outpoint.vout + ), + Self::TransactionNotFound { txid } => { + write!( + f, + "Transaction not found in the internal database with txid: {}", + txid + ) + } + Self::TransactionConfirmed { txid } => { + write!(f, "Transaction already confirmed with txid: {}", txid) + } + Self::IrreplaceableTransaction { txid } => { + write!(f, "Transaction can't be replaced with txid: {}", txid) } - Self::TransactionConfirmed => write!(f, "Transaction already confirmed"), - Self::IrreplaceableTransaction => write!(f, "Transaction can't be replaced"), Self::FeeRateUnavailable => write!(f, "Fee rate unavailable"), } } diff --git a/crates/bdk/src/wallet/mod.rs b/crates/bdk/src/wallet/mod.rs index d32ba5d694..fb207a8799 100644 --- a/crates/bdk/src/wallet/mod.rs +++ b/crates/bdk/src/wallet/mod.rs @@ -1291,14 +1291,14 @@ impl Wallet { let mut tx = graph .get_tx(txid) - .ok_or(BuildFeeBumpError::TransactionNotFound)? + .ok_or(BuildFeeBumpError::TransactionNotFound { txid })? .clone(); let pos = graph .get_chain_position(&self.chain, chain_tip, txid) - .ok_or(BuildFeeBumpError::TransactionNotFound)?; + .ok_or(BuildFeeBumpError::TransactionNotFound { txid })?; if let ChainPosition::Confirmed(_) = pos { - return Err(BuildFeeBumpError::TransactionConfirmed); + return Err(BuildFeeBumpError::TransactionConfirmed { txid }); } if !tx @@ -1306,7 +1306,7 @@ impl Wallet { .iter() .any(|txin| txin.sequence.to_consensus_u32() <= 0xFFFFFFFD) { - return Err(BuildFeeBumpError::IrreplaceableTransaction); + return Err(BuildFeeBumpError::IrreplaceableTransaction { txid: tx.txid() }); } let fee = self @@ -1321,14 +1321,18 @@ impl Wallet { let original_utxos = original_txin .iter() .map(|txin| -> Result<_, BuildFeeBumpError> { - let prev_tx = graph - .get_tx(txin.previous_output.txid) - .ok_or(BuildFeeBumpError::UnknownUtxo)?; + let prev_tx = graph.get_tx(txin.previous_output.txid).ok_or( + BuildFeeBumpError::UnknownUtxo { + outpoint: txin.previous_output, + }, + )?; let txout = &prev_tx.output[txin.previous_output.vout as usize]; let confirmation_time: ConfirmationTime = graph .get_chain_position(&self.chain, chain_tip, txin.previous_output.txid) - .ok_or(BuildFeeBumpError::UnknownUtxo)? + .ok_or(BuildFeeBumpError::UnknownUtxo { + outpoint: txin.previous_output, + })? .cloned() .into();