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

Commit 5084e85

Browse files
committed
Track pending payjoin proposal_psbt tx
1 parent e20e87b commit 5084e85

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

mutiny-core/src/lib.rs

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

174176
impl ActivityItem {

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)