Skip to content

Commit

Permalink
Track pending payjoin proposal_psbt tx
Browse files Browse the repository at this point in the history
  • Loading branch information
DanGould committed Jan 6, 2024
1 parent 683663f commit 49e8592
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
2 changes: 2 additions & 0 deletions mutiny-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ pub enum ActivityItem {
OnChain(TransactionDetails),
Lightning(Box<MutinyInvoice>),
ChannelClosed(ChannelClosure),
// /// A payjoin proposal is posted to the directory but not yet broadcast from the sender
// PendingPayjoin,
}

impl ActivityItem {
Expand Down
19 changes: 14 additions & 5 deletions mutiny-core/src/onchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,15 +334,15 @@ impl<S: MutinyStorage> OnChainWallet<S> {

// 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()))?;
Expand All @@ -354,6 +354,15 @@ impl<S: MutinyStorage> OnChainWallet<S> {
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
Expand Down

0 comments on commit 49e8592

Please sign in to comment.