mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-13 11:09:23 +01:00
routerrpc: unmarshal AMP record in route hop marshalling
This commit is contained in:
parent
4521894ed2
commit
0767a2cbc0
2 changed files with 23 additions and 0 deletions
|
@ -410,6 +410,16 @@ func testSendPaymentAMP(ht *lntest.HarnessTest) {
|
||||||
if htlc.Status == lnrpc.HTLCAttempt_SUCCEEDED {
|
if htlc.Status == lnrpc.HTLCAttempt_SUCCEEDED {
|
||||||
succeeded++
|
succeeded++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When an AMP record is expected, it will only be seen on the
|
||||||
|
// last hop of a route. So we make sure it isn't set on any of
|
||||||
|
// the hops except the last one
|
||||||
|
for _, hop := range htlc.Route.Hops[:len(htlc.Route.Hops)-1] {
|
||||||
|
require.Nil(ht, hop.AmpRecord)
|
||||||
|
}
|
||||||
|
|
||||||
|
lastHop := htlc.Route.Hops[len(htlc.Route.Hops)-1]
|
||||||
|
require.NotNil(ht, lastHop.AmpRecord)
|
||||||
}
|
}
|
||||||
|
|
||||||
const minExpectedShards = 3
|
const minExpectedShards = 3
|
||||||
|
|
|
@ -613,6 +613,18 @@ func (r *RouterBackend) MarshallRoute(route *route.Route) (*lnrpc.Route, error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var amp *lnrpc.AMPRecord
|
||||||
|
if hop.AMP != nil {
|
||||||
|
rootShare := hop.AMP.RootShare()
|
||||||
|
setID := hop.AMP.SetID()
|
||||||
|
|
||||||
|
amp = &lnrpc.AMPRecord{
|
||||||
|
RootShare: rootShare[:],
|
||||||
|
SetId: setID[:],
|
||||||
|
ChildIndex: hop.AMP.ChildIndex(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
resp.Hops[i] = &lnrpc.Hop{
|
resp.Hops[i] = &lnrpc.Hop{
|
||||||
ChanId: hop.ChannelID,
|
ChanId: hop.ChannelID,
|
||||||
ChanCapacity: int64(chanCapacity),
|
ChanCapacity: int64(chanCapacity),
|
||||||
|
@ -627,6 +639,7 @@ func (r *RouterBackend) MarshallRoute(route *route.Route) (*lnrpc.Route, error)
|
||||||
CustomRecords: hop.CustomRecords,
|
CustomRecords: hop.CustomRecords,
|
||||||
TlvPayload: !hop.LegacyPayload,
|
TlvPayload: !hop.LegacyPayload,
|
||||||
MppRecord: mpp,
|
MppRecord: mpp,
|
||||||
|
AmpRecord: amp,
|
||||||
Metadata: hop.Metadata,
|
Metadata: hop.Metadata,
|
||||||
EncryptedData: hop.EncryptedData,
|
EncryptedData: hop.EncryptedData,
|
||||||
TotalAmtMsat: uint64(hop.TotalAmtMsat),
|
TotalAmtMsat: uint64(hop.TotalAmtMsat),
|
||||||
|
|
Loading…
Add table
Reference in a new issue