Skip to content

Commit c2a3d15

Browse files
committed
Expose fallback tx off sender session history
Extract the unchecked transaction from the original psbt which becomes asccessible in the first session event -- withReplyKey.
1 parent f6d4a61 commit c2a3d15

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

payjoin-ffi/src/send/uni.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ impl SenderSessionHistory {
7373
pub fn endpoints(&self) -> Option<Arc<Url>> {
7474
self.0.0.endpoint().map(|url| Arc::new(url.clone().into()))
7575
}
76+
77+
/// Fallback transaction from the session if present
78+
pub fn fallback_tx(&self) -> Option<Arc<crate::Transaction>> {
79+
self.0.0.fallback_tx().map(|tx| Arc::new(tx.into()))
80+
}
7681
}
7782

7883
#[derive(uniffi::Object)]

payjoin/src/send/v2/session.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ pub struct SessionHistory {
6767
}
6868

6969
impl SessionHistory {
70+
/// Fallback transaction from the session if present
71+
pub fn fallback_tx(&self) -> Option<bitcoin::Transaction> {
72+
self.events.iter().find_map(|event| match event {
73+
SessionEvent::CreatedReplyKey(proposal) =>
74+
Some(proposal.v1.psbt.clone().extract_tx_unchecked_fee_rate()),
75+
_ => None,
76+
})
77+
}
78+
7079
pub fn endpoint(&self) -> Option<&Url> {
7180
self.events.iter().find_map(|event| match event {
7281
SessionEvent::V2GetContext(ctx) => Some(&ctx.endpoint),

0 commit comments

Comments
 (0)