mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-26 22:56:42 +02:00
channeldb: add method initializable
to decide initiating payment
This commit adds a new method, `initializable`, to help decide whether initiating a payment is allowed.
This commit is contained in:
committed by
Olaoluwa Osuntokun
parent
30fd29371c
commit
de33c3e009
@@ -151,30 +151,8 @@ func (p *PaymentControl) InitPayment(paymentHash lntypes.Hash,
|
||||
// payment. We'll check the status to decide whether we allow
|
||||
// retrying the payment or return a specific error.
|
||||
case err == nil:
|
||||
switch paymentStatus {
|
||||
// We allow retrying failed payments.
|
||||
case StatusFailed:
|
||||
|
||||
// We already have payment creation info for this
|
||||
// payment so we won't allow creating a duplicate one.
|
||||
case StatusInitiated:
|
||||
updateErr = ErrPaymentExists
|
||||
return nil
|
||||
|
||||
// We already have an InFlight payment on the network.
|
||||
// We will disallow any new payments.
|
||||
case StatusInFlight:
|
||||
updateErr = ErrPaymentInFlight
|
||||
return nil
|
||||
|
||||
// We've already succeeded a payment to this payment
|
||||
// hash, forbid the switch from sending another.
|
||||
case StatusSucceeded:
|
||||
updateErr = ErrAlreadyPaid
|
||||
return nil
|
||||
|
||||
default:
|
||||
updateErr = ErrUnknownPaymentStatus
|
||||
if err := paymentStatus.initializable(); err != nil {
|
||||
updateErr = err
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user