mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-13 11:09:23 +01:00
channeldb: return error when payment is not found in duplicate payments
We also update the legacy code to return an error when the payment is not found.
This commit is contained in:
parent
b7d1c6666f
commit
21cecc40e1
1 changed files with 11 additions and 8 deletions
|
@ -59,22 +59,22 @@ type duplicateHTLCAttemptInfo struct {
|
|||
route route.Route
|
||||
}
|
||||
|
||||
// fetchDuplicatePaymentStatus fetches the payment status of the payment. If the
|
||||
// payment isn't found, it will default to "StatusUnknown".
|
||||
func fetchDuplicatePaymentStatus(bucket kvdb.RBucket) PaymentStatus {
|
||||
// fetchDuplicatePaymentStatus fetches the payment status of the payment. If
|
||||
// the payment isn't found, it will return error `ErrPaymentNotInitiated`.
|
||||
func fetchDuplicatePaymentStatus(bucket kvdb.RBucket) (PaymentStatus, error) {
|
||||
if bucket.Get(duplicatePaymentSettleInfoKey) != nil {
|
||||
return StatusSucceeded
|
||||
return StatusSucceeded, nil
|
||||
}
|
||||
|
||||
if bucket.Get(duplicatePaymentFailInfoKey) != nil {
|
||||
return StatusFailed
|
||||
return StatusFailed, nil
|
||||
}
|
||||
|
||||
if bucket.Get(duplicatePaymentCreationInfoKey) != nil {
|
||||
return StatusInFlight
|
||||
return StatusInFlight, nil
|
||||
}
|
||||
|
||||
return StatusUnknown
|
||||
return 0, ErrPaymentNotInitiated
|
||||
}
|
||||
|
||||
func deserializeDuplicateHTLCAttemptInfo(r io.Reader) (
|
||||
|
@ -138,7 +138,10 @@ func fetchDuplicatePayment(bucket kvdb.RBucket) (*MPPayment, error) {
|
|||
sequenceNum := binary.BigEndian.Uint64(seqBytes)
|
||||
|
||||
// Get the payment status.
|
||||
paymentStatus := fetchDuplicatePaymentStatus(bucket)
|
||||
paymentStatus, err := fetchDuplicatePaymentStatus(bucket)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Get the PaymentCreationInfo.
|
||||
b := bucket.Get(duplicatePaymentCreationInfoKey)
|
||||
|
|
Loading…
Add table
Reference in a new issue