Skip to content

Commit 039f23c

Browse files
committed
multi: pass upfront fee through to request route
1 parent 6e3feb2 commit 039f23c

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

lnrpc/routerrpc/router_backend.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,7 @@ func (r *RouterBackend) extractIntentFromSendRequest(
747747
payIntent.PaymentAddr = payAddr
748748
payIntent.PaymentRequest = []byte(rpcPayReq.PaymentRequest)
749749
payIntent.Metadata = payReq.Metadata
750+
payIntent.UpfrontFeePolicy = payReq.UpfrontFeePolicy
750751
} else {
751752
// Otherwise, If the payment request field was not specified
752753
// (and a custom route wasn't specified), construct the payment

routing/payment_session.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/davecgh/go-spew/spew"
99
"github.com/lightningnetwork/lnd/build"
1010
"github.com/lightningnetwork/lnd/channeldb"
11+
"github.com/lightningnetwork/lnd/htlcswitch"
1112
"github.com/lightningnetwork/lnd/lnwire"
1213
"github.com/lightningnetwork/lnd/routing/route"
1314
)
@@ -381,6 +382,14 @@ func (p *paymentSession) RequestRoute(maxAmt, feeLimit lnwire.MilliSatoshi,
381382
// With the next candidate path found, we'll attempt to turn
382383
// this into a route by applying the time-lock and fee
383384
// requirements.
385+
var policy htlcswitch.ForwardingPolicy
386+
if p.payment.UpfrontFeePolicy != nil {
387+
policy.BaseFee = p.payment.UpfrontFeePolicy.BaseFee
388+
policy.FeeRate = lnwire.MilliSatoshi(
389+
p.payment.UpfrontFeePolicy.FeeRate,
390+
)
391+
}
392+
384393
route, err := newRoute(
385394
sourceVertex, path, height,
386395
finalHopParams{
@@ -390,6 +399,7 @@ func (p *paymentSession) RequestRoute(maxAmt, feeLimit lnwire.MilliSatoshi,
390399
records: p.payment.DestCustomRecords,
391400
paymentAddr: p.payment.PaymentAddr,
392401
metadata: p.payment.Metadata,
402+
upfrontFee: policy,
393403
},
394404
)
395405
if err != nil {

routing/router.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1994,6 +1994,10 @@ type LightningPayment struct {
19941994
// Metadata is additional data that is sent along with the payment to
19951995
// the payee.
19961996
Metadata []byte
1997+
1998+
// UpfrontFeePolicy is the upfront fee policy for the final hop in the
1999+
// route.
2000+
UpfrontFeePolicy *zpay32.UpfrontFeePolicy
19972001
}
19982002

19992003
// AMPOptions houses information that must be known in order to send an AMP

0 commit comments

Comments
 (0)