listpeers: include info on channels that are in-process
Channels that we're in negotiation for, but don't have a commitment transaction saved for yet.
This commit is contained in:
parent
c519c84ef8
commit
a23277af57
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <bitcoin/psbt.h>
|
||||
#include <bitcoin/script.h>
|
||||
#include <ccan/array_size/array_size.h>
|
||||
#include <ccan/ccan/mem/mem.h>
|
||||
#include <ccan/ccan/take/take.h>
|
||||
#include <ccan/ccan/tal/tal.h>
|
||||
|
@ -73,6 +74,52 @@ void kill_unsaved_channel(struct channel *channel,
|
|||
tal_free(channel);
|
||||
}
|
||||
|
||||
void json_add_unsaved_channel(struct json_stream *response,
|
||||
const struct channel *channel)
|
||||
{
|
||||
struct amount_msat total;
|
||||
|
||||
if (!channel)
|
||||
return;
|
||||
|
||||
/* If we're chatting but no channel, that's shown by connected: True */
|
||||
if (!channel->open_attempt)
|
||||
return;
|
||||
|
||||
json_object_start(response, NULL);
|
||||
json_add_string(response, "state", channel_state_name(channel));
|
||||
json_add_string(response, "owner", channel->owner->name);
|
||||
json_add_string(response, "opener", channel->opener == LOCAL ?
|
||||
"local" : "remote");
|
||||
json_array_start(response, "status");
|
||||
for (size_t i = 0; i < ARRAY_SIZE(channel->billboard.permanent); i++) {
|
||||
if (!channel->billboard.permanent[i])
|
||||
continue;
|
||||
json_add_string(response, NULL,
|
||||
channel->billboard.permanent[i]);
|
||||
}
|
||||
if (channel->billboard.transient)
|
||||
json_add_string(response, NULL, channel->billboard.transient);
|
||||
json_array_end(response);
|
||||
|
||||
/* These should never fail. */
|
||||
if (amount_sat_to_msat(&total, channel->open_attempt->funding)) {
|
||||
json_add_amount_msat_compat(response, total,
|
||||
"msatoshi_to_us", "to_us_msat");
|
||||
/* This will change if peer adds funds */
|
||||
json_add_amount_msat_compat(response, total,
|
||||
"msatoshi_total", "total_msat");
|
||||
}
|
||||
|
||||
json_array_start(response, "features");
|
||||
/* v2 channels assumed to have both static_remotekey + anchor_outputs */
|
||||
json_add_string(response, NULL, "option_static_remotekey");
|
||||
json_add_string(response, NULL, "option_anchor_outputs");
|
||||
json_array_end(response);
|
||||
json_object_end(response);
|
||||
}
|
||||
|
||||
|
||||
static struct channel_inflight *
|
||||
channel_current_inflight(struct channel *channel)
|
||||
{
|
||||
|
|
|
@ -21,4 +21,7 @@ void dualopen_tell_depth(struct subd *dualopend,
|
|||
u32 depth);
|
||||
void kill_unsaved_channel(struct channel *channel,
|
||||
const char *why);
|
||||
|
||||
void json_add_unsaved_channel(struct json_stream *response,
|
||||
const struct channel *channel);
|
||||
#endif /* LIGHTNING_LIGHTNINGD_DUAL_OPEN_CONTROL_H */
|
||||
|
|
|
@ -1387,8 +1387,14 @@ static void json_add_peer(struct lightningd *ld,
|
|||
json_array_start(response, "channels");
|
||||
json_add_uncommitted_channel(response, p->uncommitted_channel);
|
||||
|
||||
list_for_each(&p->channels, channel, list)
|
||||
json_add_channel(ld, response, NULL, channel);
|
||||
list_for_each(&p->channels, channel, list) {
|
||||
#if EXPERIMENTAL_FEATURES
|
||||
if (channel_unsaved(channel))
|
||||
json_add_unsaved_channel(response, channel);
|
||||
else
|
||||
#endif /* EXPERIMENTAL_FEATURES */
|
||||
json_add_channel(ld, response, NULL, channel);
|
||||
}
|
||||
json_array_end(response);
|
||||
|
||||
if (ll)
|
||||
|
|
|
@ -320,6 +320,10 @@ void json_add_txid(struct json_stream *result UNNEEDED, const char *fieldname UN
|
|||
void json_add_uncommitted_channel(struct json_stream *response UNNEEDED,
|
||||
const struct uncommitted_channel *uc UNNEEDED)
|
||||
{ fprintf(stderr, "json_add_uncommitted_channel called!\n"); abort(); }
|
||||
/* Generated stub for json_add_unsaved_channel */
|
||||
void json_add_unsaved_channel(struct json_stream *response UNNEEDED,
|
||||
const struct channel *channel UNNEEDED)
|
||||
{ fprintf(stderr, "json_add_unsaved_channel called!\n"); abort(); }
|
||||
/* Generated stub for json_array_end */
|
||||
void json_array_end(struct json_stream *js UNNEEDED)
|
||||
{ fprintf(stderr, "json_array_end called!\n"); abort(); }
|
||||
|
|
|
@ -1834,4 +1834,4 @@ struct db_query db_postgres_queries[] = {
|
|||
|
||||
#endif /* LIGHTNINGD_WALLET_GEN_DB_POSTGRES */
|
||||
|
||||
// SHA256STAMP:05cb7231674d7f4be2ca9629d185aa9f77fcbb92ffa09ec62eefbb9a4d13b414
|
||||
// SHA256STAMP:d0a5c4dda6f04a6c1b80f3226723eedd6eefef3327f6bf047546f43d3ea8ab8f
|
||||
|
|
|
@ -1834,4 +1834,4 @@ struct db_query db_sqlite3_queries[] = {
|
|||
|
||||
#endif /* LIGHTNINGD_WALLET_GEN_DB_SQLITE3 */
|
||||
|
||||
// SHA256STAMP:05cb7231674d7f4be2ca9629d185aa9f77fcbb92ffa09ec62eefbb9a4d13b414
|
||||
// SHA256STAMP:d0a5c4dda6f04a6c1b80f3226723eedd6eefef3327f6bf047546f43d3ea8ab8f
|
||||
|
|
|
@ -1202,11 +1202,11 @@ msgstr ""
|
|||
msgid "not a valid SQL statement"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/test/run-wallet.c:1414
|
||||
#: wallet/test/run-wallet.c:1418
|
||||
msgid "SELECT COUNT(1) FROM channel_funding_inflights WHERE channel_id = ?;"
|
||||
msgstr ""
|
||||
|
||||
#: wallet/test/run-wallet.c:1612
|
||||
#: wallet/test/run-wallet.c:1616
|
||||
msgid "INSERT INTO channels (id) VALUES (1);"
|
||||
msgstr ""
|
||||
# SHA256STAMP:bf5f416a1538ee73dfdedcab076dd11be8f65f5afda71a02557544fa376a391b
|
||||
# SHA256STAMP:5e6810f5b92f800a08b2e64611534d169881c270a809d96a0babf79fee9723f9
|
||||
|
|
|
@ -356,6 +356,10 @@ void json_add_u64(struct json_stream *result UNNEEDED, const char *fieldname UNN
|
|||
void json_add_uncommitted_channel(struct json_stream *response UNNEEDED,
|
||||
const struct uncommitted_channel *uc UNNEEDED)
|
||||
{ fprintf(stderr, "json_add_uncommitted_channel called!\n"); abort(); }
|
||||
/* Generated stub for json_add_unsaved_channel */
|
||||
void json_add_unsaved_channel(struct json_stream *response UNNEEDED,
|
||||
const struct channel *channel UNNEEDED)
|
||||
{ fprintf(stderr, "json_add_unsaved_channel called!\n"); abort(); }
|
||||
/* Generated stub for json_array_end */
|
||||
void json_array_end(struct json_stream *js UNNEEDED)
|
||||
{ fprintf(stderr, "json_array_end called!\n"); abort(); }
|
||||
|
|
Loading…
Reference in New Issue