@@ -160,9 +160,8 @@ impl MaybeInputsOwned {
160160 /// An attacker can try to spend the receiver's own inputs. This check prevents that.
161161 pub fn check_inputs_not_owned (
162162 self ,
163- is_owned : impl FnMut ( & Script ) -> Result < bool , ImplementationError > ,
163+ is_owned : & mut impl FnMut ( & Script ) -> Result < bool , ImplementationError > ,
164164 ) -> Result < MaybeInputsSeen , ReplyableError > {
165- let mut is_owned = is_owned;
166165 let mut err: Result < ( ) , ReplyableError > = Ok ( ( ) ) ;
167166 if let Some ( e) = self
168167 . psbt
@@ -207,9 +206,8 @@ impl MaybeInputsSeen {
207206 /// original proposal PSBT of the current, new payjoin.
208207 pub fn check_no_inputs_seen_before (
209208 self ,
210- is_known : impl FnMut ( & OutPoint ) -> Result < bool , ImplementationError > ,
209+ is_known : & mut impl FnMut ( & OutPoint ) -> Result < bool , ImplementationError > ,
211210 ) -> Result < OutputsUnknown , ReplyableError > {
212- let mut is_known = is_known;
213211 self . psbt . input_pairs ( ) . try_for_each ( |input| {
214212 match is_known ( & input. txin . previous_output ) {
215213 Ok ( false ) => Ok :: < ( ) , ReplyableError > ( ( ) ) ,
@@ -250,9 +248,8 @@ impl OutputsUnknown {
250248 /// outputs.
251249 pub fn identify_receiver_outputs (
252250 self ,
253- is_receiver_output : impl FnMut ( & Script ) -> Result < bool , ImplementationError > ,
251+ is_receiver_output : & mut impl FnMut ( & Script ) -> Result < bool , ImplementationError > ,
254252 ) -> Result < WantsOutputs , ReplyableError > {
255- let mut is_receiver_output = is_receiver_output;
256253 let owned_vouts: Vec < usize > = self
257254 . psbt
258255 . unsigned_tx
@@ -912,11 +909,11 @@ pub(crate) mod test {
912909 fn wants_outputs_from_test_vector ( proposal : UncheckedProposal ) -> WantsOutputs {
913910 proposal
914911 . assume_interactive_receiver ( )
915- . check_inputs_not_owned ( |_| Ok ( false ) )
912+ . check_inputs_not_owned ( & mut |_| Ok ( false ) )
916913 . expect ( "No inputs should be owned" )
917- . check_no_inputs_seen_before ( |_| Ok ( false ) )
914+ . check_no_inputs_seen_before ( & mut |_| Ok ( false ) )
918915 . expect ( "No inputs should be seen before" )
919- . identify_receiver_outputs ( |script| {
916+ . identify_receiver_outputs ( & mut |script| {
920917 let network = Network :: Bitcoin ;
921918 Ok ( Address :: from_script ( script, network) . unwrap ( )
922919 == Address :: from_str ( "3CZZi7aWFugaCdUCS15dgrUUViupmB8bVM" )
@@ -945,20 +942,20 @@ pub(crate) mod test {
945942 Ok ( ret)
946943 }
947944
948- let maybe_inputs_seen =
949- maybe_inputs_owned . check_inputs_not_owned ( |_| mock_callback ( & mut call_count, false ) ) ;
945+ let maybe_inputs_seen = maybe_inputs_owned
946+ . check_inputs_not_owned ( & mut |_| mock_callback ( & mut call_count, false ) ) ;
950947 assert_eq ! ( call_count, 1 ) ;
951948
952949 let outputs_unknown = maybe_inputs_seen
953950 . map_err ( |_| "Check inputs owned closure failed" . to_string ( ) )
954951 . expect ( "Next receiver state should be accessible" )
955- . check_no_inputs_seen_before ( |_| mock_callback ( & mut call_count, false ) ) ;
952+ . check_no_inputs_seen_before ( & mut |_| mock_callback ( & mut call_count, false ) ) ;
956953 assert_eq ! ( call_count, 2 ) ;
957954
958955 let _wants_outputs = outputs_unknown
959956 . map_err ( |_| "Check no inputs seen closure failed" . to_string ( ) )
960957 . expect ( "Next receiver state should be accessible" )
961- . identify_receiver_outputs ( |_| mock_callback ( & mut call_count, true ) ) ;
958+ . identify_receiver_outputs ( & mut |_| mock_callback ( & mut call_count, true ) ) ;
962959 // there are 2 receiver outputs so we should expect this callback to run twice incrementing
963960 // call count twice
964961 assert_eq ! ( call_count, 4 ) ;
@@ -1014,11 +1011,11 @@ pub(crate) mod test {
10141011 let proposal = unchecked_proposal_from_test_vector ( ) ;
10151012 let wants_inputs = proposal
10161013 . assume_interactive_receiver ( )
1017- . check_inputs_not_owned ( |_| Ok ( false ) )
1014+ . check_inputs_not_owned ( & mut |_| Ok ( false ) )
10181015 . expect ( "No inputs should be owned" )
1019- . check_no_inputs_seen_before ( |_| Ok ( false ) )
1016+ . check_no_inputs_seen_before ( & mut |_| Ok ( false ) )
10201017 . expect ( "No inputs should be seen before" )
1021- . identify_receiver_outputs ( |script| {
1018+ . identify_receiver_outputs ( & mut |script| {
10221019 let network = Network :: Bitcoin ;
10231020 let target_address = Address :: from_str ( "3CZZi7aWFugaCdUCS15dgrUUViupmB8bVM" )
10241021 . map_err ( ImplementationError :: new) ?
0 commit comments