mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-22 14:22:37 +01:00
rpcserver: expose graph tlv data
This commit is contained in:
parent
0663a92bff
commit
6e073cb213
6 changed files with 1749 additions and 1594 deletions
|
@ -46,6 +46,10 @@
|
||||||
skipped by specifying `skip_peer_alias_lookup`. `lncli fwdinghistory` also
|
skipped by specifying `skip_peer_alias_lookup`. `lncli fwdinghistory` also
|
||||||
adds a flag `skip_peer_alias_lookup` to skip the lookup.
|
adds a flag `skip_peer_alias_lookup` to skip the lookup.
|
||||||
|
|
||||||
|
* The graph lookups method `DescribeGraph`, `GetNodeInfo` and `GetChanInfo` now
|
||||||
|
[expose tlv data](https://github.com/lightningnetwork/lnd/pull/7085) that is
|
||||||
|
broadcast over the gossip network.
|
||||||
|
|
||||||
## Wallet
|
## Wallet
|
||||||
|
|
||||||
* [Allows Taproot public keys and tap scripts to be imported as watch-only
|
* [Allows Taproot public keys and tap scripts to be imported as watch-only
|
||||||
|
|
|
@ -84,6 +84,14 @@
|
||||||
},
|
},
|
||||||
"node2_policy": {
|
"node2_policy": {
|
||||||
"$ref": "#/definitions/lnrpcRoutingPolicy"
|
"$ref": "#/definitions/lnrpcRoutingPolicy"
|
||||||
|
},
|
||||||
|
"custom_records": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "byte"
|
||||||
|
},
|
||||||
|
"description": "Custom channel announcement tlv records."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"description": "A fully authenticated channel along with all its unique attributes.\nOnce an authenticated channel announcement has been processed on the network,\nthen an instance of ChannelEdgeInfo encapsulating the channels attributes is\nstored. The other portions relevant to routing policy of a channel are stored\nwithin a ChannelEdgePolicy for each direction of the channel."
|
"description": "A fully authenticated channel along with all its unique attributes.\nOnce an authenticated channel announcement has been processed on the network,\nthen an instance of ChannelEdgeInfo encapsulating the channels attributes is\nstored. The other portions relevant to routing policy of a channel are stored\nwithin a ChannelEdgePolicy for each direction of the channel."
|
||||||
|
@ -149,6 +157,14 @@
|
||||||
"additionalProperties": {
|
"additionalProperties": {
|
||||||
"$ref": "#/definitions/lnrpcFeature"
|
"$ref": "#/definitions/lnrpcFeature"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"custom_records": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "byte"
|
||||||
|
},
|
||||||
|
"description": "Custom node announcement tlv records."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"description": "An individual vertex/node within the channel graph. A node is\nconnected to other nodes by one or more channel edges emanating from it. As the\ngraph is directed, a node will also have an incoming edge attached to it for\neach outgoing edge."
|
"description": "An individual vertex/node within the channel graph. A node is\nconnected to other nodes by one or more channel edges emanating from it. As the\ngraph is directed, a node will also have an incoming edge attached to it for\neach outgoing edge."
|
||||||
|
@ -193,6 +209,14 @@
|
||||||
"last_update": {
|
"last_update": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"format": "int64"
|
"format": "int64"
|
||||||
|
},
|
||||||
|
"custom_records": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "byte"
|
||||||
|
},
|
||||||
|
"description": "Custom channel update tlv records."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3054,6 +3054,9 @@ message LightningNode {
|
||||||
repeated NodeAddress addresses = 4;
|
repeated NodeAddress addresses = 4;
|
||||||
string color = 5;
|
string color = 5;
|
||||||
map<uint32, Feature> features = 6;
|
map<uint32, Feature> features = 6;
|
||||||
|
|
||||||
|
// Custom node announcement tlv records.
|
||||||
|
map<uint64, bytes> custom_records = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
message NodeAddress {
|
message NodeAddress {
|
||||||
|
@ -3069,6 +3072,9 @@ message RoutingPolicy {
|
||||||
bool disabled = 5;
|
bool disabled = 5;
|
||||||
uint64 max_htlc_msat = 6;
|
uint64 max_htlc_msat = 6;
|
||||||
uint32 last_update = 7;
|
uint32 last_update = 7;
|
||||||
|
|
||||||
|
// Custom channel update tlv records.
|
||||||
|
map<uint64, bytes> custom_records = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -3096,6 +3102,9 @@ message ChannelEdge {
|
||||||
|
|
||||||
RoutingPolicy node1_policy = 7;
|
RoutingPolicy node1_policy = 7;
|
||||||
RoutingPolicy node2_policy = 8;
|
RoutingPolicy node2_policy = 8;
|
||||||
|
|
||||||
|
// Custom channel announcement tlv records.
|
||||||
|
map<uint64, bytes> custom_records = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ChannelGraphRequest {
|
message ChannelGraphRequest {
|
||||||
|
|
|
@ -3845,6 +3845,14 @@
|
||||||
},
|
},
|
||||||
"node2_policy": {
|
"node2_policy": {
|
||||||
"$ref": "#/definitions/lnrpcRoutingPolicy"
|
"$ref": "#/definitions/lnrpcRoutingPolicy"
|
||||||
|
},
|
||||||
|
"custom_records": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "byte"
|
||||||
|
},
|
||||||
|
"description": "Custom channel announcement tlv records."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"description": "A fully authenticated channel along with all its unique attributes.\nOnce an authenticated channel announcement has been processed on the network,\nthen an instance of ChannelEdgeInfo encapsulating the channels attributes is\nstored. The other portions relevant to routing policy of a channel are stored\nwithin a ChannelEdgePolicy for each direction of the channel."
|
"description": "A fully authenticated channel along with all its unique attributes.\nOnce an authenticated channel announcement has been processed on the network,\nthen an instance of ChannelEdgeInfo encapsulating the channels attributes is\nstored. The other portions relevant to routing policy of a channel are stored\nwithin a ChannelEdgePolicy for each direction of the channel."
|
||||||
|
@ -5210,6 +5218,14 @@
|
||||||
"additionalProperties": {
|
"additionalProperties": {
|
||||||
"$ref": "#/definitions/lnrpcFeature"
|
"$ref": "#/definitions/lnrpcFeature"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"custom_records": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "byte"
|
||||||
|
},
|
||||||
|
"description": "Custom node announcement tlv records."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"description": "An individual vertex/node within the channel graph. A node is\nconnected to other nodes by one or more channel edges emanating from it. As the\ngraph is directed, a node will also have an incoming edge attached to it for\neach outgoing edge."
|
"description": "An individual vertex/node within the channel graph. A node is\nconnected to other nodes by one or more channel edges emanating from it. As the\ngraph is directed, a node will also have an incoming edge attached to it for\neach outgoing edge."
|
||||||
|
@ -6443,6 +6459,14 @@
|
||||||
"last_update": {
|
"last_update": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"format": "int64"
|
"format": "int64"
|
||||||
|
},
|
||||||
|
"custom_records": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "byte"
|
||||||
|
},
|
||||||
|
"description": "Custom channel update tlv records."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
54
rpcserver.go
54
rpcserver.go
|
@ -71,6 +71,7 @@ import (
|
||||||
"github.com/lightningnetwork/lnd/rpcperms"
|
"github.com/lightningnetwork/lnd/rpcperms"
|
||||||
"github.com/lightningnetwork/lnd/signal"
|
"github.com/lightningnetwork/lnd/signal"
|
||||||
"github.com/lightningnetwork/lnd/sweep"
|
"github.com/lightningnetwork/lnd/sweep"
|
||||||
|
"github.com/lightningnetwork/lnd/tlv"
|
||||||
"github.com/lightningnetwork/lnd/watchtower"
|
"github.com/lightningnetwork/lnd/watchtower"
|
||||||
"github.com/lightningnetwork/lnd/zpay32"
|
"github.com/lightningnetwork/lnd/zpay32"
|
||||||
"github.com/tv42/zbase32"
|
"github.com/tv42/zbase32"
|
||||||
|
@ -5716,6 +5717,30 @@ func (r *rpcServer) DescribeGraph(ctx context.Context,
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// marshalExtraOpaqueData marshals the given tlv data. If the tlv stream is
|
||||||
|
// malformed or empty, an empty map is returned. This makes the method safe to
|
||||||
|
// use on unvalidated data.
|
||||||
|
func marshalExtraOpaqueData(data []byte) map[uint64][]byte {
|
||||||
|
r := bytes.NewReader(data)
|
||||||
|
|
||||||
|
tlvStream, err := tlv.NewStream()
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
parsedTypes, err := tlvStream.DecodeWithParsedTypes(r)
|
||||||
|
if err != nil || len(parsedTypes) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
records := make(map[uint64][]byte)
|
||||||
|
for k, v := range parsedTypes {
|
||||||
|
records[uint64(k)] = v
|
||||||
|
}
|
||||||
|
|
||||||
|
return records
|
||||||
|
}
|
||||||
|
|
||||||
func marshalDbEdge(edgeInfo *channeldb.ChannelEdgeInfo,
|
func marshalDbEdge(edgeInfo *channeldb.ChannelEdgeInfo,
|
||||||
c1, c2 *channeldb.ChannelEdgePolicy) *lnrpc.ChannelEdge {
|
c1, c2 *channeldb.ChannelEdgePolicy) *lnrpc.ChannelEdge {
|
||||||
|
|
||||||
|
@ -5735,14 +5760,17 @@ func marshalDbEdge(edgeInfo *channeldb.ChannelEdgeInfo,
|
||||||
lastUpdate = c2.LastUpdate.Unix()
|
lastUpdate = c2.LastUpdate.Unix()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
customRecords := marshalExtraOpaqueData(edgeInfo.ExtraOpaqueData)
|
||||||
|
|
||||||
edge := &lnrpc.ChannelEdge{
|
edge := &lnrpc.ChannelEdge{
|
||||||
ChannelId: edgeInfo.ChannelID,
|
ChannelId: edgeInfo.ChannelID,
|
||||||
ChanPoint: edgeInfo.ChannelPoint.String(),
|
ChanPoint: edgeInfo.ChannelPoint.String(),
|
||||||
// TODO(roasbeef): update should be on edge info itself
|
// TODO(roasbeef): update should be on edge info itself
|
||||||
LastUpdate: uint32(lastUpdate),
|
LastUpdate: uint32(lastUpdate),
|
||||||
Node1Pub: hex.EncodeToString(edgeInfo.NodeKey1Bytes[:]),
|
Node1Pub: hex.EncodeToString(edgeInfo.NodeKey1Bytes[:]),
|
||||||
Node2Pub: hex.EncodeToString(edgeInfo.NodeKey2Bytes[:]),
|
Node2Pub: hex.EncodeToString(edgeInfo.NodeKey2Bytes[:]),
|
||||||
Capacity: int64(edgeInfo.Capacity),
|
Capacity: int64(edgeInfo.Capacity),
|
||||||
|
CustomRecords: customRecords,
|
||||||
}
|
}
|
||||||
|
|
||||||
if c1 != nil {
|
if c1 != nil {
|
||||||
|
@ -5761,6 +5789,8 @@ func marshalDBRoutingPolicy(
|
||||||
|
|
||||||
disabled := policy.ChannelFlags&lnwire.ChanUpdateDisabled != 0
|
disabled := policy.ChannelFlags&lnwire.ChanUpdateDisabled != 0
|
||||||
|
|
||||||
|
customRecords := marshalExtraOpaqueData(policy.ExtraOpaqueData)
|
||||||
|
|
||||||
return &lnrpc.RoutingPolicy{
|
return &lnrpc.RoutingPolicy{
|
||||||
TimeLockDelta: uint32(policy.TimeLockDelta),
|
TimeLockDelta: uint32(policy.TimeLockDelta),
|
||||||
MinHtlc: int64(policy.MinHTLC),
|
MinHtlc: int64(policy.MinHTLC),
|
||||||
|
@ -5769,6 +5799,7 @@ func marshalDBRoutingPolicy(
|
||||||
FeeRateMilliMsat: int64(policy.FeeProportionalMillionths),
|
FeeRateMilliMsat: int64(policy.FeeProportionalMillionths),
|
||||||
Disabled: disabled,
|
Disabled: disabled,
|
||||||
LastUpdate: uint32(policy.LastUpdate.Unix()),
|
LastUpdate: uint32(policy.LastUpdate.Unix()),
|
||||||
|
CustomRecords: customRecords,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5931,13 +5962,16 @@ func marshalNode(node *channeldb.LightningNode) *lnrpc.LightningNode {
|
||||||
|
|
||||||
features := invoicesrpc.CreateRPCFeatures(node.Features)
|
features := invoicesrpc.CreateRPCFeatures(node.Features)
|
||||||
|
|
||||||
|
customRecords := marshalExtraOpaqueData(node.ExtraOpaqueData)
|
||||||
|
|
||||||
return &lnrpc.LightningNode{
|
return &lnrpc.LightningNode{
|
||||||
LastUpdate: uint32(node.LastUpdate.Unix()),
|
LastUpdate: uint32(node.LastUpdate.Unix()),
|
||||||
PubKey: hex.EncodeToString(node.PubKeyBytes[:]),
|
PubKey: hex.EncodeToString(node.PubKeyBytes[:]),
|
||||||
Addresses: nodeAddrs,
|
Addresses: nodeAddrs,
|
||||||
Alias: node.Alias,
|
Alias: node.Alias,
|
||||||
Color: routing.EncodeHexColor(node.Color),
|
Color: routing.EncodeHexColor(node.Color),
|
||||||
Features: features,
|
Features: features,
|
||||||
|
CustomRecords: customRecords,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue