multi: move DBMPPayment to paymentsdb package

This commit is contained in:
ziggie
2025-08-19 17:53:56 +02:00
parent 9ac93e75ac
commit b16782caeb
4 changed files with 42 additions and 40 deletions

View File

@@ -9,38 +9,6 @@ import (
"github.com/lightningnetwork/lnd/queue"
)
// DBMPPayment is an interface derived from channeldb.MPPayment that is used by
// the payment lifecycle.
type DBMPPayment interface {
// GetState returns the current state of the payment.
GetState() *paymentsdb.MPPaymentState
// Terminated returns true if the payment is in a final state.
Terminated() bool
// GetStatus returns the current status of the payment.
GetStatus() paymentsdb.PaymentStatus
// NeedWaitAttempts specifies whether the payment needs to wait for the
// outcome of an attempt.
NeedWaitAttempts() (bool, error)
// GetHTLCs returns all HTLCs of this payment.
GetHTLCs() []paymentsdb.HTLCAttempt
// InFlightHTLCs returns all HTLCs that are in flight.
InFlightHTLCs() []paymentsdb.HTLCAttempt
// AllowMoreAttempts is used to decide whether we can safely attempt
// more HTLCs for a given payment state. Return an error if the payment
// is in an unexpected state.
AllowMoreAttempts() (bool, error)
// TerminalInfo returns the settled HTLC attempt or the payment's
// failure reason.
TerminalInfo() (*paymentsdb.HTLCAttempt, *paymentsdb.FailureReason)
}
// ControlTower tracks all outgoing payments made, whose primary purpose is to
// prevent duplicate payments to the same payment hash. In production, a
// persistent implementation is preferred so that tracking can survive across
@@ -76,7 +44,7 @@ type ControlTower interface {
// FetchPayment fetches the payment corresponding to the given payment
// hash.
FetchPayment(paymentHash lntypes.Hash) (DBMPPayment, error)
FetchPayment(paymentHash lntypes.Hash) (paymentsdb.DBMPPayment, error)
// FailPayment transitions a payment into the Failed state, and records
// the ultimate reason the payment failed. Note that this should only
@@ -273,7 +241,7 @@ func (p *controlTower) FailAttempt(paymentHash lntypes.Hash,
// FetchPayment fetches the payment corresponding to the given payment hash.
func (p *controlTower) FetchPayment(paymentHash lntypes.Hash) (
DBMPPayment, error) {
paymentsdb.DBMPPayment, error) {
return p.db.FetchPayment(paymentHash)
}