refactor(error): alias types from external crates
This commit is contained in:
parent
330dc96b8a
commit
b7fe91b003
@ -25,6 +25,11 @@ use bdk::chain;
|
|||||||
use bdk::wallet::error::CreateTxError as BdkCreateTxError;
|
use bdk::wallet::error::CreateTxError as BdkCreateTxError;
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
|
use bdk::bitcoin::address::Error as BdkAddressError;
|
||||||
|
use bdk::bitcoin::consensus::encode::Error as BdkEncodeError;
|
||||||
|
use bdk::bitcoin::psbt::ExtractTxError as BdkExtractTxError;
|
||||||
|
use chain::local_chain::CannotConnectError as BdkCannotConnectError;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// error definitions
|
// error definitions
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
@ -440,21 +445,19 @@ pub enum WalletCreationError {
|
|||||||
// error conversions
|
// error conversions
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
impl From<bdk::bitcoin::address::Error> for AddressError {
|
impl From<BdkAddressError> for AddressError {
|
||||||
fn from(error: bdk::bitcoin::address::Error) -> Self {
|
fn from(error: BdkAddressError) -> Self {
|
||||||
match error {
|
match error {
|
||||||
bdk::bitcoin::address::Error::WitnessVersion(error_message) => {
|
BdkAddressError::WitnessVersion(error_message) => AddressError::WitnessVersion {
|
||||||
AddressError::WitnessVersion {
|
error_message: error_message.to_string(),
|
||||||
error_message: error_message.to_string(),
|
},
|
||||||
}
|
BdkAddressError::WitnessProgram(e) => AddressError::WitnessProgram {
|
||||||
}
|
|
||||||
bdk::bitcoin::address::Error::WitnessProgram(e) => AddressError::WitnessProgram {
|
|
||||||
error_message: e.to_string(),
|
error_message: e.to_string(),
|
||||||
},
|
},
|
||||||
bdk::bitcoin::address::Error::UncompressedPubkey => AddressError::UncompressedPubkey,
|
BdkAddressError::UncompressedPubkey => AddressError::UncompressedPubkey,
|
||||||
bdk::bitcoin::address::Error::ExcessiveScriptSize => AddressError::ExcessiveScriptSize,
|
BdkAddressError::ExcessiveScriptSize => AddressError::ExcessiveScriptSize,
|
||||||
bdk::bitcoin::address::Error::UnrecognizedScript => AddressError::UnrecognizedScript,
|
BdkAddressError::UnrecognizedScript => AddressError::UnrecognizedScript,
|
||||||
bdk::bitcoin::address::Error::NetworkValidation {
|
BdkAddressError::NetworkValidation {
|
||||||
required,
|
required,
|
||||||
found,
|
found,
|
||||||
address,
|
address,
|
||||||
@ -549,8 +552,8 @@ impl From<BdkCalculateFeeError> for CalculateFeeError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<chain::local_chain::CannotConnectError> for CannotConnectError {
|
impl From<BdkCannotConnectError> for CannotConnectError {
|
||||||
fn from(error: chain::local_chain::CannotConnectError) -> Self {
|
fn from(error: BdkCannotConnectError) -> Self {
|
||||||
CannotConnectError::Include {
|
CannotConnectError::Include {
|
||||||
height: error.try_include_height,
|
height: error.try_include_height,
|
||||||
}
|
}
|
||||||
@ -702,8 +705,8 @@ impl From<BdkDescriptorKeyParseError> for DescriptorKeyError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<bdk::bitcoin::bip32::Error> for DescriptorKeyError {
|
impl From<BdkBip32Error> for DescriptorKeyError {
|
||||||
fn from(error: bdk::bitcoin::bip32::Error) -> DescriptorKeyError {
|
fn from(error: BdkBip32Error) -> DescriptorKeyError {
|
||||||
DescriptorKeyError::Bip32 {
|
DescriptorKeyError::Bip32 {
|
||||||
error_message: format!("BIP32 derivation error: {:?}", error),
|
error_message: format!("BIP32 derivation error: {:?}", error),
|
||||||
}
|
}
|
||||||
@ -748,21 +751,17 @@ impl From<BdkEsploraError> for EsploraError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<bdk::bitcoin::psbt::ExtractTxError> for ExtractTxError {
|
impl From<BdkExtractTxError> for ExtractTxError {
|
||||||
fn from(error: bdk::bitcoin::psbt::ExtractTxError) -> Self {
|
fn from(error: BdkExtractTxError) -> Self {
|
||||||
match error {
|
match error {
|
||||||
bdk::bitcoin::psbt::ExtractTxError::AbsurdFeeRate { fee_rate, .. } => {
|
BdkExtractTxError::AbsurdFeeRate { fee_rate, .. } => {
|
||||||
let sat_per_vbyte = fee_rate.to_sat_per_vb_ceil();
|
let sat_per_vbyte = fee_rate.to_sat_per_vb_ceil();
|
||||||
ExtractTxError::AbsurdFeeRate {
|
ExtractTxError::AbsurdFeeRate {
|
||||||
fee_rate: sat_per_vbyte,
|
fee_rate: sat_per_vbyte,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bdk::bitcoin::psbt::ExtractTxError::MissingInputValue { .. } => {
|
BdkExtractTxError::MissingInputValue { .. } => ExtractTxError::MissingInputValue,
|
||||||
ExtractTxError::MissingInputValue
|
BdkExtractTxError::SendingTooMuch { .. } => ExtractTxError::SendingTooMuch,
|
||||||
}
|
|
||||||
bdk::bitcoin::psbt::ExtractTxError::SendingTooMuch { .. } => {
|
|
||||||
ExtractTxError::SendingTooMuch
|
|
||||||
}
|
|
||||||
_ => ExtractTxError::OtherExtractTxErr,
|
_ => ExtractTxError::OtherExtractTxErr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -817,24 +816,22 @@ impl From<BdkSignerError> for SignerError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<bdk::bitcoin::consensus::encode::Error> for TransactionError {
|
impl From<BdkEncodeError> for TransactionError {
|
||||||
fn from(error: bdk::bitcoin::consensus::encode::Error) -> Self {
|
fn from(error: BdkEncodeError) -> Self {
|
||||||
match error {
|
match error {
|
||||||
bdk::bitcoin::consensus::encode::Error::Io(_) => TransactionError::Io,
|
BdkEncodeError::Io(_) => TransactionError::Io,
|
||||||
bdk::bitcoin::consensus::encode::Error::OversizedVectorAllocation { .. } => {
|
BdkEncodeError::OversizedVectorAllocation { .. } => {
|
||||||
TransactionError::OversizedVectorAllocation
|
TransactionError::OversizedVectorAllocation
|
||||||
}
|
}
|
||||||
bdk::bitcoin::consensus::encode::Error::InvalidChecksum { expected, actual } => {
|
BdkEncodeError::InvalidChecksum { expected, actual } => {
|
||||||
TransactionError::InvalidChecksum {
|
TransactionError::InvalidChecksum {
|
||||||
expected: DisplayHex::to_lower_hex_string(&expected),
|
expected: DisplayHex::to_lower_hex_string(&expected),
|
||||||
actual: DisplayHex::to_lower_hex_string(&actual),
|
actual: DisplayHex::to_lower_hex_string(&actual),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bdk::bitcoin::consensus::encode::Error::NonMinimalVarInt => {
|
BdkEncodeError::NonMinimalVarInt => TransactionError::NonMinimalVarInt,
|
||||||
TransactionError::NonMinimalVarInt
|
BdkEncodeError::ParseFailed(_) => TransactionError::ParseFailed,
|
||||||
}
|
BdkEncodeError::UnsupportedSegwitFlag(flag) => {
|
||||||
bdk::bitcoin::consensus::encode::Error::ParseFailed(_) => TransactionError::ParseFailed,
|
|
||||||
bdk::bitcoin::consensus::encode::Error::UnsupportedSegwitFlag(flag) => {
|
|
||||||
TransactionError::UnsupportedSegwitFlag { flag }
|
TransactionError::UnsupportedSegwitFlag { flag }
|
||||||
}
|
}
|
||||||
_ => TransactionError::OtherTransactionErr,
|
_ => TransactionError::OtherTransactionErr,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user