@@ -767,7 +767,16 @@ impl<S: MutinyStorage> NodeManager<S> {
767767 . map_err ( |_| MutinyError :: IncorrectNetwork ) ?;
768768 let address = uri. address . clone ( ) ;
769769 let original_psbt = self . wallet . create_signed_psbt ( address, amount, fee_rate) ?;
770- // TODO ensure this creates a pending tx in the UI. Ensure locked UTXO.
770+ // Track this transaction in the wallet so it shows as an ActivityItem in UI.
771+ // We'll cancel it if and when this original_psbt fallback is replaced with a received payjoin.
772+ self . wallet
773+ . insert_tx (
774+ original_psbt. clone ( ) . extract_tx ( ) ,
775+ ConfirmationTime :: unconfirmed ( crate :: utils:: now ( ) . as_secs ( ) ) ,
776+ None ,
777+ )
778+ . await ?;
779+
771780 let fee_rate = if let Some ( rate) = fee_rate {
772781 FeeRate :: from_sat_per_vb ( rate)
773782 } else {
@@ -798,6 +807,7 @@ impl<S: MutinyStorage> NodeManager<S> {
798807 let proposal_psbt = match Self :: poll_payjoin_sender ( stop, req_ctx) . await {
799808 Ok ( psbt) => psbt,
800809 Err ( e) => {
810+ // self.wallet cancel_tx
801811 log_error ! ( logger, "Error polling payjoin sender: {e}" ) ;
802812 return ;
803813 }
@@ -867,11 +877,13 @@ impl<S: MutinyStorage> NodeManager<S> {
867877 labels : Vec < String > ,
868878 ) -> Result < Txid , MutinyError > {
869879 log_debug ! ( logger, "Sending payjoin.." ) ;
880+ let original_tx = original_psbt. clone ( ) . extract_tx ( ) ;
870881 let tx = wallet
871882 . send_payjoin ( original_psbt, proposal_psbt, labels)
872883 . await ?;
873884 let txid = tx. txid ( ) ;
874885 wallet. broadcast_transaction ( tx) . await ?;
886+ wallet. cancel_tx ( & original_tx) ?;
875887 log_info ! ( logger, "Payjoin broadcast! TXID: {txid}" ) ;
876888 Ok ( txid)
877889 }
0 commit comments