@@ -708,7 +708,17 @@ impl<S: MutinyStorage> NodeManager<S> {
708
708
let address = Address :: from_str ( & uri. address . to_string ( ) )
709
709
. map_err ( |_| MutinyError :: InvalidArgumentsError ) ?;
710
710
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
+
712
722
let fee_rate = if let Some ( rate) = fee_rate {
713
723
FeeRate :: from_sat_per_vb ( rate)
714
724
} else {
@@ -743,6 +753,7 @@ impl<S: MutinyStorage> NodeManager<S> {
743
753
let proposal_psbt = match Self :: poll_payjoin_sender ( stop, req_ctx) . await {
744
754
Ok ( psbt) => psbt,
745
755
Err ( e) => {
756
+ // self.wallet cancel_tx
746
757
log_error ! ( logger, "Error polling payjoin sender: {e}" ) ;
747
758
return ;
748
759
}
@@ -812,11 +823,13 @@ impl<S: MutinyStorage> NodeManager<S> {
812
823
labels : Vec < String > ,
813
824
) -> Result < Txid , MutinyError > {
814
825
log_debug ! ( logger, "Sending payjoin.." ) ;
826
+ let original_tx = original_psbt. clone ( ) . extract_tx ( ) ;
815
827
let tx = wallet
816
828
. send_payjoin ( original_psbt, proposal_psbt, labels)
817
829
. await ?;
818
830
let txid = tx. txid ( ) ;
819
831
wallet. broadcast_transaction ( tx) . await ?;
832
+ wallet. cancel_tx ( & original_tx) ?;
820
833
log_info ! ( logger, "Payjoin broadcast! TXID: {txid}" ) ;
821
834
Ok ( txid)
822
835
}
0 commit comments