mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-23 22:46:40 +01:00
lnrpc: add first hop custom data to route
This commit is contained in:
parent
444ef199a6
commit
1822b2f79a
5 changed files with 1637 additions and 1560 deletions
File diff suppressed because it is too large
Load diff
|
@ -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 {
|
||||
|
|
|
@ -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."
|
||||
|
|
|
@ -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."
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue