lnrpc: add first hop custom data to route

This commit is contained in:
Oliver Gugger committed 2024-09-05 18:00:53 +02:00
1 parent aa17543d23
commit 81c8331f82
5 files changed
+1637 -1560

No files matched your search

+1582 -1554
View File
File diff suppressed because it is too large. Load diff
+14
View File
@@ -3293,6 +3293,20 @@ message Route {
The total amount in millisatoshis.
*/
int64 total_amt_msat = 6;
/*
The actual on-chain amount that was sent out to the first hop. This value is
only different from the total_amt_msat field if this is a custom channel
payment and the value transported in the HTLC is different from the BTC
amount in the HTLC. If this value is zero, then this is an old payment that
didn't have this value yet and can be ignored.
*/
int64 first_hop_amount_msat = 7;
/*
Custom channel data that might be populated in custom channels.
*/
bytes custom_channel_data = 8;
}
message NodeInfoRequest {
+10
View File
@@ -6912,6 +6912,16 @@
"type": "string",
"format": "int64",
"description": "The total amount in millisatoshis."
},
"first_hop_amount_msat": {
"type": "string",
"format": "int64",
"description": "The actual on-chain amount that was sent out to the first hop. This value is\nonly different from the total_amt_msat field if this is a custom channel\npayment and the value transported in the HTLC is different from the BTC\namount in the HTLC. If this value is zero, then this is an old payment that\ndidn't have this value yet and can be ignored."
},
"custom_channel_data": {
"type": "string",
"format": "byte",
"description": "Custom channel data that might be populated in custom channels."
}
},
"description": "A path through the channel graph which runs over one or more channels in\nsuccession. This struct carries all the information required to craft the\nSphinx onion packet, and send the payment along the first hop in the path. A\nroute is only selected as valid if all the channels have sufficient capacity to\ncarry the initial payment amount after fees are accounted for."
+10
View File
@@ -1166,6 +1166,16 @@
"type": "string",
"format": "int64",
"description": "The total amount in millisatoshis."
},
"first_hop_amount_msat": {
"type": "string",
"format": "int64",
"description": "The actual on-chain amount that was sent out to the first hop. This value is\nonly different from the total_amt_msat field if this is a custom channel\npayment and the value transported in the HTLC is different from the BTC\namount in the HTLC. If this value is zero, then this is an old payment that\ndidn't have this value yet and can be ignored."
},
"custom_channel_data": {
"type": "string",
"format": "byte",
"description": "Custom channel data that might be populated in custom channels."
}
},
"description": "A path through the channel graph which runs over one or more channels in\nsuccession. This struct carries all the information required to craft the\nSphinx onion packet, and send the payment along the first hop in the path. A\nroute is only selected as valid if all the channels have sufficient capacity to\ncarry the initial payment amount after fees are accounted for."
+21 -6
View File
@@ -578,13 +578,28 @@ func (r *RouterBackend) rpcEdgeToPair(e *lnrpc.EdgeLocator) (
// MarshallRoute marshalls an internal route to an rpc route struct.
func (r *RouterBackend) MarshallRoute(route *route.Route) (*lnrpc.Route, error) {
resp := &lnrpc.Route{
TotalTimeLock: route.TotalTimeLock,
TotalFees: int64(route.TotalFees().ToSatoshis()),
TotalFeesMsat: int64(route.TotalFees()),
TotalAmt: int64(route.TotalAmount.ToSatoshis()),
TotalAmtMsat: int64(route.TotalAmount),
Hops: make([]*lnrpc.Hop, len(route.Hops)),
TotalTimeLock: route.TotalTimeLock,
TotalFees: int64(route.TotalFees().ToSatoshis()),
TotalFeesMsat: int64(route.TotalFees()),
TotalAmt: int64(route.TotalAmount.ToSatoshis()),
TotalAmtMsat: int64(route.TotalAmount),
Hops: make([]*lnrpc.Hop, len(route.Hops)),
FirstHopAmountMsat: int64(route.FirstHopAmount.Val.Int()),
}
// Encode the route's custom channel data (if available).
if len(route.FirstHopWireCustomRecords) > 0 {
customData, err := route.FirstHopWireCustomRecords.Serialize()
if err != nil {
return nil, err
}
resp.CustomChannelData = customData
// TODO(guggero): Feed the route into the custom data parser
// (part 3 of the mega PR series).
}
incomingAmt := route.TotalAmount
for i, hop := range route.Hops {
fee := route.HopFee(i)