From 8ce91ab3f69ff97a74cc012cb14cbab073a84a84 Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 26 Jun 2025 16:57:57 -0500 Subject: [PATCH 01/17] refactor: use macros for `FeeRateError` --- bdk-ffi/src/bdk.udl | 4 ---- bdk-ffi/src/error.rs | 4 ++-- bdk-ffi/src/lib.rs | 1 - 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/bdk-ffi/src/bdk.udl b/bdk-ffi/src/bdk.udl index 5edb5c87..c24ef5e0 100644 --- a/bdk-ffi/src/bdk.udl +++ b/bdk-ffi/src/bdk.udl @@ -131,10 +131,6 @@ interface EsploraError { InvalidResponse(); }; -[Error] -interface FeeRateError { - ArithmeticOverflow(); -}; [Error] interface FromScriptError { diff --git a/bdk-ffi/src/error.rs b/bdk-ffi/src/error.rs index 649e5d43..f25c0dad 100644 --- a/bdk-ffi/src/error.rs +++ b/bdk-ffi/src/error.rs @@ -386,9 +386,9 @@ pub enum ExtractTxError { )] OtherExtractTxErr, } -#[derive(Debug, thiserror::Error)] +#[derive(Debug, thiserror::Error, uniffi::Error)] pub enum FeeRateError { - #[error("arithmetic overflow on feerate")] + #[error("arithmetic overflow")] ArithmeticOverflow, } diff --git a/bdk-ffi/src/lib.rs b/bdk-ffi/src/lib.rs index 3597fc9c..72ddcf33 100644 --- a/bdk-ffi/src/lib.rs +++ b/bdk-ffi/src/lib.rs @@ -21,7 +21,6 @@ use crate::error::DescriptorError; use crate::error::DescriptorKeyError; use crate::error::ElectrumError; use crate::error::EsploraError; -use crate::error::FeeRateError; use crate::error::FromScriptError; use crate::error::MiniscriptError; use crate::error::ParseAmountError; From e68324354d1539b597ab3ebaeb819490c76ae639 Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 26 Jun 2025 17:05:38 -0500 Subject: [PATCH 02/17] refactor: use macros for `PersistenceError` --- bdk-ffi/src/bdk.udl | 4 ---- bdk-ffi/src/error.rs | 2 +- bdk-ffi/src/lib.rs | 1 - 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/bdk-ffi/src/bdk.udl b/bdk-ffi/src/bdk.udl index c24ef5e0..d8e5957f 100644 --- a/bdk-ffi/src/bdk.udl +++ b/bdk-ffi/src/bdk.udl @@ -191,10 +191,6 @@ interface ParseAmountError { OtherParseAmountErr(); }; -[Error] -interface PersistenceError { - Reason(string error_message); -}; [Error] interface PsbtError { diff --git a/bdk-ffi/src/error.rs b/bdk-ffi/src/error.rs index f25c0dad..77100475 100644 --- a/bdk-ffi/src/error.rs +++ b/bdk-ffi/src/error.rs @@ -562,7 +562,7 @@ pub enum ParseAmountError { OtherParseAmountErr, } -#[derive(Debug, thiserror::Error)] +#[derive(Debug, thiserror::Error, uniffi::Error)] pub enum PersistenceError { #[error("persistence error: {error_message}")] Reason { error_message: String }, diff --git a/bdk-ffi/src/lib.rs b/bdk-ffi/src/lib.rs index 72ddcf33..c7603bcb 100644 --- a/bdk-ffi/src/lib.rs +++ b/bdk-ffi/src/lib.rs @@ -24,7 +24,6 @@ use crate::error::EsploraError; use crate::error::FromScriptError; use crate::error::MiniscriptError; use crate::error::ParseAmountError; -use crate::error::PersistenceError; use crate::error::PsbtError; use crate::error::PsbtFinalizeError; use crate::error::PsbtParseError; From afefc76eb4577e143099f43b3b813e9cd893d193 Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 26 Jun 2025 17:08:29 -0500 Subject: [PATCH 03/17] refactor: use macros for `FromScriptError` --- bdk-ffi/src/bdk.udl | 7 ------- bdk-ffi/src/error.rs | 2 +- bdk-ffi/src/lib.rs | 1 - 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/bdk-ffi/src/bdk.udl b/bdk-ffi/src/bdk.udl index d8e5957f..94954b33 100644 --- a/bdk-ffi/src/bdk.udl +++ b/bdk-ffi/src/bdk.udl @@ -132,13 +132,6 @@ interface EsploraError { }; -[Error] -interface FromScriptError { - UnrecognizedScript(); - WitnessProgram(string error_message); - WitnessVersion(string error_message); - OtherFromScriptErr(); -}; [Error] interface MiniscriptError { diff --git a/bdk-ffi/src/error.rs b/bdk-ffi/src/error.rs index 77100475..ebf6832c 100644 --- a/bdk-ffi/src/error.rs +++ b/bdk-ffi/src/error.rs @@ -392,7 +392,7 @@ pub enum FeeRateError { ArithmeticOverflow, } -#[derive(Debug, thiserror::Error)] +#[derive(Debug, thiserror::Error, uniffi::Error)] pub enum FromScriptError { #[error("script is not a p2pkh, p2sh or witness program")] UnrecognizedScript, diff --git a/bdk-ffi/src/lib.rs b/bdk-ffi/src/lib.rs index c7603bcb..69b52e58 100644 --- a/bdk-ffi/src/lib.rs +++ b/bdk-ffi/src/lib.rs @@ -21,7 +21,6 @@ use crate::error::DescriptorError; use crate::error::DescriptorKeyError; use crate::error::ElectrumError; use crate::error::EsploraError; -use crate::error::FromScriptError; use crate::error::MiniscriptError; use crate::error::ParseAmountError; use crate::error::PsbtError; From 7ee4bbf0b53671d3b9c187ef2f46fb097c9e3964 Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 26 Jun 2025 17:11:43 -0500 Subject: [PATCH 04/17] refactor: use macros for `PsbtParseError` --- bdk-ffi/src/bdk.udl | 5 ----- bdk-ffi/src/error.rs | 2 +- bdk-ffi/src/lib.rs | 1 - 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/bdk-ffi/src/bdk.udl b/bdk-ffi/src/bdk.udl index 94954b33..65e3e1fe 100644 --- a/bdk-ffi/src/bdk.udl +++ b/bdk-ffi/src/bdk.udl @@ -222,11 +222,6 @@ interface PsbtError { OtherPsbtErr(); }; -[Error] -interface PsbtParseError { - PsbtEncoding(string error_message); - Base64Encoding(string error_message); -}; [Error] interface PsbtFinalizeError { diff --git a/bdk-ffi/src/error.rs b/bdk-ffi/src/error.rs index ebf6832c..60c0ffcc 100644 --- a/bdk-ffi/src/error.rs +++ b/bdk-ffi/src/error.rs @@ -672,7 +672,7 @@ pub enum PsbtError { OtherPsbtErr, } -#[derive(Debug, thiserror::Error)] +#[derive(Debug, thiserror::Error, uniffi::Error)] pub enum PsbtParseError { #[error("error in internal psbt data structure: {error_message}")] PsbtEncoding { error_message: String }, diff --git a/bdk-ffi/src/lib.rs b/bdk-ffi/src/lib.rs index 69b52e58..2653c619 100644 --- a/bdk-ffi/src/lib.rs +++ b/bdk-ffi/src/lib.rs @@ -25,7 +25,6 @@ use crate::error::MiniscriptError; use crate::error::ParseAmountError; use crate::error::PsbtError; use crate::error::PsbtFinalizeError; -use crate::error::PsbtParseError; use crate::error::TransactionError; use bdk_wallet::bitcoin::Network; From a391b16c6c633f191c13e3c0325fee15597aed31 Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 26 Jun 2025 17:19:43 -0500 Subject: [PATCH 05/17] refactor: use macros for `Bip39Error` --- bdk-ffi/src/bdk.udl | 8 -------- bdk-ffi/src/error.rs | 2 +- bdk-ffi/src/lib.rs | 1 - 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/bdk-ffi/src/bdk.udl b/bdk-ffi/src/bdk.udl index 65e3e1fe..cdfe0d09 100644 --- a/bdk-ffi/src/bdk.udl +++ b/bdk-ffi/src/bdk.udl @@ -33,14 +33,6 @@ interface Bip32Error { UnknownError(string error_message); }; -[Error] -interface Bip39Error { - BadWordCount(u64 word_count); - UnknownWord(u64 index); - BadEntropyBitCount(u64 bit_count); - InvalidChecksum(); - AmbiguousLanguages(string languages); -}; [Error] interface CreateTxError { diff --git a/bdk-ffi/src/error.rs b/bdk-ffi/src/error.rs index 60c0ffcc..ec150226 100644 --- a/bdk-ffi/src/error.rs +++ b/bdk-ffi/src/error.rs @@ -103,7 +103,7 @@ pub enum Bip32Error { UnknownError { error_message: String }, } -#[derive(Debug, thiserror::Error)] +#[derive(Debug, thiserror::Error, uniffi::Error)] pub enum Bip39Error { #[error("the word count {word_count} is not supported")] BadWordCount { word_count: u64 }, diff --git a/bdk-ffi/src/lib.rs b/bdk-ffi/src/lib.rs index 2653c619..22443d87 100644 --- a/bdk-ffi/src/lib.rs +++ b/bdk-ffi/src/lib.rs @@ -15,7 +15,6 @@ use crate::bitcoin::FeeRate; use crate::bitcoin::OutPoint; use crate::error::AddressParseError; use crate::error::Bip32Error; -use crate::error::Bip39Error; use crate::error::CreateTxError; use crate::error::DescriptorError; use crate::error::DescriptorKeyError; From 742bb32523afc402a5012c8b6c8f82c6f57bdc8b Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 26 Jun 2025 17:22:12 -0500 Subject: [PATCH 06/17] refactor: use macros for `DescriptorKeyError` --- bdk-ffi/src/bdk.udl | 6 ------ bdk-ffi/src/error.rs | 2 +- bdk-ffi/src/lib.rs | 1 - 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/bdk-ffi/src/bdk.udl b/bdk-ffi/src/bdk.udl index cdfe0d09..f5790af2 100644 --- a/bdk-ffi/src/bdk.udl +++ b/bdk-ffi/src/bdk.udl @@ -77,12 +77,6 @@ interface DescriptorError { ExternalAndInternalAreTheSame(); }; -[Error] -interface DescriptorKeyError { - Parse(string error_message); - InvalidKeyType(); - Bip32(string error_message); -}; [Error] interface ElectrumError { diff --git a/bdk-ffi/src/error.rs b/bdk-ffi/src/error.rs index ec150226..ee9f933c 100644 --- a/bdk-ffi/src/error.rs +++ b/bdk-ffi/src/error.rs @@ -259,7 +259,7 @@ pub enum DescriptorError { ExternalAndInternalAreTheSame, } -#[derive(Debug, thiserror::Error)] +#[derive(Debug, thiserror::Error, uniffi::Error)] pub enum DescriptorKeyError { #[error("error parsing descriptor key: {error_message}")] Parse { error_message: String }, diff --git a/bdk-ffi/src/lib.rs b/bdk-ffi/src/lib.rs index 22443d87..e1130e31 100644 --- a/bdk-ffi/src/lib.rs +++ b/bdk-ffi/src/lib.rs @@ -17,7 +17,6 @@ use crate::error::AddressParseError; use crate::error::Bip32Error; use crate::error::CreateTxError; use crate::error::DescriptorError; -use crate::error::DescriptorKeyError; use crate::error::ElectrumError; use crate::error::EsploraError; use crate::error::MiniscriptError; From 3fdd2a532dae2ce2d8c91a932dd69d83bb812390 Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 26 Jun 2025 17:24:38 -0500 Subject: [PATCH 07/17] refactor: use macros for `ParseAmountError` --- bdk-ffi/src/bdk.udl | 9 --------- bdk-ffi/src/error.rs | 2 +- bdk-ffi/src/lib.rs | 1 - 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/bdk-ffi/src/bdk.udl b/bdk-ffi/src/bdk.udl index f5790af2..1348c060 100644 --- a/bdk-ffi/src/bdk.udl +++ b/bdk-ffi/src/bdk.udl @@ -160,15 +160,6 @@ interface MiniscriptError { Unprintable(u8 byte); }; -[Error] -interface ParseAmountError { - OutOfRange(); - TooPrecise(); - MissingDigits(); - InputTooLarge(); - InvalidCharacter(string error_message); - OtherParseAmountErr(); -}; [Error] diff --git a/bdk-ffi/src/error.rs b/bdk-ffi/src/error.rs index ee9f933c..8fcec3f4 100644 --- a/bdk-ffi/src/error.rs +++ b/bdk-ffi/src/error.rs @@ -540,7 +540,7 @@ pub enum MiniscriptError { Unprintable { byte: u8 }, } -#[derive(Debug, thiserror::Error)] +#[derive(Debug, thiserror::Error, uniffi::Error)] pub enum ParseAmountError { #[error("amount out of range")] OutOfRange, diff --git a/bdk-ffi/src/lib.rs b/bdk-ffi/src/lib.rs index e1130e31..daa01d3a 100644 --- a/bdk-ffi/src/lib.rs +++ b/bdk-ffi/src/lib.rs @@ -20,7 +20,6 @@ use crate::error::DescriptorError; use crate::error::ElectrumError; use crate::error::EsploraError; use crate::error::MiniscriptError; -use crate::error::ParseAmountError; use crate::error::PsbtError; use crate::error::PsbtFinalizeError; use crate::error::TransactionError; From eafa8ae4b035585a39291db93169f4c1b4ea7136 Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 26 Jun 2025 17:28:04 -0500 Subject: [PATCH 08/17] refactor: use macros for `CreateTxError` --- bdk-ffi/src/bdk.udl | 25 ------------------------- bdk-ffi/src/error.rs | 2 +- bdk-ffi/src/lib.rs | 1 - 3 files changed, 1 insertion(+), 27 deletions(-) diff --git a/bdk-ffi/src/bdk.udl b/bdk-ffi/src/bdk.udl index 1348c060..31515072 100644 --- a/bdk-ffi/src/bdk.udl +++ b/bdk-ffi/src/bdk.udl @@ -34,31 +34,6 @@ interface Bip32Error { }; -[Error] -interface CreateTxError { - Descriptor(string error_message); - Policy(string error_message); - SpendingPolicyRequired(string kind); - Version0(); - Version1Csv(); - LockTime(string requested, string required); - RbfSequenceCsv(string sequence, string csv); - FeeTooLow(string required); - FeeRateTooLow(string required); - NoUtxosSelected(); - OutputBelowDustLimit(u64 index); - ChangePolicyDescriptor(); - CoinSelection(string error_message); - InsufficientFunds(u64 needed, u64 available); - NoRecipients(); - Psbt(string error_message); - MissingKeyOrigin(string key); - UnknownUtxo(string outpoint); - MissingNonWitnessUtxo(string outpoint); - MiniscriptPsbt(string error_message); - PushBytesError(); - LockTimeConversionError(); -}; [Error] interface DescriptorError { diff --git a/bdk-ffi/src/error.rs b/bdk-ffi/src/error.rs index 8fcec3f4..ed7c7a26 100644 --- a/bdk-ffi/src/error.rs +++ b/bdk-ffi/src/error.rs @@ -136,7 +136,7 @@ pub enum CannotConnectError { Include { height: u32 }, } -#[derive(Debug, thiserror::Error)] +#[derive(Debug, thiserror::Error, uniffi::Error)] pub enum CreateTxError { #[error("descriptor error: {error_message}")] Descriptor { error_message: String }, diff --git a/bdk-ffi/src/lib.rs b/bdk-ffi/src/lib.rs index daa01d3a..e0a681cc 100644 --- a/bdk-ffi/src/lib.rs +++ b/bdk-ffi/src/lib.rs @@ -15,7 +15,6 @@ use crate::bitcoin::FeeRate; use crate::bitcoin::OutPoint; use crate::error::AddressParseError; use crate::error::Bip32Error; -use crate::error::CreateTxError; use crate::error::DescriptorError; use crate::error::ElectrumError; use crate::error::EsploraError; From 3ae1c1103373a7006c5c8db404e1286ef44a8007 Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 26 Jun 2025 17:31:28 -0500 Subject: [PATCH 09/17] refactor: use macros for `PsbtError` --- bdk-ffi/src/bdk.udl | 36 ------------------------------------ bdk-ffi/src/error.rs | 2 +- bdk-ffi/src/lib.rs | 1 - 3 files changed, 1 insertion(+), 38 deletions(-) diff --git a/bdk-ffi/src/bdk.udl b/bdk-ffi/src/bdk.udl index 31515072..18770bbb 100644 --- a/bdk-ffi/src/bdk.udl +++ b/bdk-ffi/src/bdk.udl @@ -137,42 +137,6 @@ interface MiniscriptError { -[Error] -interface PsbtError { - InvalidMagic(); - MissingUtxo(); - InvalidSeparator(); - PsbtUtxoOutOfBounds(); - InvalidKey(string key); - InvalidProprietaryKey(); - DuplicateKey(string key); - UnsignedTxHasScriptSigs(); - UnsignedTxHasScriptWitnesses(); - MustHaveUnsignedTx(); - NoMorePairs(); - UnexpectedUnsignedTx(); - NonStandardSighashType(u32 sighash); - InvalidHash(string hash); - InvalidPreimageHashPair(); - CombineInconsistentKeySources(string xpub); - ConsensusEncoding(string encoding_error); - NegativeFee(); - FeeOverflow(); - InvalidPublicKey(string error_message); - InvalidSecp256k1PublicKey(string secp256k1_error); - InvalidXOnlyPublicKey(); - InvalidEcdsaSignature(string error_message); - InvalidTaprootSignature(string error_message); - InvalidControlBlock(); - InvalidLeafVersion(); - Taproot(); - TapTree(string error_message); - XPubKey(); - Version(string error_message); - PartialDataConsumption(); - Io(string error_message); - OtherPsbtErr(); -}; [Error] diff --git a/bdk-ffi/src/error.rs b/bdk-ffi/src/error.rs index ed7c7a26..c8cf21fe 100644 --- a/bdk-ffi/src/error.rs +++ b/bdk-ffi/src/error.rs @@ -568,7 +568,7 @@ pub enum PersistenceError { Reason { error_message: String }, } -#[derive(Debug, thiserror::Error)] +#[derive(Debug, thiserror::Error, uniffi::Error)] pub enum PsbtError { #[error("invalid magic")] InvalidMagic, diff --git a/bdk-ffi/src/lib.rs b/bdk-ffi/src/lib.rs index e0a681cc..aac7f0eb 100644 --- a/bdk-ffi/src/lib.rs +++ b/bdk-ffi/src/lib.rs @@ -19,7 +19,6 @@ use crate::error::DescriptorError; use crate::error::ElectrumError; use crate::error::EsploraError; use crate::error::MiniscriptError; -use crate::error::PsbtError; use crate::error::PsbtFinalizeError; use crate::error::TransactionError; From 6018284377117835907750b0786ef870be0f4bd3 Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 26 Jun 2025 17:35:09 -0500 Subject: [PATCH 10/17] refactor: use macros for `MiniscriptError` --- bdk-ffi/src/bdk.udl | 40 ---------------------------------------- bdk-ffi/src/error.rs | 2 +- bdk-ffi/src/lib.rs | 1 - 3 files changed, 1 insertion(+), 42 deletions(-) diff --git a/bdk-ffi/src/bdk.udl b/bdk-ffi/src/bdk.udl index 18770bbb..6ff6f0e9 100644 --- a/bdk-ffi/src/bdk.udl +++ b/bdk-ffi/src/bdk.udl @@ -94,46 +94,6 @@ interface EsploraError { -[Error] -interface MiniscriptError { - AbsoluteLockTime(); - AddrError(string error_message); - AddrP2shError(string error_message); - AnalysisError(string error_message); - AtOutsideOr(); - BadDescriptor(string error_message); - BareDescriptorAddr(); - CmsTooManyKeys(u32 keys); - ContextError(string error_message); - CouldNotSatisfy(); - ExpectedChar(string char); - ImpossibleSatisfaction(); - InvalidOpcode(); - InvalidPush(); - LiftError(string error_message); - MaxRecursiveDepthExceeded(); - MissingSig(); - MultiATooManyKeys(u64 keys); - MultiColon(); - MultipathDescLenMismatch(); - NonMinimalVerify(string error_message); - NonStandardBareScript(); - NonTopLevel(string error_message); - ParseThreshold(); - PolicyError(string error_message); - PubKeyCtxError(); - RelativeLockTime(); - Script(string error_message); - Secp(string error_message); - Threshold(); - TrNoScriptCode(); - Trailing(string error_message); - TypeCheck(string error_message); - Unexpected(string error_message); - UnexpectedStart(); - UnknownWrapper(string char); - Unprintable(u8 byte); -}; diff --git a/bdk-ffi/src/error.rs b/bdk-ffi/src/error.rs index c8cf21fe..ad316f47 100644 --- a/bdk-ffi/src/error.rs +++ b/bdk-ffi/src/error.rs @@ -426,7 +426,7 @@ pub enum LoadWithPersistError { CouldNotLoad, } -#[derive(Debug, thiserror::Error)] +#[derive(Debug, thiserror::Error, uniffi::Error)] pub enum MiniscriptError { #[error("absolute locktime error")] AbsoluteLockTime, diff --git a/bdk-ffi/src/lib.rs b/bdk-ffi/src/lib.rs index aac7f0eb..1c28dca5 100644 --- a/bdk-ffi/src/lib.rs +++ b/bdk-ffi/src/lib.rs @@ -18,7 +18,6 @@ use crate::error::Bip32Error; use crate::error::DescriptorError; use crate::error::ElectrumError; use crate::error::EsploraError; -use crate::error::MiniscriptError; use crate::error::PsbtFinalizeError; use crate::error::TransactionError; From 09ef58fdc50ae997692867d72e6967615652292d Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 26 Jun 2025 17:38:33 -0500 Subject: [PATCH 11/17] refactor: use macros for `AddressParseError` --- bdk-ffi/src/bdk.udl | 14 -------------- bdk-ffi/src/error.rs | 2 +- bdk-ffi/src/lib.rs | 2 +- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/bdk-ffi/src/bdk.udl b/bdk-ffi/src/bdk.udl index 6ff6f0e9..9c628d64 100644 --- a/bdk-ffi/src/bdk.udl +++ b/bdk-ffi/src/bdk.udl @@ -4,20 +4,6 @@ namespace bdk {}; // bdk crate - error module // ------------------------------------------------------------------------ -[Error] -interface AddressParseError { - Base58(); - Bech32(); - WitnessVersion(string error_message); - WitnessProgram(string error_message); - UnknownHrp(); - LegacyAddressTooLong(); - InvalidBase58PayloadLength(); - InvalidLegacyPrefix(); - NetworkValidation(); - OtherAddressParseErr(); -}; - [Error] interface Bip32Error { CannotDeriveFromHardenedKey(); diff --git a/bdk-ffi/src/error.rs b/bdk-ffi/src/error.rs index ad316f47..9bad20dd 100644 --- a/bdk-ffi/src/error.rs +++ b/bdk-ffi/src/error.rs @@ -33,7 +33,7 @@ use std::convert::TryInto; // error definitions // ------------------------------------------------------------------------ -#[derive(Debug, thiserror::Error)] +#[derive(Debug, thiserror::Error, uniffi::Error)] pub enum AddressParseError { #[error("base58 address encoding error")] Base58, diff --git a/bdk-ffi/src/lib.rs b/bdk-ffi/src/lib.rs index 1c28dca5..5c6eedac 100644 --- a/bdk-ffi/src/lib.rs +++ b/bdk-ffi/src/lib.rs @@ -13,7 +13,7 @@ mod wallet; use crate::bitcoin::FeeRate; use crate::bitcoin::OutPoint; -use crate::error::AddressParseError; +use crate::bitcoin::Script; use crate::error::Bip32Error; use crate::error::DescriptorError; use crate::error::ElectrumError; From 6ef7d8fe77e5c7baa3e3f547271c691921b15f2c Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 26 Jun 2025 17:41:03 -0500 Subject: [PATCH 12/17] refactor: use macros for `Bip32Error` --- bdk-ffi/src/bdk.udl | 17 ----------------- bdk-ffi/src/error.rs | 2 +- bdk-ffi/src/lib.rs | 1 - 3 files changed, 1 insertion(+), 19 deletions(-) diff --git a/bdk-ffi/src/bdk.udl b/bdk-ffi/src/bdk.udl index 9c628d64..cb49c8cf 100644 --- a/bdk-ffi/src/bdk.udl +++ b/bdk-ffi/src/bdk.udl @@ -4,23 +4,6 @@ namespace bdk {}; // bdk crate - error module // ------------------------------------------------------------------------ -[Error] -interface Bip32Error { - CannotDeriveFromHardenedKey(); - Secp256k1(string error_message); - InvalidChildNumber(u32 child_number); - InvalidChildNumberFormat(); - InvalidDerivationPathFormat(); - UnknownVersion(string version); - WrongExtendedKeyLength(u32 length); - Base58(string error_message); - Hex(string error_message); - InvalidPublicKeyHexLength(u32 length); - UnknownError(string error_message); -}; - - - [Error] interface DescriptorError { InvalidHdKeyPath(); diff --git a/bdk-ffi/src/error.rs b/bdk-ffi/src/error.rs index 9bad20dd..8e923fb4 100644 --- a/bdk-ffi/src/error.rs +++ b/bdk-ffi/src/error.rs @@ -67,7 +67,7 @@ pub enum AddressParseError { OtherAddressParseErr, } -#[derive(Debug, thiserror::Error)] +#[derive(Debug, thiserror::Error, uniffi::Error)] pub enum Bip32Error { #[error("cannot derive from a hardened key")] CannotDeriveFromHardenedKey, diff --git a/bdk-ffi/src/lib.rs b/bdk-ffi/src/lib.rs index 5c6eedac..8ae3247c 100644 --- a/bdk-ffi/src/lib.rs +++ b/bdk-ffi/src/lib.rs @@ -14,7 +14,6 @@ mod wallet; use crate::bitcoin::FeeRate; use crate::bitcoin::OutPoint; use crate::bitcoin::Script; -use crate::error::Bip32Error; use crate::error::DescriptorError; use crate::error::ElectrumError; use crate::error::EsploraError; From 1c4eec1eff9fa34a932c66df0783cef45d491f8a Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 26 Jun 2025 17:43:37 -0500 Subject: [PATCH 13/17] refactor: use macros for `DescriptorError` --- bdk-ffi/src/bdk.udl | 18 ------------------ bdk-ffi/src/error.rs | 2 +- bdk-ffi/src/lib.rs | 1 - 3 files changed, 1 insertion(+), 20 deletions(-) diff --git a/bdk-ffi/src/bdk.udl b/bdk-ffi/src/bdk.udl index cb49c8cf..55c780ff 100644 --- a/bdk-ffi/src/bdk.udl +++ b/bdk-ffi/src/bdk.udl @@ -4,24 +4,6 @@ namespace bdk {}; // bdk crate - error module // ------------------------------------------------------------------------ -[Error] -interface DescriptorError { - InvalidHdKeyPath(); - InvalidDescriptorChecksum(); - HardenedDerivationXpub(); - MultiPath(); - Key(string error_message); - Policy(string error_message); - InvalidDescriptorCharacter(string char); - Bip32(string error_message); - Base58(string error_message); - Pk(string error_message); - Miniscript(string error_message); - Hex(string error_message); - ExternalAndInternalAreTheSame(); -}; - - [Error] interface ElectrumError { IOError(string error_message); diff --git a/bdk-ffi/src/error.rs b/bdk-ffi/src/error.rs index 8e923fb4..4965ea04 100644 --- a/bdk-ffi/src/error.rs +++ b/bdk-ffi/src/error.rs @@ -217,7 +217,7 @@ pub enum CreateWithPersistError { Descriptor { error_message: String }, } -#[derive(Debug, thiserror::Error)] +#[derive(Debug, thiserror::Error, uniffi::Error)] pub enum DescriptorError { #[error("invalid hd key path")] InvalidHdKeyPath, diff --git a/bdk-ffi/src/lib.rs b/bdk-ffi/src/lib.rs index 8ae3247c..404703fe 100644 --- a/bdk-ffi/src/lib.rs +++ b/bdk-ffi/src/lib.rs @@ -14,7 +14,6 @@ mod wallet; use crate::bitcoin::FeeRate; use crate::bitcoin::OutPoint; use crate::bitcoin::Script; -use crate::error::DescriptorError; use crate::error::ElectrumError; use crate::error::EsploraError; use crate::error::PsbtFinalizeError; From 1b30a60fcd8980b72c9a62013732319b6065f989 Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 26 Jun 2025 17:46:23 -0500 Subject: [PATCH 14/17] refactor: use macros for `ElectrumError` --- bdk-ffi/src/bdk.udl | 21 --------------------- bdk-ffi/src/error.rs | 2 +- bdk-ffi/src/lib.rs | 1 - 3 files changed, 1 insertion(+), 23 deletions(-) diff --git a/bdk-ffi/src/bdk.udl b/bdk-ffi/src/bdk.udl index 55c780ff..0a42c4f2 100644 --- a/bdk-ffi/src/bdk.udl +++ b/bdk-ffi/src/bdk.udl @@ -4,27 +4,6 @@ namespace bdk {}; // bdk crate - error module // ------------------------------------------------------------------------ -[Error] -interface ElectrumError { - IOError(string error_message); - Json(string error_message); - Hex(string error_message); - Protocol(string error_message); - Bitcoin(string error_message); - AlreadySubscribed(); - NotSubscribed(); - InvalidResponse(string error_message); - Message(string error_message); - InvalidDNSNameError(string domain); - MissingDomain(); - AllAttemptsErrored(); - SharedIOError(string error_message); - CouldntLockReader(); - Mpsc(); - CouldNotCreateConnection(string error_message); - RequestAlreadyConsumed(); -}; - [Error] interface EsploraError { Minreq(string error_message); diff --git a/bdk-ffi/src/error.rs b/bdk-ffi/src/error.rs index 4965ea04..40e69b03 100644 --- a/bdk-ffi/src/error.rs +++ b/bdk-ffi/src/error.rs @@ -271,7 +271,7 @@ pub enum DescriptorKeyError { Bip32 { error_message: String }, } -#[derive(Debug, thiserror::Error)] +#[derive(Debug, thiserror::Error, uniffi::Error)] pub enum ElectrumError { #[error("{error_message}")] IOError { error_message: String }, diff --git a/bdk-ffi/src/lib.rs b/bdk-ffi/src/lib.rs index 404703fe..b2c5221f 100644 --- a/bdk-ffi/src/lib.rs +++ b/bdk-ffi/src/lib.rs @@ -14,7 +14,6 @@ mod wallet; use crate::bitcoin::FeeRate; use crate::bitcoin::OutPoint; use crate::bitcoin::Script; -use crate::error::ElectrumError; use crate::error::EsploraError; use crate::error::PsbtFinalizeError; use crate::error::TransactionError; From 61e161086e982b16c8666f1cc85de0f2ed47cedc Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 26 Jun 2025 17:49:47 -0500 Subject: [PATCH 15/17] refactor: use macros for `EsploraError` --- bdk-ffi/src/bdk.udl | 25 ------------------------- bdk-ffi/src/error.rs | 2 +- bdk-ffi/src/lib.rs | 1 - 3 files changed, 1 insertion(+), 27 deletions(-) diff --git a/bdk-ffi/src/bdk.udl b/bdk-ffi/src/bdk.udl index 0a42c4f2..4c1fe3d5 100644 --- a/bdk-ffi/src/bdk.udl +++ b/bdk-ffi/src/bdk.udl @@ -4,31 +4,6 @@ namespace bdk {}; // bdk crate - error module // ------------------------------------------------------------------------ -[Error] -interface EsploraError { - Minreq(string error_message); - HttpResponse(u16 status, string error_message); - Parsing(string error_message); - StatusCode(string error_message); - BitcoinEncoding(string error_message); - HexToArray(string error_message); - HexToBytes(string error_message); - TransactionNotFound(); - HeaderHeightNotFound(u32 height); - HeaderHashNotFound(); - InvalidHttpHeaderName(string name); - InvalidHttpHeaderValue(string value); - RequestAlreadyConsumed(); - InvalidResponse(); -}; - - - - - - - - [Error] interface PsbtFinalizeError { InputError(string reason, u32 index); diff --git a/bdk-ffi/src/error.rs b/bdk-ffi/src/error.rs index 40e69b03..e1498a9e 100644 --- a/bdk-ffi/src/error.rs +++ b/bdk-ffi/src/error.rs @@ -325,7 +325,7 @@ pub enum ElectrumError { RequestAlreadyConsumed, } -#[derive(Debug, thiserror::Error)] +#[derive(Debug, thiserror::Error, uniffi::Error)] pub enum EsploraError { #[error("minreq error: {error_message}")] Minreq { error_message: String }, diff --git a/bdk-ffi/src/lib.rs b/bdk-ffi/src/lib.rs index b2c5221f..67d33ae5 100644 --- a/bdk-ffi/src/lib.rs +++ b/bdk-ffi/src/lib.rs @@ -14,7 +14,6 @@ mod wallet; use crate::bitcoin::FeeRate; use crate::bitcoin::OutPoint; use crate::bitcoin::Script; -use crate::error::EsploraError; use crate::error::PsbtFinalizeError; use crate::error::TransactionError; From 64c1fca855e80818cc6b73585914e0d5592ea456 Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 26 Jun 2025 17:52:43 -0500 Subject: [PATCH 16/17] refactor: use macros for PsbtFinalizeError --- bdk-ffi/src/bdk.udl | 7 ------- bdk-ffi/src/error.rs | 2 +- bdk-ffi/src/lib.rs | 1 - 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/bdk-ffi/src/bdk.udl b/bdk-ffi/src/bdk.udl index 4c1fe3d5..f4c82bdb 100644 --- a/bdk-ffi/src/bdk.udl +++ b/bdk-ffi/src/bdk.udl @@ -4,13 +4,6 @@ namespace bdk {}; // bdk crate - error module // ------------------------------------------------------------------------ -[Error] -interface PsbtFinalizeError { - InputError(string reason, u32 index); - WrongInputCount(u32 in_tx, u32 in_map); - InputIdxOutofBounds(u32 psbt_inp, u32 requested); -}; - [Error] interface TransactionError { Io(); diff --git a/bdk-ffi/src/error.rs b/bdk-ffi/src/error.rs index e1498a9e..53c26e31 100644 --- a/bdk-ffi/src/error.rs +++ b/bdk-ffi/src/error.rs @@ -681,7 +681,7 @@ pub enum PsbtParseError { Base64Encoding { error_message: String }, } -#[derive(Debug, thiserror::Error)] +#[derive(Debug, thiserror::Error, uniffi::Error)] pub enum PsbtFinalizeError { #[error("an input at index {index} is invalid: {reason}")] InputError { reason: String, index: u32 }, diff --git a/bdk-ffi/src/lib.rs b/bdk-ffi/src/lib.rs index 67d33ae5..1f94827e 100644 --- a/bdk-ffi/src/lib.rs +++ b/bdk-ffi/src/lib.rs @@ -14,7 +14,6 @@ mod wallet; use crate::bitcoin::FeeRate; use crate::bitcoin::OutPoint; use crate::bitcoin::Script; -use crate::error::PsbtFinalizeError; use crate::error::TransactionError; use bdk_wallet::bitcoin::Network; From b822dca9b0f1cd83142ff143b7067e9f4a813711 Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 26 Jun 2025 18:00:31 -0500 Subject: [PATCH 17/17] refactor: use macros for `TransactionError` --- bdk-ffi/src/bdk.udl | 11 ----------- bdk-ffi/src/error.rs | 2 +- bdk-ffi/src/lib.rs | 2 -- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/bdk-ffi/src/bdk.udl b/bdk-ffi/src/bdk.udl index f4c82bdb..793ea4cf 100644 --- a/bdk-ffi/src/bdk.udl +++ b/bdk-ffi/src/bdk.udl @@ -4,17 +4,6 @@ namespace bdk {}; // bdk crate - error module // ------------------------------------------------------------------------ -[Error] -interface TransactionError { - Io(); - OversizedVectorAllocation(); - InvalidChecksum(string expected, string actual); - NonMinimalVarInt(); - ParseFailed(); - UnsupportedSegwitFlag(u8 flag); - OtherTransactionErr(); -}; - // ------------------------------------------------------------------------ // bdk_wallet crate - types module // ------------------------------------------------------------------------ diff --git a/bdk-ffi/src/error.rs b/bdk-ffi/src/error.rs index 53c26e31..c02f16ce 100644 --- a/bdk-ffi/src/error.rs +++ b/bdk-ffi/src/error.rs @@ -745,7 +745,7 @@ pub enum SignerError { Psbt { error_message: String }, } -#[derive(Debug, thiserror::Error)] +#[derive(Debug, thiserror::Error, uniffi::Error)] pub enum TransactionError { #[error("io error")] Io, diff --git a/bdk-ffi/src/lib.rs b/bdk-ffi/src/lib.rs index 1f94827e..e92bd4db 100644 --- a/bdk-ffi/src/lib.rs +++ b/bdk-ffi/src/lib.rs @@ -13,8 +13,6 @@ mod wallet; use crate::bitcoin::FeeRate; use crate::bitcoin::OutPoint; -use crate::bitcoin::Script; -use crate::error::TransactionError; use bdk_wallet::bitcoin::Network;