From efb7204b9c9d230012d2532b133960db741b55f7 Mon Sep 17 00:00:00 2001 From: DanGould Date: Wed, 29 Jul 2026 14:45:25 +0800 Subject: [PATCH] Expose PjParam::receiver_pubkey() over FFI FFI consumers need the receiver's ephemeral HPKE public key as the key for deduplicating and resuming sender sessions, matching what payjoin-cli already does natively. Until now the FFI PjParam was an opaque object with no exported methods, forcing wallets to scrape the compressed key out of the endpoint fragment and reimplement URI-format knowledge that belongs in the library. Add a #[uniffi::export] getter returning the 33-byte compressed key, mirroring the existing SenderSessionHistory::fallback_tx() pattern. This only bridges to FFI what core already exposes as pub for exactly this purpose; the genuinely-internal fields stay pub(crate). --- payjoin-ffi/src/send/mod.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/payjoin-ffi/src/send/mod.rs b/payjoin-ffi/src/send/mod.rs index 53e4739aa..bccbead8b 100644 --- a/payjoin-ffi/src/send/mod.rs +++ b/payjoin-ffi/src/send/mod.rs @@ -252,6 +252,18 @@ impl From for payjoin::uri::v2::PjParam { fn from(value: PjParam) -> Self { value.0 } } +#[uniffi::export] +impl PjParam { + /// The receiver's ephemeral HPKE public key, as 33 compressed bytes. + /// + /// Stable for the lifetime of a receive session. Consumers use it to + /// deduplicate and resume sender sessions and to ensure a receiver key + /// is not reused across sessions, without parsing the endpoint fragment. + pub fn receiver_pubkey(&self) -> Vec { + self.0.receiver_pubkey().to_compressed_bytes().to_vec() + } +} + #[derive(uniffi::Object, Clone)] pub struct SenderSessionHistory(pub payjoin::send::v2::SessionHistory);