diff --git a/payjoin-ffi/csharp/UnitTests.cs b/payjoin-ffi/csharp/UnitTests.cs index 655286fa5..6a801d179 100644 --- a/payjoin-ffi/csharp/UnitTests.cs +++ b/payjoin-ffi/csharp/UnitTests.cs @@ -283,7 +283,7 @@ public void ReceiverBuilderRejectsBadAddress() { var ohttpKeys = OhttpKeys.Decode(OhttpKeysData); - Assert.Throws(() => + Assert.Throws(() => { new ReceiverBuilder("not-an-address", "https://example.com", ohttpKeys); }); diff --git a/payjoin-ffi/python/test/test_payjoin_unit_test.py b/payjoin-ffi/python/test/test_payjoin_unit_test.py index 61b5c0780..fa3daffa3 100644 --- a/payjoin-ffi/python/test/test_payjoin_unit_test.py +++ b/payjoin-ffi/python/test/test_payjoin_unit_test.py @@ -269,7 +269,7 @@ async def run_test(): class TestValidation(unittest.TestCase): def test_receiver_builder_rejects_bad_address(self): - with self.assertRaises(cast(type[Exception], payjoin.ReceiverBuilderError)): + with self.assertRaises(cast(type[Exception], payjoin.BuildReceiverError)): payjoin.ReceiverBuilder( "not-an-address", "https://example.com", diff --git a/payjoin-ffi/src/receive/error.rs b/payjoin-ffi/src/receive/error.rs index 88a6a5d42..a04c2dfe9 100644 --- a/payjoin-ffi/src/receive/error.rs +++ b/payjoin-ffi/src/receive/error.rs @@ -122,7 +122,7 @@ impl_persisted_error_from!(payjoin::IntoUrlError, |api_err: payjoin::IntoUrlErro /// Error that may occur when building a receiver session. #[derive(Debug, thiserror::Error, uniffi::Error)] #[non_exhaustive] -pub enum ReceiverBuilderError { +pub enum BuildReceiverError { /// The provided Bitcoin address is invalid. #[error("Invalid Bitcoin address: {0}")] InvalidAddress(Arc), @@ -131,15 +131,15 @@ pub enum ReceiverBuilderError { IntoUrl(Arc), } -impl From for ReceiverBuilderError { +impl From for BuildReceiverError { fn from(value: payjoin::IntoUrlError) -> Self { - ReceiverBuilderError::IntoUrl(Arc::new(value.into())) + BuildReceiverError::IntoUrl(Arc::new(value.into())) } } -impl From for ReceiverBuilderError { +impl From for BuildReceiverError { fn from(value: payjoin::bitcoin::address::ParseError) -> Self { - ReceiverBuilderError::InvalidAddress(Arc::new(value.into())) + BuildReceiverError::InvalidAddress(Arc::new(value.into())) } } diff --git a/payjoin-ffi/src/receive/mod.rs b/payjoin-ffi/src/receive/mod.rs index 9daa240d5..7708bb033 100644 --- a/payjoin-ffi/src/receive/mod.rs +++ b/payjoin-ffi/src/receive/mod.rs @@ -2,8 +2,8 @@ use std::str::FromStr; use std::sync::{Arc, RwLock}; pub use error::{ - AddressParseError, CoinSelectionError, InputContributionError, InputPairError, JsonReply, - OutputSubstitutionError, ProtocolError, PsbtInputError, ReceiverBuilderError, + AddressParseError, BuildReceiverError, CoinSelectionError, InputContributionError, + InputPairError, JsonReply, OutputSubstitutionError, ProtocolError, PsbtInputError, ReceiverCreateRequestError, ReceiverError, SessionError, }; use payjoin::bitcoin::consensus::Decodable; @@ -541,9 +541,9 @@ impl ReceiverBuilder { address: String, directory: String, ohttp_keys: Arc, - ) -> Result { + ) -> Result { let parsed_address = payjoin::bitcoin::Address::from_str(address.as_str()) - .map_err(ReceiverBuilderError::from)? + .map_err(BuildReceiverError::from)? .assume_checked(); Ok(Self( payjoin::receive::v2::ReceiverBuilder::new( @@ -551,7 +551,7 @@ impl ReceiverBuilder { directory, Arc::unwrap_or_clone(ohttp_keys).into(), ) - .map_err(ReceiverBuilderError::from)?, + .map_err(BuildReceiverError::from)?, )) } diff --git a/payjoin-ffi/src/send/error.rs b/payjoin-ffi/src/send/error.rs index 0685a34b4..d02b558b7 100644 --- a/payjoin-ffi/src/send/error.rs +++ b/payjoin-ffi/src/send/error.rs @@ -11,16 +11,16 @@ use crate::error::{FfiValidationError, ImplementationError}; #[derive(Debug, PartialEq, Eq, thiserror::Error, uniffi::Object)] #[uniffi::export(Debug, Display, Eq)] #[error("Error initializing the sender: {msg}")] -pub struct SenderBuilderError { +pub struct BuildSenderError { msg: String, } -impl From for SenderBuilderError { - fn from(value: PsbtParseError) -> Self { SenderBuilderError { msg: value.to_string() } } +impl From for BuildSenderError { + fn from(value: PsbtParseError) -> Self { BuildSenderError { msg: value.to_string() } } } -impl From for SenderBuilderError { - fn from(value: send::BuildSenderError) -> Self { SenderBuilderError { msg: value.to_string() } } +impl From for BuildSenderError { + fn from(value: send::BuildSenderError) -> Self { BuildSenderError { msg: value.to_string() } } } /// FFI-visible PSBT parsing error surfaced at the sender boundary. @@ -41,7 +41,7 @@ pub enum SenderInputError { #[error(transparent)] Psbt(PsbtParseError), #[error(transparent)] - Build(Arc), + Build(Arc), #[error(transparent)] FfiValidation(FfiValidationError), } @@ -189,7 +189,7 @@ pub enum SenderError { Response(ResponseError), /// Sender Build error #[error(transparent)] - Build(Arc), + BuildSender(Arc), /// Unexpected error #[error("An unexpected error occurred")] Unexpected, @@ -258,7 +258,7 @@ impl_sender_persisted_error_from!(send::ResponseError, |api_err: send::ResponseE }); impl_sender_persisted_error_from!(send::BuildSenderError, |api_err: send::BuildSenderError| { - SenderError::Build(Arc::new(api_err.into())) + SenderError::BuildSender(Arc::new(api_err.into())) }); #[cfg(test)] diff --git a/payjoin-ffi/src/send/mod.rs b/payjoin-ffi/src/send/mod.rs index 53e4739aa..78b927b20 100644 --- a/payjoin-ffi/src/send/mod.rs +++ b/payjoin-ffi/src/send/mod.rs @@ -2,7 +2,7 @@ use std::str::FromStr; use std::sync::{Arc, RwLock}; pub use error::{ - CreateRequestError, DecapsulationError, PsbtParseError, ResponseError, SenderBuilderError, + BuildSenderError, CreateRequestError, DecapsulationError, PsbtParseError, ResponseError, SenderInputError, };