Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

Commit 49e8592

Browse files
committed
Track pending payjoin proposal_psbt tx
1 parent 683663f commit 49e8592

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

Diff for: mutiny-core/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ pub enum ActivityItem {
168168
OnChain(TransactionDetails),
169169
Lightning(Box<MutinyInvoice>),
170170
ChannelClosed(ChannelClosure),
171+
// /// A payjoin proposal is posted to the directory but not yet broadcast from the sender
172+
// PendingPayjoin,
171173
}
172174

173175
impl ActivityItem {

Diff for: mutiny-core/src/onchain.rs

+14-5
Original file line numberDiff line numberDiff line change
@@ -334,15 +334,15 @@ impl<S: MutinyStorage> OnChainWallet<S> {
334334

335335
// Outputs may be substituted for e.g. batching at this stage
336336
// We're not doing this yet.
337-
337+
let mut wallet = self
338+
.wallet
339+
.try_write()
340+
.map_err(|_| Error::Server(MutinyError::WalletSigningFailed.into()))?;
338341
let payjoin_proposal = provisional_payjoin.finalize_proposal(
339342
|psbt: &payjoin::bitcoin::psbt::Psbt| {
340343
// convert from payjoin::bitcoin 30.0
341344
let mut psbt = PartiallySignedTransaction::from_str(&psbt.to_string()).unwrap();
342-
let wallet = self
343-
.wallet
344-
.try_read()
345-
.map_err(|_| Error::Server(MutinyError::WalletSigningFailed.into()))?;
345+
346346
wallet
347347
.sign(&mut psbt, SignOptions::default())
348348
.map_err(|_| Error::Server(MutinyError::WalletSigningFailed.into()))?;
@@ -354,6 +354,15 @@ impl<S: MutinyStorage> OnChainWallet<S> {
354354
Some(payjoin::bitcoin::FeeRate::MIN),
355355
)?;
356356
let payjoin_proposal_psbt = payjoin_proposal.psbt();
357+
let proposal_psbt_29 =
358+
bitcoin::psbt::PartiallySignedTransaction::from_str(&payjoin_proposal_psbt.to_string())
359+
.map_err(|_| Error::Server(MutinyError::WalletOperationFailed.into()))?;
360+
wallet
361+
.insert_tx(
362+
proposal_psbt_29.extract_tx(),
363+
ConfirmationTime::unconfirmed(crate::utils::now().as_secs()),
364+
)
365+
.map_err(|_| Error::Server(MutinyError::WalletOperationFailed.into()))?;
357366
log::debug!(
358367
"Receiver's Payjoin proposal PSBT Rsponse: {:#?}",
359368
payjoin_proposal_psbt

0 commit comments

Comments
 (0)