@ -276,7 +276,7 @@ pub enum CfdState {
// TODO: Can be extended with CetStatus
/// The CFD contract's refund transaction was published but it not final yet
Must Refund { common : CfdStateCommon , dlc : Dlc } ,
Pending Refund { common : CfdStateCommon , dlc : Dlc } ,
/// The Cfd was refunded and the refund transaction reached finality
///
@ -328,7 +328,7 @@ impl CfdState {
}
pub fn must_refund ( dlc : Dlc ) -> Self {
Self ::Must Refund {
Self ::Pending Refund {
common : CfdStateCommon ::default ( ) ,
dlc ,
}
@ -455,7 +455,7 @@ impl CfdState {
CfdState ::PendingOpen { common , . . } = > common ,
CfdState ::Open { common , . . } = > common ,
CfdState ::OpenCommitted { common , . . } = > common ,
CfdState ::Must Refund { common , . . } = > common ,
CfdState ::Pending Refund { common , . . } = > common ,
CfdState ::Refunded { common , . . } = > common ,
CfdState ::SetupFailed { common , . . } = > common ,
CfdState ::PendingCommit { common , . . } = > common ,
@ -511,7 +511,7 @@ impl fmt::Display for CfdState {
CfdState ::OpenCommitted { . . } = > {
write ! ( f , "Open Committed" )
}
CfdState ::Must Refund { . . } = > {
CfdState ::Pending Refund { . . } = > {
write ! ( f , "Must Refund" )
}
CfdState ::Refunded { . . } = > {
@ -835,11 +835,11 @@ impl Cfd {
let dlc = if let OpenCommitted { dlc , . . } = self . state . clone ( ) {
dlc
} else if let Open { dlc , . . } | PendingOpen { dlc , . . } = self . state . clone ( ) {
tracing ::debug ! ( % order_id , "Was in unexpected state {}, jumping ahead to Must Refund" , self . state ) ;
tracing ::debug ! ( % order_id , "Was in unexpected state {}, jumping ahead to Pending Refund" , self . state ) ;
dlc
} else {
bail ! (
"Cannot transition to Must Refund because of unexpected state {}" ,
"Cannot transition to Pending Refund because of unexpected state {}" ,
self . state
)
} ;
@ -983,10 +983,10 @@ impl Cfd {
}
pub fn refund_tx ( & self ) -> Result < Transaction > {
let dlc = if let CfdState ::Must Refund { dlc , . . } = self . state . clone ( ) {
let dlc = if let CfdState ::Pending Refund { dlc , . . } = self . state . clone ( ) {
dlc
} else {
bail ! ( "Refund transaction can only be constructed when in state Must Refund, but we are currently in {}" , self . state . clone ( ) )
bail ! ( "Refund transaction can only be constructed when in state Pending Refund, but we are currently in {}" , self . state . clone ( ) )
} ;
let sig_hash = spending_tx_sighash (
@ -1132,7 +1132,7 @@ impl Cfd {
}
pub fn is_must_refund ( & self ) -> bool {
matches ! ( self . state . clone ( ) , CfdState ::Must Refund { . . } )
matches ! ( self . state . clone ( ) , CfdState ::Pending Refund { . . } )
}
pub fn is_pending_commit ( & self ) -> bool {
@ -1171,7 +1171,7 @@ impl Cfd {
| CfdState ::Rejected { . . }
| CfdState ::ContractSetup { . . }
| CfdState ::Closed { . . }
| CfdState ::Must Refund { . . }
| CfdState ::Pending Refund { . . }
| CfdState ::Refunded { . . }
| CfdState ::SetupFailed { . . } = > None ,
}
@ -1211,7 +1211,7 @@ impl Cfd {
| CfdState ::PendingCommit { . . }
| CfdState ::Closed { . . }
| CfdState ::OpenCommitted { . . }
| CfdState ::Must Refund { . . }
| CfdState ::Pending Refund { . . }
| CfdState ::Refunded { . . }
| CfdState ::SetupFailed { . . } = > None ,
}
@ -1239,7 +1239,7 @@ impl Cfd {
| CfdState ::PendingCet { . . }
| CfdState ::Closed { . . }
| CfdState ::OpenCommitted { . . }
| CfdState ::Must Refund { . . }
| CfdState ::Pending Refund { . . }
| CfdState ::Refunded { . . }
| CfdState ::SetupFailed { . . } = > None ,
}
@ -1252,7 +1252,7 @@ impl Cfd {
/// undecided
pub fn payout ( & self ) -> Option < Amount > {
// early exit in case of refund scenario
if let CfdState ::Must Refund { dlc , . . } | CfdState ::Refunded { dlc , . . } =
if let CfdState ::Pending Refund { dlc , . . } | CfdState ::Refunded { dlc , . . } =
self . state . clone ( )
{
return Some ( dlc . refund_amount ( self . role ( ) ) ) ;