-
Notifications
You must be signed in to change notification settings - Fork 906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
listpeers: add features
array using BOLT9 names.
#3963
listpeers: add features
array using BOLT9 names.
#3963
Conversation
It's actually not possible to currently tell if you're using anchor_outputs with a peer (since it depends on whether you both supported it at *channel open*). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-added: JSON-RPC: `listpeers` shows `features` list for each channel.
be979eb
to
07b328d
Compare
@@ -155,6 +155,18 @@ void json_add_uncommitted_channel(struct json_stream *response, | |||
json_add_amount_msat_compat(response, total, | |||
"msatoshi_total", "total_msat"); | |||
} | |||
|
|||
json_array_start(response, "features"); | |||
if (feature_negotiated(uc->peer->ld->our_features, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it not be better (and more easy to extend with new features in the future) to have an array of structs like so?
static const struct { const char *name; size_t feature; } known_features[] = {
{ "option_static_remotekey", OPT_STATIC_REMOTEKEY},
{ "option_anchor_outputs", OPT_ANCHOR_OUTPUTS}
};
Then just iterate:
for (size_t i = 0; i < ARRAY_SIZE(known_features); ++i)
if (feature_negotiated(our_features, their_features, known_features[i].feature))
json_add_string(response, NULL, known_features[i].name);
Also, is not their_features
set on init
message, and the peer could be initially an old software, create channel with us pre-anchor-commitments, then upgrade so they now both support anchor-commitments but the actual channel is not using anchor commitments yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably include the feature names in the per-peer part of the JSON output, yes, but that information is technically redundant (since you can find out our features and their features already, by bitmap).
But these two features are sticky based on what was negotiated at opening time, so you can't intuit them by looking at currently negotiated features. Hence these test the flag directly, (from the db).
There's a proposal to upgrade on-the-fly, which would also Just Work with this API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 07b328d
It's actually not possible to currently tell if you're using anchor_outputs
with a peer (since it depends on whether you both supported it at channel open).
Signed-off-by: Rusty Russell rusty@rustcorp.com.au
Changelog-added: JSON-RPC:
listpeers
showsfeatures
list for each channel.