Merge pull request #3575 from cfromknecht/disable-str-custom-tlvs

lnrpc+routerrpc: disable custom tlv records via rpc
This commit is contained in:
Olaoluwa Osuntokun
2019-10-04 12:34:12 -07:00
committed by GitHub
4 changed files with 549 additions and 619 deletions

View File

@@ -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,
@@ -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
}
@@ -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),
@@ -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
@@ -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,
@@ -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,
@@ -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
}

File diff suppressed because it is too large Load Diff

View File

@@ -1741,14 +1741,6 @@ message QueryRoutesRequest {
A list of directed node pairs that will be ignored during path finding.
*/
repeated NodePair ignored_pairs = 10;
/**
An optional field that can be used to pass an arbitrary set of TLV records
to a peer which understands the new records. This can be used to pass
application specific data during the payment attempt. If the destination
does not support the specified recrods, and error will be returned.
*/
map<uint64, bytes> dest_tlv = 11;
}
message NodePair {
@@ -1808,17 +1800,9 @@ message Hop {
/**
If set to true, then this hop will be encoded using the new variable length
TLV format. Note that if any custom tlv_records below are specified, then
this field MUST be set to true for them to be encoded properly.
TLV format.
*/
bool tlv_payload = 9 [json_name = "tlv_payload"];
/**
An optional set of key-value TLV records. This is useful within the context
of the SendToRoute call as it allows callers to specify arbitrary K-V pairs
to drop off at each hop within the onion.
*/
map<uint64, bytes> tlv_records = 10 [json_name = "tlv_records"];
}
/**

View File

@@ -2384,15 +2384,7 @@
"tlv_payload": {
"type": "boolean",
"format": "boolean",
"description": "* \nIf set to true, then this hop will be encoded using the new variable length\nTLV format. Note that if any custom tlv_records below are specified, then\nthis field MUST be set to true for them to be encoded properly."
},
"tlv_records": {
"type": "object",
"additionalProperties": {
"type": "string",
"format": "byte"
},
"description": "*\nAn optional set of key-value TLV records. This is useful within the context\nof the SendToRoute call as it allows callers to specify arbitrary K-V pairs\nto drop off at each hop within the onion."
"description": "* \nIf set to true, then this hop will be encoded using the new variable length\nTLV format."
}
}
},