multi: move PaymentCreationInfo to payment pkg

This commit is contained in:
ziggie committed 2025-08-14 19:53:18 +02:00
1 parent d138e23919
commit df9bac2ecf
11 files changed
+58 -75

No files matched your search

+2 -3
View File
@@ -3,7 +3,6 @@ package routing
import (
"sync"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/multimutex"
paymentsdb "github.com/lightningnetwork/lnd/payments/db"
@@ -50,7 +49,7 @@ type DBMPPayment interface {
type ControlTower interface {
// This method checks that no succeeded payment exist for this payment
// hash.
InitPayment(lntypes.Hash, *channeldb.PaymentCreationInfo) error
InitPayment(lntypes.Hash, *paymentsdb.PaymentCreationInfo) error
// DeleteFailedAttempts removes all failed HTLCs from the db. It should
// be called for a given payment whenever all inflight htlcs are
@@ -185,7 +184,7 @@ func NewControlTower(db *paymentsdb.KVPaymentsDB) ControlTower {
// method returns successfully, the payment is guaranteed to be in the
// Initiated state.
func (p *controlTower) InitPayment(paymentHash lntypes.Hash,
info *channeldb.PaymentCreationInfo) error {
info *paymentsdb.PaymentCreationInfo) error {
err := p.db.InitPayment(paymentHash, info)
if err != nil {
+2 -2
View File
@@ -559,7 +559,7 @@ func initDB(t *testing.T) *channeldb.DB {
)
}
func genInfo() (*channeldb.PaymentCreationInfo, *paymentsdb.HTLCAttemptInfo,
func genInfo() (*paymentsdb.PaymentCreationInfo, *paymentsdb.HTLCAttemptInfo,
lntypes.Preimage, error) {
preimage, err := genPreimage()
@@ -579,7 +579,7 @@ func genInfo() (*channeldb.PaymentCreationInfo, *paymentsdb.HTLCAttemptInfo,
return nil, nil, lntypes.Preimage{}, err
}
return &channeldb.PaymentCreationInfo{
return &paymentsdb.PaymentCreationInfo{
PaymentIdentifier: rhash,
Value: testRoute.ReceiverAmt(),
CreationTime: time.Unix(time.Now().Unix(), 0),
+4 -5
View File
@@ -7,7 +7,6 @@ import (
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/graph/db/models"
"github.com/lightningnetwork/lnd/htlcswitch"
@@ -248,7 +247,7 @@ func (m *mockPayerOld) CleanStore(pids map[uint64]struct{}) error {
}
type initArgs struct {
c *channeldb.PaymentCreationInfo
c *paymentsdb.PaymentCreationInfo
}
type registerAttemptArgs struct {
@@ -268,7 +267,7 @@ type failPaymentArgs struct {
}
type testPayment struct {
info channeldb.PaymentCreationInfo
info paymentsdb.PaymentCreationInfo
attempts []paymentsdb.HTLCAttempt
}
@@ -298,7 +297,7 @@ func makeMockControlTower() *mockControlTowerOld {
}
func (m *mockControlTowerOld) InitPayment(phash lntypes.Hash,
c *channeldb.PaymentCreationInfo) error {
c *paymentsdb.PaymentCreationInfo) error {
if m.init != nil {
m.init <- initArgs{c}
@@ -733,7 +732,7 @@ type mockControlTower struct {
var _ ControlTower = (*mockControlTower)(nil)
func (m *mockControlTower) InitPayment(phash lntypes.Hash,
c *channeldb.PaymentCreationInfo) error {
c *paymentsdb.PaymentCreationInfo) error {
args := m.Called(phash, c)
return args.Error(0)
+2 -3
View File
@@ -15,7 +15,6 @@ import (
"github.com/btcsuite/btcd/btcutil"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lnd/amp"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/clock"
"github.com/lightningnetwork/lnd/fn/v2"
"github.com/lightningnetwork/lnd/graph/db/models"
@@ -999,7 +998,7 @@ func (r *ChannelRouter) PreparePayment(payment *LightningPayment) (
// already in-flight.
//
// TODO(roasbeef): store records as part of creation info?
info := &channeldb.PaymentCreationInfo{
info := &paymentsdb.PaymentCreationInfo{
PaymentIdentifier: payment.Identifier(),
Value: payment.Amount,
CreationTime: r.cfg.Clock.Now(),
@@ -1122,7 +1121,7 @@ func (r *ChannelRouter) sendToRoute(htlcHash lntypes.Hash, rt *route.Route,
// Record this payment hash with the ControlTower, ensuring it is not
// already in-flight.
info := &channeldb.PaymentCreationInfo{
info := &paymentsdb.PaymentCreationInfo{
PaymentIdentifier: paymentIdentifier,
Value: amt,
CreationTime: r.cfg.Clock.Now(),