Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions Cargo-minimal.lock
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,15 @@ dependencies = [
"url",
]

[[package]]
name = "bhttp"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d305a54bcb99974213b4c78a486c34091e83c5d6d6572f7f4331c904ea9d127"
dependencies = [
"thiserror 2.0.18",
]

[[package]]
name = "bip39"
version = "2.2.2"
Expand Down Expand Up @@ -2761,11 +2770,12 @@ checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3"
name = "payjoin"
version = "0.25.0"
dependencies = [
"bhttp",
"bhttp 0.7.2",
"bitcoin 0.32.8",
"bitcoin-hpke",
"bitcoin-ohttp",
"bitcoin_uri",
"getrandom 0.3.4",
"http",
"once_cell",
"payjoin-test-utils",
Expand Down Expand Up @@ -2850,7 +2860,7 @@ dependencies = [
"anyhow",
"axum",
"axum-server",
"bhttp",
"bhttp 0.6.1",
"bitcoin 0.32.8",
"bitcoin-ohttp",
"byteorder",
Expand Down
56 changes: 31 additions & 25 deletions Cargo-recent.lock
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,15 @@ dependencies = [
"url",
]

[[package]]
name = "bhttp"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d305a54bcb99974213b4c78a486c34091e83c5d6d6572f7f4331c904ea9d127"
dependencies = [
"thiserror 2.0.18",
]

[[package]]
name = "bip39"
version = "2.2.0"
Expand Down Expand Up @@ -1665,21 +1674,21 @@ dependencies = [
"cfg-if",
"js-sys",
"libc",
"wasi 0.11.0+wasi-snapshot-preview1",
"wasi",
"wasm-bindgen",
]

[[package]]
name = "getrandom"
version = "0.3.3"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4"
checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
dependencies = [
"cfg-if",
"js-sys",
"libc",
"r-efi",
"wasi 0.14.2+wasi-0.2.4",
"wasip2",
"wasm-bindgen",
]

Expand Down Expand Up @@ -1869,12 +1878,11 @@ dependencies = [

[[package]]
name = "http"
version = "1.3.1"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565"
checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a"
dependencies = [
"bytes",
"fnv",
"itoa",
]

Expand Down Expand Up @@ -2203,7 +2211,7 @@ version = "0.1.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33"
dependencies = [
"getrandom 0.3.3",
"getrandom 0.3.4",
"libc",
]

Expand Down Expand Up @@ -2430,7 +2438,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c"
dependencies = [
"libc",
"wasi 0.11.0+wasi-snapshot-preview1",
"wasi",
"windows-sys 0.59.0",
]

Expand Down Expand Up @@ -2729,11 +2737,12 @@ checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd"
name = "payjoin"
version = "0.25.0"
dependencies = [
"bhttp",
"bhttp 0.7.2",
"bitcoin 0.32.8",
"bitcoin-hpke",
"bitcoin-ohttp",
"bitcoin_uri",
"getrandom 0.3.4",
"http",
"once_cell",
"payjoin-test-utils",
Expand Down Expand Up @@ -2818,7 +2827,7 @@ dependencies = [
"anyhow",
"axum",
"axum-server",
"bhttp",
"bhttp 0.6.1",
"bitcoin 0.32.8",
"bitcoin-ohttp",
"byteorder",
Expand Down Expand Up @@ -3134,7 +3143,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49df843a9161c85bb8aae55f101bc0bac8bcafd637a620d9122fd7e0b2f7422e"
dependencies = [
"bytes",
"getrandom 0.3.3",
"getrandom 0.3.4",
"lru-slab",
"rand 0.9.1",
"ring",
Expand Down Expand Up @@ -3255,7 +3264,7 @@ version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
dependencies = [
"getrandom 0.3.3",
"getrandom 0.3.4",
]

[[package]]
Expand Down Expand Up @@ -4100,7 +4109,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1"
dependencies = [
"fastrand",
"getrandom 0.3.3",
"getrandom 0.3.4",
"once_cell",
"rustix 1.0.7",
"windows-sys 0.59.0",
Expand Down Expand Up @@ -4927,7 +4936,7 @@ version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2e054861b4bd027cd373e18e8d8d8e6548085000e41290d95ce0c373a654b4a"
dependencies = [
"getrandom 0.3.3",
"getrandom 0.3.4",
"js-sys",
"rand 0.9.1",
"wasm-bindgen",
Expand Down Expand Up @@ -4967,12 +4976,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"

[[package]]
name = "wasi"
version = "0.14.2+wasi-0.2.4"
name = "wasip2"
version = "1.0.2+wasi-0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3"
checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5"
dependencies = [
"wit-bindgen-rt",
"wit-bindgen",
]

[[package]]
Expand Down Expand Up @@ -5397,13 +5406,10 @@ dependencies = [
]

[[package]]
name = "wit-bindgen-rt"
version = "0.39.0"
name = "wit-bindgen"
version = "0.51.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
dependencies = [
"bitflags 2.6.0",
]
checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5"

[[package]]
name = "writeable"
Expand Down
6 changes: 5 additions & 1 deletion payjoin-ffi/src/receive/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,11 @@ impl From<payjoin::receive::v2::SessionHistory> for ReceiverSessionHistory {
#[uniffi::export]
impl ReceiverSessionHistory {
/// Receiver session Payjoin URI
pub fn pj_uri(&self) -> Arc<crate::PjUri> { Arc::new(self.0.pj_uri().into()) }
pub fn pj_uri(&self) -> Arc<crate::PjUri> {
// SAFETY: pj_uri() returns PjUri<'static> — label and message are None
let uri: payjoin::PjUri<'static> = unsafe { core::mem::transmute(self.0.pj_uri()) };
Arc::new(uri.into())
}

/// Fallback transaction from the session if present
pub fn fallback_tx(&self) -> Option<Vec<u8>> {
Expand Down
5 changes: 5 additions & 0 deletions payjoin/src/bech32.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#[cfg(feature = "alloc")]
use alloc::string::String;
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;

use bitcoin::bech32::primitives::decode::{CheckedHrpstring, CheckedHrpstringError};
use bitcoin::bech32::{self, EncodeError, Hrp, NoChecksum};

Expand Down
38 changes: 32 additions & 6 deletions payjoin/src/core/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
use std::fmt::Debug;
use std::{error, fmt};
#[cfg(not(feature = "std"))]
use alloc::boxed::Box;
#[cfg(not(feature = "std"))]
use core::error;
use core::fmt::{self, Debug};
#[cfg(feature = "std")]
use std::error;

#[derive(Debug)]
pub struct StdRequiredError;

impl fmt::Display for StdRequiredError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "std is required for this operation")
}
}

#[cfg(feature = "std")]
impl std::error::Error for StdRequiredError {}

#[cfg(not(feature = "std"))]
impl core::error::Error for StdRequiredError {}

impl ImplementationError {
pub fn std_required() -> Self { ImplementationError(Box::new(StdRequiredError)) }
}
#[derive(Debug)]
pub struct ImplementationError(Box<dyn error::Error + Send + Sync>);

Expand All @@ -11,7 +34,7 @@ impl ImplementationError {
}

impl fmt::Display for ImplementationError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { std::fmt::Display::fmt(&self.0, f) }
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(&self.0, f) }
}

impl error::Error for ImplementationError {
Expand All @@ -34,16 +57,17 @@ impl From<&str> for ImplementationError {
ImplementationError::from(error)
}
}

/// Errors that can occur when replaying a session event log
#[cfg(feature = "v2")]
#[derive(Debug)]
pub struct ReplayError<SessionState, SessionEvent>(InternalReplayError<SessionState, SessionEvent>);

#[cfg(feature = "v2")]
impl<SessionState: Debug, SessionEvent: Debug> std::fmt::Display
impl<SessionState: Debug, SessionEvent: Debug> fmt::Display
for ReplayError<SessionState, SessionEvent>
{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
use InternalReplayError::*;
match &self.0 {
NoEvents => write!(f, "No events found in session"),
Expand All @@ -56,8 +80,9 @@ impl<SessionState: Debug, SessionEvent: Debug> std::fmt::Display
}
}
}

#[cfg(feature = "v2")]
impl<SessionState: Debug, SessionEvent: Debug> std::error::Error
impl<SessionState: Debug, SessionEvent: Debug> error::Error
for ReplayError<SessionState, SessionEvent>
{
}
Expand All @@ -71,6 +96,7 @@ impl<SessionState: Debug, SessionEvent: Debug> From<InternalReplayError<SessionS

#[cfg(feature = "v2")]
#[derive(Debug)]
#[allow(dead_code)]
pub(crate) enum InternalReplayError<SessionState, SessionEvent> {
/// No events in the event log
NoEvents,
Expand Down
Loading
Loading