-
Notifications
You must be signed in to change notification settings - Fork 6
/
resolution_result.go
148 lines (109 loc) · 3.85 KB
/
resolution_result.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package lnmux
// FailResolutionResult provides metadata about a htlc that was failed by
// the registry. It can be used to take custom actions on resolution of the
// htlc.
type FailResolutionResult uint8
const (
resultInvalidFailure FailResolutionResult = iota
// ResultExpiryTooSoon is returned when we do not accept an invoice
// payment because it expires too soon.
ResultExpiryTooSoon
// ResultInvoiceNotOpen is returned when a mpp invoice is not open.
ResultInvoiceNotOpen
// ResultMppTimeout is returned when an invoice paid with multiple
// partial payments times out before it is fully paid.
ResultMppTimeout
// ResultAddressMismatch is returned when the payment address for a mpp
// invoice does not match.
ResultAddressMismatch
// ResultHtlcSetTotalMismatch is returned when the amount paid by a
// htlc does not match its set total.
ResultHtlcSetTotalMismatch
// ResultHtlcSetTotalTooLow is returned when a mpp set total is too low
// for an invoice.
ResultHtlcSetTotalTooLow
// ResultHtlcSetOverpayment is returned when a mpp set is overpaid.
ResultHtlcSetOverpayment
// ResultInvoiceNotFound is returned when an attempt is made to pay an
// invoice that is unknown to us.
ResultInvoiceNotFound
// ResultHtlcInvoiceTypeMismatch is returned when an AMP HTLC targets a
// non-AMP invoice and vice versa.
ResultHtlcInvoiceTypeMismatch
// ResultCannotSettle is returned when the invoice cannot be settled in
// the database.
ResultCannotSettle
// ResultInvoiceExpired is returned when an invoice has expired.
ResultInvoiceExpired
// ResultNoAcceptSubscriber is returned when an htlc is failed because there
// is no application subscribed to accept events.
ResultNoAcceptSubscriber
// ResultAcceptTimeout is returned when the accept timeout is reached
// without settlement after an invoice is accepted.
ResultAcceptTimeout
)
// String returns a string representation of the result.
func (f FailResolutionResult) String() string {
return f.FailureString()
}
// FailureString returns a string representation of the result.
//
// Note: it is part of the FailureDetail interface.
func (f FailResolutionResult) FailureString() string {
switch f {
case resultInvalidFailure:
return "invalid failure result"
case ResultExpiryTooSoon:
return "expiry too soon"
case ResultInvoiceNotOpen:
return "invoice no longer open"
case ResultMppTimeout:
return "mpp timeout"
case ResultAddressMismatch:
return "payment address mismatch"
case ResultHtlcSetTotalMismatch:
return "htlc total amt doesn't match set total"
case ResultHtlcSetTotalTooLow:
return "set total too low for invoice"
case ResultHtlcSetOverpayment:
return "mpp is overpaying set total"
case ResultInvoiceNotFound:
return "invoice not found"
case ResultHtlcInvoiceTypeMismatch:
return "htlc invoice type mismatch"
case ResultCannotSettle:
return "cannot settle"
case ResultInvoiceExpired:
return "invoice expired"
case ResultNoAcceptSubscriber:
return "no accept subscriber"
case ResultAcceptTimeout:
return "accept timeout"
default:
return "unknown failure resolution result"
}
}
// SettleResolutionResult provides metadata which about a htlc that was failed
// by the registry. It can be used to take custom actions on resolution of the
// htlc.
type SettleResolutionResult uint8
const (
resultInvalidSettle SettleResolutionResult = iota
// ResultSettled is returned when we settle an invoice.
ResultSettled
// ResultReplayToSettled is returned when we replay a settled invoice.
ResultReplayToSettled
)
// String returns a string representation of the result.
func (s SettleResolutionResult) String() string {
switch s {
case resultInvalidSettle:
return "invalid settle result"
case ResultSettled:
return "settled"
case ResultReplayToSettled:
return "replayed htlc to settled invoice"
default:
return "unknown settle resolution result"
}
}