channeldb/migration_01_to_11: isolate route structure

Before we change the Hop struct, isolate the code that is used in older
migrations to prevent breaking them.

route.go was taken from commit 6e463c1634
This commit is contained in:
Joost Jager
2019-12-11 10:20:55 +01:00
parent 62dadff291
commit 7aa4a7c7fc
6 changed files with 362 additions and 37 deletions

View File

@@ -9,7 +9,6 @@ import (
"github.com/btcsuite/btcd/btcec"
"github.com/coreos/bbolt"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing/route"
)
// MigrateNodeAndEdgeUpdateIndex is a migration function that will update the
@@ -817,14 +816,14 @@ func MigrateOutgoingPayments(tx *bbolt.Tx) error {
// Do the same for the PaymentAttemptInfo.
totalAmt := payment.Terms.Value + payment.Fee
rt := route.Route{
rt := Route{
TotalTimeLock: payment.TimeLockLength,
TotalAmount: totalAmt,
SourcePubKey: sourcePubKey,
Hops: []*route.Hop{},
Hops: []*Hop{},
}
for _, hop := range payment.Path {
rt.Hops = append(rt.Hops, &route.Hop{
rt.Hops = append(rt.Hops, &Hop{
PubKeyBytes: hop,
AmtToForward: totalAmt,
})