routing: distinguish between receiver amount and total amount in newRoute

This commit is contained in:
Joost Jager 2020-03-25 14:06:48 +01:00
parent e5c7e9a38c
commit 46f5fc7400
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7
4 changed files with 7 additions and 1 deletions

View File

@ -74,6 +74,7 @@ type edgePolicyWithSource struct {
// custom records and payment address.
type finalHopParams struct {
amt lnwire.MilliSatoshi
totalAmt lnwire.MilliSatoshi
cltvDelta uint16
records record.CustomSet
paymentAddr *[32]byte
@ -177,7 +178,8 @@ func newRoute(sourceVertex route.Vertex,
// Otherwise attach the mpp record if it exists.
if finalHop.paymentAddr != nil {
mpp = record.NewMPP(
finalHop.amt, *finalHop.paymentAddr,
finalHop.totalAmt,
*finalHop.paymentAddr,
)
}
} else {

View File

@ -1327,6 +1327,7 @@ func TestNewRoute(t *testing.T) {
sourceVertex, testCase.hops, startingHeight,
finalHopParams{
amt: testCase.paymentAmount,
totalAmt: testCase.paymentAmount,
cltvDelta: finalHopCLTV,
records: nil,
paymentAddr: testCase.paymentAddr,

View File

@ -196,6 +196,7 @@ func (p *paymentSession) RequestRoute(maxAmt, feeLimit lnwire.MilliSatoshi,
sourceVertex, path, height,
finalHopParams{
amt: maxAmt,
totalAmt: maxAmt,
cltvDelta: finalCltvDelta,
records: p.payment.DestCustomRecords,
paymentAddr: p.payment.PaymentAddr,

View File

@ -1456,6 +1456,7 @@ func (r *ChannelRouter) FindRoute(source, target route.Vertex,
source, path, uint32(currentHeight),
finalHopParams{
amt: amt,
totalAmt: amt,
cltvDelta: finalExpiry,
records: destCustomRecords,
},
@ -2513,6 +2514,7 @@ func (r *ChannelRouter) BuildRoute(amt *lnwire.MilliSatoshi,
source, pathEdges, uint32(height),
finalHopParams{
amt: receiverAmt,
totalAmt: receiverAmt,
cltvDelta: uint16(finalCltvDelta),
records: nil,
},