@@ -768,7 +768,17 @@ impl<S: MutinyStorage> NodeManager<S> {
768768 . map_err ( |_| MutinyError :: IncorrectNetwork ) ?;
769769 let address = uri. address . clone ( ) ;
770770 let original_psbt = self . wallet . create_signed_psbt ( address, amount, fee_rate) ?;
771- // TODO ensure this creates a pending tx in the UI. Ensure locked UTXO.
771+ // Track this transaction in the wallet so it shows as an ActivityItem in UI.
772+ // We'll cancel it if and when this original_psbt fallback is replaced with a payjoin.
773+ // TODO mark as a payjoin
774+ self . wallet
775+ . insert_tx (
776+ original_psbt. clone ( ) . extract_tx ( ) ,
777+ ConfirmationTime :: unconfirmed ( crate :: utils:: now ( ) . as_secs ( ) ) ,
778+ None ,
779+ )
780+ . await ?;
781+
772782 let fee_rate = if let Some ( rate) = fee_rate {
773783 FeeRate :: from_sat_per_vb ( rate)
774784 } else {
@@ -799,6 +809,7 @@ impl<S: MutinyStorage> NodeManager<S> {
799809 let proposal_psbt = match Self :: poll_payjoin_sender ( stop, req_ctx) . await {
800810 Ok ( psbt) => psbt,
801811 Err ( e) => {
812+ // self.wallet cancel_tx
802813 log_error ! ( logger, "Error polling payjoin sender: {e}" ) ;
803814 return ;
804815 }
@@ -869,11 +880,13 @@ impl<S: MutinyStorage> NodeManager<S> {
869880 labels : Vec < String > ,
870881 ) -> Result < Txid , MutinyError > {
871882 log_debug ! ( logger, "Sending payjoin.." ) ;
883+ let original_tx = original_psbt. clone ( ) . extract_tx ( ) ;
872884 let tx = wallet
873885 . send_payjoin ( original_psbt, proposal_psbt, labels)
874886 . await ?;
875887 let txid = tx. txid ( ) ;
876888 wallet. broadcast_transaction ( tx) . await ?;
889+ wallet. cancel_tx ( & original_tx) ?;
877890 log_info ! ( logger, "Payjoin broadcast! TXID: {txid}" ) ;
878891 Ok ( txid)
879892 }
@@ -908,7 +921,7 @@ impl<S: MutinyStorage> NodeManager<S> {
908921 let ( req, ohttp_ctx) = payjoin_proposal. extract_v2_req ( ) ?;
909922 let res = http_client
910923 . post ( req. url )
911- . header ( "Content-Type " , "message/ohttp-req" )
924+ . header ( "content-type " , "message/ohttp-req" )
912925 . body ( req. body )
913926 . send ( )
914927 . await ?;
@@ -936,7 +949,7 @@ impl<S: MutinyStorage> NodeManager<S> {
936949 let ( req, context) = session. enrolled . extract_req ( ) ?;
937950 let ohttp_response = client
938951 . post ( req. url )
939- . header ( "Content-Type " , "message/ohttp-req" )
952+ . header ( "content-type " , "message/ohttp-req" )
940953 . body ( req. body )
941954 . send ( )
942955 . await ?;
0 commit comments