@@ -708,7 +708,17 @@ impl<S: MutinyStorage> NodeManager<S> {
708708 let address = Address :: from_str ( & uri. address . to_string ( ) )
709709 . map_err ( |_| MutinyError :: InvalidArgumentsError ) ?;
710710 let original_psbt = self . wallet . create_signed_psbt ( address, amount, fee_rate) ?;
711- // TODO ensure this creates a pending tx in the UI. Ensure locked UTXO.
711+ // Track this transaction in the wallet so it shows as an ActivityItem in UI.
712+ // We'll cancel it if and when this original_psbt fallback is replaced with a payjoin.
713+ // TODO mark as a payjoin
714+ self . wallet
715+ . insert_tx (
716+ original_psbt. clone ( ) . extract_tx ( ) ,
717+ ConfirmationTime :: unconfirmed ( crate :: utils:: now ( ) . as_secs ( ) ) ,
718+ None ,
719+ )
720+ . await ?;
721+
712722 let fee_rate = if let Some ( rate) = fee_rate {
713723 FeeRate :: from_sat_per_vb ( rate)
714724 } else {
@@ -743,6 +753,7 @@ impl<S: MutinyStorage> NodeManager<S> {
743753 let proposal_psbt = match Self :: poll_payjoin_sender ( stop, req_ctx) . await {
744754 Ok ( psbt) => psbt,
745755 Err ( e) => {
756+ // self.wallet cancel_tx
746757 log_error ! ( logger, "Error polling payjoin sender: {e}" ) ;
747758 return ;
748759 }
@@ -812,11 +823,13 @@ impl<S: MutinyStorage> NodeManager<S> {
812823 labels : Vec < String > ,
813824 ) -> Result < Txid , MutinyError > {
814825 log_debug ! ( logger, "Sending payjoin.." ) ;
826+ let original_tx = original_psbt. clone ( ) . extract_tx ( ) ;
815827 let tx = wallet
816828 . send_payjoin ( original_psbt, proposal_psbt, labels)
817829 . await ?;
818830 let txid = tx. txid ( ) ;
819831 wallet. broadcast_transaction ( tx) . await ?;
832+ wallet. cancel_tx ( & original_tx) ?;
820833 log_info ! ( logger, "Payjoin broadcast! TXID: {txid}" ) ;
821834 Ok ( txid)
822835 }
0 commit comments