mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-02 19:44:03 +02:00
Add constant and percentage-based fee limits to payments
- Extend SendRequest and QueryRoutesRequest protos - newRoute function takes fee limit and cuts off routes that exceed it - queryRoutes, payInvoice and sendPayment commands take the feeLimit inputs and pass them down to newRoute - When no feeLimit is included, don't enforce any feeLimits at all (by setting feeLimit to maxValue)
This commit is contained in:
committed by
Wilmer Paulino
parent
80b531db62
commit
6746609ec6
@ -174,9 +174,12 @@ func TestFindRoutesFeeSorting(t *testing.T) {
|
||||
|
||||
// Execute a query for all possible routes between roasbeef and luo ji.
|
||||
paymentAmt := lnwire.NewMSatFromSatoshis(100)
|
||||
feeLimit := paymentAmt.ToSatoshis()
|
||||
target := ctx.aliases["luoji"]
|
||||
routes, err := ctx.router.FindRoutes(target, paymentAmt,
|
||||
defaultNumRoutes, DefaultFinalCLTVDelta)
|
||||
routes, err := ctx.router.FindRoutes(
|
||||
target, paymentAmt, feeLimit, defaultNumRoutes,
|
||||
DefaultFinalCLTVDelta,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to find any routes: %v", err)
|
||||
}
|
||||
@ -221,12 +224,15 @@ func TestSendPaymentRouteFailureFallback(t *testing.T) {
|
||||
}
|
||||
|
||||
// Craft a LightningPayment struct that'll send a payment from roasbeef
|
||||
// to luo ji for 100 satoshis.
|
||||
// to luo ji for 1000 satoshis, with a maximum of 1000 satoshis in fees.
|
||||
var payHash [32]byte
|
||||
paymentAmt := lnwire.NewMSatFromSatoshis(1000)
|
||||
feeLimit := paymentAmt.ToSatoshis()
|
||||
payment := LightningPayment{
|
||||
Target: ctx.aliases["luoji"],
|
||||
Amount: lnwire.NewMSatFromSatoshis(1000),
|
||||
Amount: paymentAmt,
|
||||
PaymentHash: payHash,
|
||||
FeeLimit: feeLimit,
|
||||
}
|
||||
|
||||
var preImage [32]byte
|
||||
@ -524,12 +530,15 @@ func TestSendPaymentErrorPathPruning(t *testing.T) {
|
||||
}
|
||||
|
||||
// Craft a LightningPayment struct that'll send a payment from roasbeef
|
||||
// to luo ji for 100 satoshis.
|
||||
// to luo ji for 1000 satoshis, with a maximum of 1000 satoshis in fees.
|
||||
var payHash [32]byte
|
||||
paymentAmt := lnwire.NewMSatFromSatoshis(1000)
|
||||
feeLimit := paymentAmt.ToSatoshis()
|
||||
payment := LightningPayment{
|
||||
Target: ctx.aliases["luoji"],
|
||||
Amount: lnwire.NewMSatFromSatoshis(1000),
|
||||
Amount: paymentAmt,
|
||||
PaymentHash: payHash,
|
||||
FeeLimit: feeLimit,
|
||||
}
|
||||
|
||||
var preImage [32]byte
|
||||
@ -965,9 +974,12 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
|
||||
|
||||
// We should now be able to find two routes to node 2.
|
||||
paymentAmt := lnwire.NewMSatFromSatoshis(100)
|
||||
feeLimit := paymentAmt.ToSatoshis()
|
||||
targetNode := priv2.PubKey()
|
||||
routes, err := ctx.router.FindRoutes(targetNode, paymentAmt,
|
||||
defaultNumRoutes, DefaultFinalCLTVDelta)
|
||||
routes, err := ctx.router.FindRoutes(
|
||||
targetNode, paymentAmt, feeLimit, defaultNumRoutes,
|
||||
DefaultFinalCLTVDelta,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to find any routes: %v", err)
|
||||
}
|
||||
@ -1009,8 +1021,10 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
|
||||
|
||||
// Should still be able to find the routes, and the info should be
|
||||
// updated.
|
||||
routes, err = ctx.router.FindRoutes(targetNode, paymentAmt,
|
||||
defaultNumRoutes, DefaultFinalCLTVDelta)
|
||||
routes, err = ctx.router.FindRoutes(
|
||||
targetNode, paymentAmt, feeLimit, defaultNumRoutes,
|
||||
DefaultFinalCLTVDelta,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to find any routes: %v", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user