jsonrpc: Add aliases to listpeers result

This commit is contained in:
Christian Decker 2022-04-27 14:08:21 +02:00
parent 5e74048508
commit cdedd433a4
6 changed files with 52 additions and 1 deletions

View file

@ -669,6 +669,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,
@ -719,6 +720,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

View file

@ -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 {

View file

@ -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")]

View file

@ -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")
@ -381,4 +384,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:2e8bcc66531b2dce44b94c42852b624bdd9435cc63495fc799458fa5522f0ea9)
[comment]: # ( SHA256STAMP:fcfc465cbbe95430f4fc6473099142c576883e333ef9fe31d04372f411e49f6d)

View file

@ -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",
@ -664,6 +678,7 @@
"payment_hash": {},
"local_trimmed": {},
"status": {},
"alias": {},
"state": {
"type": "string",
"enum": [
@ -751,6 +766,7 @@
"funding_outnum": {},
"close_to": {},
"private": {},
"alias": {},
"opener": {},
"closer": {},
"features": {},
@ -827,6 +843,7 @@
],
"properties": {
"state": {},
"alias": {},
"scratch_txid": {},
"feerate": {},
"owner": {},
@ -911,6 +928,7 @@
"direction"
],
"properties": {
"alias": {},
"state": {},
"scratch_txid": {},
"feerate": {},
@ -1002,6 +1020,7 @@
"scratch_txid": {},
"feerate": {},
"owner": {},
"alias": {},
"short_channel_id": {},
"channel_id": {},
"funding_txid": {},

View file

@ -744,6 +744,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");