@@ -795,6 +795,7 @@ impl<S: MutinyStorage> NodeManager<S> {
795795 /// Poll the payjoin relay to maintain a payjoin session and create a payjoin proposal.
796796 pub async fn receive_payjoin (
797797 wallet : Arc < OnChainWallet < S > > ,
798+ stop : Arc < AtomicBool > ,
798799 mut enrolled : payjoin:: receive:: v2:: Enrolled ,
799800 ) -> Result < Txid , MutinyError > {
800801 use crate :: payjoin:: Error as PayjoinError ;
@@ -803,7 +804,9 @@ impl<S: MutinyStorage> NodeManager<S> {
803804 . build ( )
804805 . map_err ( PayjoinError :: Reqwest ) ?;
805806 let proposal: payjoin:: receive:: v2:: UncheckedProposal =
806- Self :: poll_for_fallback_psbt ( & http_client, & mut enrolled) . await ?;
807+ Self :: poll_for_fallback_psbt ( stop, & http_client, & mut enrolled)
808+ . await
809+ . map_err ( |e| PayjoinError :: ReceiverStateMachine ( e. to_string ( ) ) ) ?;
807810 let mut payjoin_proposal = wallet
808811 . process_payjoin_proposal ( proposal)
809812 . map_err ( |e| PayjoinError :: ReceiverStateMachine ( e. to_string ( ) ) ) ?;
@@ -827,10 +830,14 @@ impl<S: MutinyStorage> NodeManager<S> {
827830 }
828831
829832 async fn poll_for_fallback_psbt (
833+ stop : Arc < AtomicBool > ,
830834 client : & reqwest:: Client ,
831835 enroller : & mut payjoin:: receive:: v2:: Enrolled ,
832836 ) -> Result < payjoin:: receive:: v2:: UncheckedProposal , crate :: payjoin:: Error > {
833837 loop {
838+ if stop. load ( Ordering :: Relaxed ) {
839+ return Err ( crate :: payjoin:: Error :: Shutdown ) ;
840+ }
834841 let ( req, context) = enroller. extract_req ( ) ?;
835842 let ohttp_response = client
836843 . post ( req. url )
0 commit comments