@@ -9,7 +9,7 @@ use crate::{
9
9
get_payment_info, list_payment_info, persist_payment_info, MutinyStorage , VersionedValue ,
10
10
} ,
11
11
utils:: sleep,
12
- HTLCStatus , MutinyInvoice , DEFAULT_PAYMENT_TIMEOUT , DEFAULT_REISSUE_TIMEOUT ,
12
+ HTLCStatus , MutinyInvoice , DEFAULT_PAYMENT_TIMEOUT ,
13
13
} ;
14
14
use async_trait:: async_trait;
15
15
use bip39:: Mnemonic ;
@@ -72,6 +72,12 @@ use std::{
72
72
sync:: atomic:: { AtomicU32 , Ordering } ,
73
73
} ;
74
74
75
+ // The amount of time in milliseconds to wait for
76
+ // checking the status of a fedimint OOB re-issuance. This
77
+ // is to work around their stream status checking
78
+ // when wanting just the current status.
79
+ const FEDIMINT_OOB_REISSUE_TIMEOUT_CHECK_MS : u64 = 30 ;
80
+
75
81
// The amount of time in milliseconds to wait for
76
82
// checking the status of a fedimint payment. This
77
83
// is to work around their stream status checking
@@ -616,15 +622,31 @@ impl<S: MutinyStorage> FederationClient<S> {
616
622
// Reissue `OOBNotes`
617
623
let operation_id = mint_module. reissue_external_notes ( oob_notes, ( ) ) . await ?;
618
624
619
- // TODO: (@leonardo) re-think about the results and errors that we need/want
620
- match process_reissue_outcome ( & mint_module, operation_id, self . logger . clone ( ) ) . await ? {
621
- ReissueExternalNotesState :: Created | ReissueExternalNotesState :: Failed ( _) => {
622
- log_trace ! ( self . logger, "re-issuance of OOBNotes failed!" ) ;
625
+ match process_reissue_outcome (
626
+ & mint_module,
627
+ operation_id,
628
+ FEDIMINT_OOB_REISSUE_TIMEOUT_CHECK_MS ,
629
+ self . logger . clone ( ) ,
630
+ )
631
+ . await ?
632
+ {
633
+ ReissueExternalNotesState :: Done => {
634
+ log_trace ! ( self . logger, "re-issuance of OOBNotes was successful!" ) ;
635
+ Ok ( ( ) )
636
+ }
637
+ ReissueExternalNotesState :: Failed ( reason) => {
638
+ log_trace ! (
639
+ self . logger,
640
+ "re-issuance of OOBNotes failed explicitly, reason: {reason}"
641
+ ) ;
623
642
Err ( MutinyError :: FedimintReissueFailed )
624
643
}
625
644
_ => {
626
- log_trace ! ( self . logger, "re-issuance of OOBNotes was successful!" ) ;
627
- Ok ( ( ) )
645
+ log_trace ! (
646
+ self . logger,
647
+ "re-issuance of OOBNotes explicitly failed, due to outcome with a stale state!"
648
+ ) ;
649
+ Err ( MutinyError :: FedimintReissueStaleState )
628
650
}
629
651
}
630
652
}
@@ -889,21 +911,22 @@ where
889
911
async fn process_reissue_outcome (
890
912
mint_module : & MintClientModule ,
891
913
operation_id : OperationId ,
914
+ timeout : u64 ,
892
915
logger : Arc < MutinyLogger > ,
893
916
) -> Result < ReissueExternalNotesState , MutinyError > {
894
- // Subscribe/Process the outcome based on `ReissueExternalNotesState`
917
+ // Subscribe to the outcome based on `ReissueExternalNotesState`
895
918
let stream_or_outcome = mint_module
896
919
. subscribe_reissue_external_notes ( operation_id)
897
920
. await
898
921
. map_err ( MutinyError :: Other ) ?;
899
922
923
+ // Process the outcome based on `ReissueExternalNotesState`
900
924
match stream_or_outcome {
901
925
UpdateStreamOrOutcome :: Outcome ( outcome) => {
902
926
log_trace ! ( logger, "outcome received {:?}" , outcome) ;
903
927
Ok ( outcome)
904
928
}
905
929
UpdateStreamOrOutcome :: UpdateStream ( mut stream) => {
906
- let timeout = DEFAULT_REISSUE_TIMEOUT ;
907
930
let timeout_fut = sleep ( timeout as i32 ) ;
908
931
pin_mut ! ( timeout_fut) ;
909
932
0 commit comments