Skip to content

[bug]: routerClient.BuildRoute does not consider inbound fees #8814

@silenzara

Description

@silenzara

Background

Using routerClient.BuildRoute to create a route does not produce routes that use any fee discounts.

Your environment

  • LND 0.18.0-beta commit=v0.18.0-beta (commit: fed7609)

Steps to reproduce

Find a route via lnClient.QueryRoutes until one is found with a hop that has negative inbound fees. Reconstruct same route using the pubkeys from the original route that QueryRoutes returned:

	for _, hop := range originalRoute.Hops {
		pk, _ := hex.DecodeString(hop.PubKey)
		pks = append(pks, pk)
	}

	sameRoute, err := satty.routerClient.BuildRoute(ctx, &routerrpc.BuildRouteRequest{
		AmtMsat:        sats * 1000,
		HopPubkeys:     pks,
		FinalCltvDelta: final,
	})

Expected behaviour

routerClient.BuildRoute should return the same route as the lnClient.QueryRoutes one with the same discounted fees.

Actual behaviour

Code:

fmt.Printf("via lnClient.QueryRoutes\n")
for n, hop := range originalRoute.Hops {
	fmt.Printf("%d - %s | Hop fee: %d\n", n, hop.PubKey, hop.FeeMsat)
}

fmt.Printf("Total fee: %d\n", originalRoute.TotalFeesMsat)

fmt.Printf("\n----\n\n")

fmt.Printf("via routerClient.BuildRoute, same pubkeys\n")
for n, hop := range sameRoute.Route.Hops {
	fmt.Printf("%d - %s | Hop fee: %d\n", n, hop.PubKey, hop.FeeMsat)
}

fmt.Printf("Total fee: %d\n", sameRoute.Route.TotalFeesMsat)

Debug output:

via lnClient.QueryRoutes
0 - 02e46fce29587e4a8d39da2cf21f032536c1ced45e82e4ba04f127ee7337783b38 | Hop fee: 0
1 - 03423790614f023e3c0cdaa654a3578e919947e4c3a14bf5044e7c787ebd11af1a | Hop fee: 0
2 - 033b63e4a9931dc151037acbce12f4f8968c86f5655cf102bbfa85a26bd4adc6d9 | Hop fee: 240771
3 - 037f990e61acee8a7697966afd29dd88f3b1f8a7b14d625c4f8742bd952003a590 | Hop fee: 1185
4 - 027ce055380348d7812d2ae7745701c9f93e70c1adeb2657f053f91df4f2843c71 | Hop fee: 51340
5 - 021c97a90a411ff2b10dc2a8e32de2f29d2fa49d41bfbb52bd416e460db0747d0d | Hop fee: 1000
6 - 03a93b87bf9f052b8e862d51ebbac4ce5e97b5f4137563cd5128548d7f5978dda9 | Hop fee: 0
Total fee: 294296

----

via routerClient.BuildRoute, same pubkeys
0 - 02e46fce29587e4a8d39da2cf21f032536c1ced45e82e4ba04f127ee7337783b38 | Hop fee: 0
1 - 03423790614f023e3c0cdaa654a3578e919947e4c3a14bf5044e7c787ebd11af1a | Hop fee: 0
2 - 033b63e4a9931dc151037acbce12f4f8968c86f5655cf102bbfa85a26bd4adc6d9 | Hop fee: 240945
3 - 037f990e61acee8a7697966afd29dd88f3b1f8a7b14d625c4f8742bd952003a590 | Hop fee: 1185
4 - 027ce055380348d7812d2ae7745701c9f93e70c1adeb2657f053f91df4f2843c71 | Hop fee: 185156
5 - 021c97a90a411ff2b10dc2a8e32de2f29d2fa49d41bfbb52bd416e460db0747d0d | Hop fee: 1000
6 - 03a93b87bf9f052b8e862d51ebbac4ce5e97b5f4137563cd5128548d7f5978dda9 | Hop fee: 0
Total fee: 428286

Metadata

Metadata

Assignees

Labels

P2should be fixed if one has timebugUnintended code behaviourinbound feeChanges related to inbound routing feerouting

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions