Skip to content

Commit

Permalink
jsonrpc: Add aliases to listpeers result
Browse files Browse the repository at this point in the history
  • Loading branch information
cdecker committed May 25, 2022
1 parent 324424a commit 5104906
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .msggen.json
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@
"ListPeers.peers[].netaddr[]": 5
},
"ListpeersPeersChannels": {
"ListPeers.peers[].channels[].alias": 50,
"ListPeers.peers[].channels[].channel_id": 6,
"ListPeers.peers[].channels[].close_to": 14,
"ListPeers.peers[].channels[].close_to_addr": 47,
Expand Down Expand Up @@ -716,6 +717,10 @@
"ListPeers.peers[].channels[].to_us_msat": 20,
"ListPeers.peers[].channels[].total_msat": 23
},
"ListpeersPeersChannelsAlias": {
"ListPeers.peers[].channels[].alias.local": 1,
"ListPeers.peers[].channels[].alias.remote": 2
},
"ListpeersPeersChannelsFeerate": {
"ListPeers.peers[].channels[].feerate.perkb": 2,
"ListPeers.peers[].channels[].feerate.perkw": 1
Expand Down
5 changes: 5 additions & 0 deletions cln-grpc/proto/node.proto
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ message ListpeersPeersChannelsFunding {
Amount pushed_msat = 3;
}

message ListpeersPeersChannelsAlias {
optional string local = 1;
optional string remote = 2;
}

message ListpeersPeersChannelsHtlcs {
// ListPeers.peers[].channels[].htlcs[].direction
enum ListpeersPeersChannelsHtlcsDirection {
Expand Down
8 changes: 8 additions & 0 deletions cln-rpc/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,14 @@ pub mod responses {
pub pushed_msat: Amount,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ListpeersPeersChannelsAlias {
#[serde(alias = "local", skip_serializing_if = "Option::is_none")]
pub local: Option<ShortChannelId>,
#[serde(alias = "remote", skip_serializing_if = "Option::is_none")]
pub remote: Option<ShortChannelId>,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ListpeersPeersChannelsState_changes {
#[serde(alias = "timestamp")]
Expand Down
5 changes: 4 additions & 1 deletion doc/lightning-listpeers.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ On success, an object containing **peers** is returned. It is an array of objec
- **their_to_self_delay** (u32, optional): the number of blocks before they can take their funds if they unilateral close
- **our_to_self_delay** (u32, optional): the number of blocks before we can take our funds if we unilateral close
- **max_accepted_htlcs** (u32, optional): Maximum number of incoming HTLC we will accept at once
- **alias** (object, optional):
- **local** (short_channel_id, optional): An alias assigned by this node to this channel, used for outgoing payments
- **remote** (short_channel_id, optional): An alias assigned by the remote node to this channel, usable in routehints and invoices
- **state_changes** (array of objects, optional): Prior state changes:
- **timestamp** (string): UTC timestamp of form YYYY-mm-ddTHH:MM:SS.%03dZ
- **old_state** (string): Previous state (one of "OPENINGD", "CHANNELD_AWAITING_LOCKIN", "CHANNELD_NORMAL", "CHANNELD_SHUTTING_DOWN", "CLOSINGD_SIGEXCHANGE", "CLOSINGD_COMPLETE", "AWAITING_UNILATERAL", "FUNDING_SPEND_SEEN", "ONCHAIN", "DUALOPEND_OPEN_INIT", "DUALOPEND_AWAITING_LOCKIN")
Expand Down Expand Up @@ -380,4 +383,4 @@ Main web site: <https://github.com/ElementsProject/lightning> Lightning
RFC site (BOLT \#9):
<https://github.com/lightningnetwork/lightning-rfc/blob/master/09-features.md>

[comment]: # ( SHA256STAMP:65b83fce3f21b31fb12fe3793e9e77e1192c76bf3dbe827647ffc11ad9d49e45)
[comment]: # ( SHA256STAMP:01b3db09bf3eb975846e7ef3978b3b8ca7512220b1b38e499cfc309a6fb504eb)
19 changes: 19 additions & 0 deletions doc/schemas/listpeers.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,20 @@
"htlc_minimum_msat": {
"deprecated": true
},
"alias": {
"type": "object",
"required": [],
"properties": {
"local": {
"type": "short_channel_id",
"description": "An alias assigned by this node to this channel, used for outgoing payments"
},
"remote": {
"type": "short_channel_id",
"description": "An alias assigned by the remote node to this channel, usable in routehints and invoices"
}
}
},
"state_changes": {
"type": "array",
"description": "Prior state changes",
Expand Down Expand Up @@ -664,6 +678,7 @@
"payment_hash": {},
"local_trimmed": {},
"status": {},
"alias": {},
"state": {
"type": "string",
"enum": [
Expand Down Expand Up @@ -751,6 +766,7 @@
"funding_outnum": {},
"close_to": {},
"private": {},
"alias": {},
"opener": {},
"closer": {},
"features": {},
Expand Down Expand Up @@ -827,6 +843,7 @@
],
"properties": {
"state": {},
"alias": {},
"scratch_txid": {},
"feerate": {},
"owner": {},
Expand Down Expand Up @@ -911,6 +928,7 @@
"direction"
],
"properties": {
"alias": {},
"state": {},
"scratch_txid": {},
"feerate": {},
Expand Down Expand Up @@ -1002,6 +1020,7 @@
"scratch_txid": {},
"feerate": {},
"owner": {},
"alias": {},
"short_channel_id": {},
"channel_id": {},
"funding_txid": {},
Expand Down
11 changes: 11 additions & 0 deletions lightningd/peer_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,17 @@ static void json_add_channel(struct lightningd *ld,
json_add_string(response, "closer", channel->closer == LOCAL ?
"local" : "remote");

if (channel->alias[LOCAL] || channel->alias[REMOTE]) {
json_object_start(response, "alias");
if (channel->alias[LOCAL])
json_add_short_channel_id(response, "local",
channel->alias[LOCAL]);
if (channel->alias[REMOTE])
json_add_short_channel_id(response, "remote",
channel->alias[REMOTE]);
json_object_end(response);
}

json_array_start(response, "features");
if (channel_has(channel, OPT_STATIC_REMOTEKEY))
json_add_string(response, NULL, "option_static_remotekey");
Expand Down

0 comments on commit 5104906

Please sign in to comment.