lightningd: prepare internal json routines for listpeerchannels.

We're soon going to call json_add_unsaved_channel and
json_add_uncommitted_channel from a new place, where we want the peer
state directly included.

Based on patch by @vincenzopalazzo.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2023-01-12 11:45:10 +10:30
parent 300f732bbe
commit 1d8b899551
7 changed files with 44 additions and 12 deletions

View File

@@ -32,9 +32,12 @@
#include <wally_psbt.h>
void json_add_uncommitted_channel(struct json_stream *response,
const struct uncommitted_channel *uc)
const struct uncommitted_channel *uc,
/* Only set for listpeerchannels */
const struct peer *peer)
{
struct amount_msat total, ours;
if (!uc)
return;
@@ -43,6 +46,10 @@ void json_add_uncommitted_channel(struct json_stream *response,
return;
json_object_start(response, NULL);
if (peer) {
json_add_node_id(response, "peer_id", &peer->id);
json_add_bool(response, "peer_connected", peer->connected == PEER_CONNECTED);
}
json_add_string(response, "state", "OPENINGD");
json_add_string(response, "owner", "lightning_openingd");
json_add_string(response, "opener", "local");