@@ -11,6 +11,7 @@ import (
11
11
"github.com/lightningnetwork/lnd/kvdb"
12
12
"github.com/lightningnetwork/lnd/lntypes"
13
13
"github.com/lightningnetwork/lnd/lnwire"
14
+ pymtpkg "github.com/lightningnetwork/lnd/payments"
14
15
"github.com/lightningnetwork/lnd/routing/route"
15
16
)
16
17
@@ -61,20 +62,20 @@ type duplicateHTLCAttemptInfo struct {
61
62
62
63
// fetchDuplicatePaymentStatus fetches the payment status of the payment. If
63
64
// the payment isn't found, it will return error `ErrPaymentNotInitiated`.
64
- func fetchDuplicatePaymentStatus (bucket kvdb.RBucket ) (PaymentStatus , error ) {
65
+ func fetchDuplicatePaymentStatus (bucket kvdb.RBucket ) (pymtpkg. PaymentStatus , error ) {
65
66
if bucket .Get (duplicatePaymentSettleInfoKey ) != nil {
66
- return StatusSucceeded , nil
67
+ return pymtpkg . StatusSucceeded , nil
67
68
}
68
69
69
70
if bucket .Get (duplicatePaymentFailInfoKey ) != nil {
70
- return StatusFailed , nil
71
+ return pymtpkg . StatusFailed , nil
71
72
}
72
73
73
74
if bucket .Get (duplicatePaymentCreationInfoKey ) != nil {
74
- return StatusInFlight , nil
75
+ return pymtpkg . StatusInFlight , nil
75
76
}
76
77
77
- return 0 , ErrPaymentNotInitiated
78
+ return 0 , pymtpkg . ErrPaymentNotInitiated
78
79
}
79
80
80
81
func deserializeDuplicateHTLCAttemptInfo (r io.Reader ) (
@@ -93,11 +94,11 @@ func deserializeDuplicateHTLCAttemptInfo(r io.Reader) (
93
94
}
94
95
95
96
func deserializeDuplicatePaymentCreationInfo (r io.Reader ) (
96
- * PaymentCreationInfo , error ) {
97
+ * pymtpkg. PaymentCreationInfo , error ) {
97
98
98
99
var scratch [8 ]byte
99
100
100
- c := & PaymentCreationInfo {}
101
+ c := & pymtpkg. PaymentCreationInfo {}
101
102
102
103
if _ , err := io .ReadFull (r , c .PaymentIdentifier [:]); err != nil {
103
104
return nil , err
@@ -129,7 +130,7 @@ func deserializeDuplicatePaymentCreationInfo(r io.Reader) (
129
130
return c , nil
130
131
}
131
132
132
- func fetchDuplicatePayment (bucket kvdb.RBucket ) (* MPPayment , error ) {
133
+ func fetchDuplicatePayment (bucket kvdb.RBucket ) (* pymtpkg. MPPayment , error ) {
133
134
seqBytes := bucket .Get (duplicatePaymentSequenceKey )
134
135
if seqBytes == nil {
135
136
return nil , fmt .Errorf ("sequence number not found" )
@@ -156,14 +157,14 @@ func fetchDuplicatePayment(bucket kvdb.RBucket) (*MPPayment, error) {
156
157
}
157
158
158
159
// Get failure reason if available.
159
- var failureReason * FailureReason
160
+ var failureReason * pymtpkg. FailureReason
160
161
b = bucket .Get (duplicatePaymentFailInfoKey )
161
162
if b != nil {
162
- reason := FailureReason (b [0 ])
163
+ reason := pymtpkg . FailureReason (b [0 ])
163
164
failureReason = & reason
164
165
}
165
166
166
- payment := & MPPayment {
167
+ payment := & pymtpkg. MPPayment {
167
168
SequenceNum : sequenceNum ,
168
169
Info : creationInfo ,
169
170
FailureReason : failureReason ,
@@ -179,13 +180,13 @@ func fetchDuplicatePayment(bucket kvdb.RBucket) (*MPPayment, error) {
179
180
return nil , err
180
181
}
181
182
182
- htlc := HTLCAttempt {
183
- HTLCAttemptInfo : HTLCAttemptInfo {
184
- AttemptID : attempt .attemptID ,
185
- Route : attempt .route ,
186
- sessionKey : attempt .sessionKey ,
183
+ htlc := pymtpkg.HTLCAttempt {
184
+ HTLCAttemptInfo : pymtpkg.HTLCAttemptInfo {
185
+ AttemptID : attempt .attemptID ,
186
+ Route : attempt .route ,
187
187
},
188
188
}
189
+ htlc .SetSessionKey (attempt .sessionKey )
189
190
190
191
// Get the payment preimage. This is only found for
191
192
// successful payments.
@@ -194,27 +195,27 @@ func fetchDuplicatePayment(bucket kvdb.RBucket) (*MPPayment, error) {
194
195
var preimg lntypes.Preimage
195
196
copy (preimg [:], b )
196
197
197
- htlc .Settle = & HTLCSettleInfo {
198
+ htlc .Settle = & pymtpkg. HTLCSettleInfo {
198
199
Preimage : preimg ,
199
200
SettleTime : time.Time {},
200
201
}
201
202
} else {
202
203
// Otherwise the payment must have failed.
203
- htlc .Failure = & HTLCFailInfo {
204
+ htlc .Failure = & pymtpkg. HTLCFailInfo {
204
205
FailTime : time.Time {},
205
206
}
206
207
}
207
208
208
- payment .HTLCs = []HTLCAttempt {htlc }
209
+ payment .HTLCs = []pymtpkg. HTLCAttempt {htlc }
209
210
}
210
211
211
212
return payment , nil
212
213
}
213
214
214
- func fetchDuplicatePayments (paymentHashBucket kvdb. RBucket ) ([] * MPPayment ,
215
- error ) {
215
+ func fetchDuplicatePayments (
216
+ paymentHashBucket kvdb. RBucket ) ([] * pymtpkg. MPPayment , error ) {
216
217
217
- var payments []* MPPayment
218
+ var payments []* pymtpkg. MPPayment
218
219
219
220
// For older versions of lnd, duplicate payments to a payment has was
220
221
// possible. These will be found in a sub-bucket indexed by their
0 commit comments