From fe66b53fb9cdf130a35123a23c75a7973f2802fa Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 12 Sep 2019 09:40:43 +0930 Subject: [PATCH] jsonrpc: add more fields to listfunds. This avoids having to correlate with listpeers for the most pertinent information. This API predates plugins, otherwise we'd have listutxos and listpeers and this would simply combine them appropriately. Still, it exists so there's little reason not to make it more friendly. Signed-off-by: Rusty Russell --- CHANGELOG.md | 3 ++- doc/lightning-listfunds.7 | 5 +++++ doc/lightning-listfunds.7.md | 3 +++ wallet/walletrpc.c | 5 +++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61e5a114a..f9f386e47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added -- JSON API: `listfunds` now lists a blockheight for confirmed transactions +- JSON API: `listfunds` now lists a blockheight for confirmed transactions, + and has `connected` and `state` fields for channels, like `listpeers`. - JSON API: `fundchannel_start` now includes field `scriptpubkey` - JSON API: `txprepare` and `withdraw` now accept an optional parameter `utxos`, a list of utxos to include in the prepared transaction diff --git a/doc/lightning-listfunds.7 b/doc/lightning-listfunds.7 index e23879cd5..a9fb6a0c1 100644 --- a/doc/lightning-listfunds.7 +++ b/doc/lightning-listfunds.7 @@ -60,6 +60,11 @@ appended\. .IP \[bu] \fIfunding_output\fR - the index of the output in the funding transaction\. +.IP \[bu] +\fIconnected\fR - whether the channel peer is connected\. +.IP \[bu] +\fIstate\fR - the channel state, in particular \fICHANNELD_NORMAL\fR means the +channel can be used normally\. .SH AUTHOR diff --git a/doc/lightning-listfunds.7.md b/doc/lightning-listfunds.7.md index d81496b30..a3267f2d9 100644 --- a/doc/lightning-listfunds.7.md +++ b/doc/lightning-listfunds.7.md @@ -45,6 +45,9 @@ Each entry in *channels* will include: - *funding\_txid* - funding transaction id. - *funding\_output* - the index of the output in the funding transaction. +- *connected* - whether the channel peer is connected. +- *state* - the channel state, in particular *CHANNELD_NORMAL* means the + channel can be used normally. AUTHOR ------ diff --git a/wallet/walletrpc.c b/wallet/walletrpc.c index 21610e1fe..ef51e50bb 100644 --- a/wallet/walletrpc.c +++ b/wallet/walletrpc.c @@ -771,6 +771,11 @@ static struct command_result *json_listfunds(struct command *cmd, list_for_each(&p->channels, c, list) { json_object_start(response, NULL); json_add_node_id(response, "peer_id", &p->id); + /* Mirrors logic in listpeers */ + json_add_bool(response, "connected", + channel_active(c) && c->connected); + json_add_string(response, "state", + channel_state_name(c)); if (c->scid) json_add_short_channel_id(response, "short_channel_id",