loopd: new loopin state for incorrect amount sweeps

This commit is contained in:
Slyghtning 2024-01-12 11:35:42 +01:00
parent 6f3c68fb21
commit 755d5dc68e
No known key found for this signature in database
GPG key ID: F82D456EA023C9BF
2 changed files with 13 additions and 5 deletions

View file

@ -72,6 +72,11 @@ const (
// StateFailInsufficientConfirmedBalance indicates that the swap wasn't
// published due to insufficient confirmed balance.
StateFailInsufficientConfirmedBalance SwapState = 12
// StateFailIncorrectHtlcAmtSwept indicates that the amount of an
// externally published loop in htlc that didn't match the swap amount
// has been swept back to the user after the htlc timeout period.
StateFailIncorrectHtlcAmtSwept SwapState = 13
)
// SwapStateType defines the types of swap states that exist. Every swap state
@ -92,10 +97,7 @@ const (
// Type returns the type of the SwapState it is called on.
func (s SwapState) Type() SwapStateType {
if s == StateInitiated || s == StateHtlcPublished ||
s == StatePreimageRevealed || s == StateFailTemporary ||
s == StateInvoiceSettled {
if s.IsPending() {
return StateTypePending
}
@ -110,7 +112,7 @@ func (s SwapState) Type() SwapStateType {
func (s SwapState) IsPending() bool {
return s == StateInitiated || s == StateHtlcPublished ||
s == StatePreimageRevealed || s == StateFailTemporary ||
s == StateInvoiceSettled
s == StateInvoiceSettled || s == StateFailIncorrectHtlcAmt
}
// IsFinal returns true if the swap is in a final state.
@ -160,6 +162,9 @@ func (s SwapState) String() string {
case StateFailInsufficientConfirmedBalance:
return "InsufficientConfirmedBalance"
case StateFailIncorrectHtlcAmtSwept:
return "StateFailIncorrectHtlcAmtSwept"
default:
return "Unknown"
}