Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 7 additions & 22 deletions lnrpc/routerrpc/router_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ func (r *RouterBackend) QueryRoutes(ctx context.Context,
ignoredPairs[pair] = struct{}{}
}

var destTLV map[uint64][]byte
restrictions := &routing.RestrictParams{
FeeLimit: feeLimit,
ProbabilitySource: func(fromNode, toNode route.Vertex,
Expand All @@ -190,13 +191,13 @@ func (r *RouterBackend) QueryRoutes(ctx context.Context,
fromNode, toNode, amt,
)
},
DestPayloadTLV: len(in.DestTlv) != 0,
DestPayloadTLV: len(destTLV) != 0,
}

// If we have any TLV records destined for the final hop, then we'll
// attempt to decode them now into a form that the router can more
// easily manipulate.
destTlvRecords, err := tlv.MapToRecords(in.DestTlv)
destTlvRecords, err := tlv.MapToRecords(destTLV)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -332,11 +333,6 @@ func (r *RouterBackend) MarshallRoute(route *route.Route) (*lnrpc.Route, error)
chanCapacity = incomingAmt.ToSatoshis()
}

tlvMap, err := tlv.RecordsToMap(hop.TLVRecords)
if err != nil {
return nil, err
}

resp.Hops[i] = &lnrpc.Hop{
ChanId: hop.ChannelID,
ChanCapacity: int64(chanCapacity),
Expand All @@ -348,7 +344,6 @@ func (r *RouterBackend) MarshallRoute(route *route.Route) (*lnrpc.Route, error)
PubKey: hex.EncodeToString(
hop.PubKeyBytes[:],
),
TlvRecords: tlvMap,
TlvPayload: !hop.LegacyPayload,
}
incomingAmt = hop.AmtToForward
Expand Down Expand Up @@ -380,10 +375,7 @@ func (r *RouterBackend) UnmarshallHopByChannelLookup(hop *lnrpc.Hop,
return nil, fmt.Errorf("channel edge does not match expected node")
}

tlvRecords, err := tlv.MapToRecords(hop.TlvRecords)
if err != nil {
return nil, err
}
var tlvRecords []tlv.Record

return &route.Hop{
OutgoingTimeLock: hop.Expiry,
Expand All @@ -408,12 +400,6 @@ func UnmarshallKnownPubkeyHop(hop *lnrpc.Hop) (*route.Hop, error) {
copy(pubKeyBytes[:], pubKey)

var tlvRecords []tlv.Record
if hop.TlvRecords != nil {
tlvRecords, err = tlv.MapToRecords(hop.TlvRecords)
if err != nil {
return nil, err
}
}

return &route.Hop{
OutgoingTimeLock: hop.Expiry,
Expand Down Expand Up @@ -501,11 +487,10 @@ func (r *RouterBackend) extractIntentFromSendRequest(
return nil, errors.New("timeout_seconds must be specified")
}

if len(rpcPayReq.DestTlv) != 0 {
var destTLV map[uint64][]byte
if len(destTLV) != 0 {
var err error
payIntent.FinalDestRecords, err = tlv.MapToRecords(
rpcPayReq.DestTlv,
)
payIntent.FinalDestRecords, err = tlv.MapToRecords(destTLV)
if err != nil {
return nil, err
}
Expand Down
Loading