@@ -821,7 +821,17 @@ impl<S: MutinyStorage> NodeManager<S> {
821821 let address = Address :: from_str ( & uri. address . to_string ( ) )
822822 . map_err ( |_| MutinyError :: PayjoinConfigError ) ?;
823823 let original_psbt = self . wallet . create_signed_psbt ( address, amount, fee_rate) ?;
824- // TODO ensure this creates a pending tx in the UI. Ensure locked UTXO.
824+ // Track this transaction in the wallet so it shows as an ActivityItem in UI.
825+ // We'll cancel it if and when this original_psbt fallback is replaced with a payjoin.
826+ // TODO mark as a payjoin
827+ self . wallet
828+ . insert_tx (
829+ original_psbt. clone ( ) . extract_tx ( ) ,
830+ ConfirmationTime :: unconfirmed ( crate :: utils:: now ( ) . as_secs ( ) ) ,
831+ None ,
832+ )
833+ . await ?;
834+
825835 let fee_rate = if let Some ( rate) = fee_rate {
826836 FeeRate :: from_sat_per_vb ( rate)
827837 } else {
@@ -856,6 +866,7 @@ impl<S: MutinyStorage> NodeManager<S> {
856866 let proposal_psbt = match Self :: poll_payjoin_sender ( stop, req_ctx) . await {
857867 Ok ( psbt) => psbt,
858868 Err ( e) => {
869+ // self.wallet cancel_tx
859870 log_error ! ( logger, "Error polling payjoin sender: {e}" ) ;
860871 return ;
861872 }
@@ -924,11 +935,13 @@ impl<S: MutinyStorage> NodeManager<S> {
924935 labels : Vec < String > ,
925936 ) -> Result < Txid , MutinyError > {
926937 log_debug ! ( logger, "Sending payjoin.." ) ;
938+ let original_tx = original_psbt. clone ( ) . extract_tx ( ) ;
927939 let tx = wallet
928940 . send_payjoin ( original_psbt, proposal_psbt, labels)
929941 . await ?;
930942 let txid = tx. txid ( ) ;
931943 wallet. broadcast_transaction ( tx) . await ?;
944+ wallet. cancel_tx ( & original_tx) ?;
932945 log_info ! ( logger, "Payjoin broadcast! TXID: {txid}" ) ;
933946 Ok ( txid)
934947 }
0 commit comments