diff --git a/mutiny-core/src/lib.rs b/mutiny-core/src/lib.rs index 812ba7b25..c19eba11c 100644 --- a/mutiny-core/src/lib.rs +++ b/mutiny-core/src/lib.rs @@ -169,6 +169,8 @@ pub enum ActivityItem { OnChain(TransactionDetails), Lightning(Box), ChannelClosed(ChannelClosure), + // /// A payjoin proposal is posted to the directory but not yet broadcast from the sender + // PendingPayjoin, } impl ActivityItem { diff --git a/mutiny-core/src/onchain.rs b/mutiny-core/src/onchain.rs index 3544db7a7..30e9e665f 100644 --- a/mutiny-core/src/onchain.rs +++ b/mutiny-core/src/onchain.rs @@ -334,15 +334,15 @@ impl OnChainWallet { // Outputs may be substituted for e.g. batching at this stage // We're not doing this yet. - + let mut wallet = self + .wallet + .try_write() + .map_err(|_| Error::Server(MutinyError::WalletSigningFailed.into()))?; let payjoin_proposal = provisional_payjoin.finalize_proposal( |psbt: &payjoin::bitcoin::psbt::Psbt| { // convert from payjoin::bitcoin 30.0 let mut psbt = PartiallySignedTransaction::from_str(&psbt.to_string()).unwrap(); - let wallet = self - .wallet - .try_read() - .map_err(|_| Error::Server(MutinyError::WalletSigningFailed.into()))?; + wallet .sign(&mut psbt, SignOptions::default()) .map_err(|_| Error::Server(MutinyError::WalletSigningFailed.into()))?; @@ -354,6 +354,15 @@ impl OnChainWallet { Some(payjoin::bitcoin::FeeRate::MIN), )?; let payjoin_proposal_psbt = payjoin_proposal.psbt(); + let proposal_psbt_29 = + bitcoin::psbt::PartiallySignedTransaction::from_str(&payjoin_proposal_psbt.to_string()) + .map_err(|_| Error::Server(MutinyError::WalletOperationFailed.into()))?; + wallet + .insert_tx( + proposal_psbt_29.extract_tx(), + ConfirmationTime::unconfirmed(crate::utils::now().as_secs()), + ) + .map_err(|_| Error::Server(MutinyError::WalletOperationFailed.into()))?; log::debug!( "Receiver's Payjoin proposal PSBT Rsponse: {:#?}", payjoin_proposal_psbt