JSON-RPC: getinfo, add field our_features

All build flags and (experimental) options make it hard to find
out what features are supported or enabled.

And the undocumented `--list-features-only`, does not account for all
our featurebits, for example bit 55 (keysend).

Changelog-Added: JSON-RPC: `getinfo` result now includes `our_features` (bits) for various Bolt #9 contexts
This commit is contained in:
Simon Vrouwe 2022-02-18 17:34:05 +02:00 committed by Rusty Russell
parent 32fb8a42fd
commit 905a85dc99
5 changed files with 55 additions and 6 deletions

View File

@ -24,9 +24,6 @@ struct amount_sat amount_asset_to_sat(struct amount_asset *asset UNNEEDED)
struct amount_sat a UNNEEDED,
struct amount_sat b UNNEEDED)
{ fprintf(stderr, "amount_sat_add called!\n"); abort(); }
/* Generated stub for amount_sat_eq */
bool amount_sat_eq(struct amount_sat a UNNEEDED, struct amount_sat b UNNEEDED)
{ fprintf(stderr, "amount_sat_eq called!\n"); abort(); }
/* Generated stub for amount_sat_greater_eq */
bool amount_sat_greater_eq(struct amount_sat a UNNEEDED, struct amount_sat b UNNEEDED)
{ fprintf(stderr, "amount_sat_greater_eq called!\n"); abort(); }

View File

@ -39,6 +39,11 @@ On success, an object is returned, containing:
- **blockheight** (u32): The highest block height we've learned
- **network** (string): represents the type of network on the node are working (e.g: `bitcoin`, `testnet`, or `regtest`)
- **fees_collected_msat** (msat): Total routing fees collected by this node
- **our_features** (object, optional): Our BOLT #9 feature bits (as hexstring) for various contexts:
- **init** (hex): features (incl. globalfeatures) in our init message, these also restrict what we offer in open_channel or accept in accept_channel
- **node** (hex): features in our node_announcement message
- **channel** (hex): negotiated channel features we — as channel initiator — publish in the channel_announcement message
- **invoice** (hex): features in our BOLT11 invoices
- **address** (array of objects, optional): The addresses we announce to the world:
- **type** (string): Type of connection (one of "dns", "ipv4", "ipv6", "torv2", "torv3", "websocket")
- **port** (u16): port number
@ -91,12 +96,18 @@ EXAMPLE JSON RESPONSE
"port": 9736
}
],
"version": "0.9.0",
"blockheight": 644297,
"version": "v0.10.2",
"blockheight": 724302,
"network": "bitcoin",
"msatoshi_fees_collected": 0,
"fees_collected_msat": "0msat",
"lightning-dir": "/media/vincent/Maxtor/C-lightning/node/bitcoin"
"our_features": {
"init": "8828226aa2",
"node": "80008828226aa2",
"channel": "",
"invoice": "20024200"
}
}
```
@ -117,4 +128,4 @@ RESOURCES
---------
Main web site: <https://github.com/ElementsProject/lightning>
[comment]: # ( SHA256STAMP:90a3bacb6cb4456119afee8e60677c29bf5f46c4cd950e660a9f9c8e0433b473)
[comment]: # ( SHA256STAMP:041768347542d7cf4260739ad8934c77d52682d089d9fe07499e22f7331b53f5)

View File

@ -56,6 +56,35 @@
"type": "string",
"description": "Identifies where you can find the configuration and other related files"
},
"our_features": {
"type": "object",
"description": "Our BOLT #9 feature bits (as hexstring) for various contexts",
"additionalProperties": true,
"required": [
"init",
"node",
"channel",
"invoice"
],
"properties": {
"init": {
"type": "hex",
"description": "features (incl. globalfeatures) in our init message, these also restrict what we offer in open_channel or accept in accept_channel"
},
"node": {
"type": "hex",
"description": "features in our node_announcement message"
},
"channel": {
"type": "hex",
"description": "negotiated channel features we — as channel initiator — publish in the channel_announcement message"
},
"invoice": {
"type": "hex",
"description": "features in our BOLT11 invoices"
}
}
},
"blockheight": {
"type": "u32",
"description": "The highest block height we've learned"

View File

@ -1747,6 +1747,15 @@ static struct command_result *json_getinfo(struct command *cmd,
json_add_string(response, "warning_lightningd_sync",
"Still loading latest blocks from bitcoind.");
u8 **bits = cmd->ld->our_features->bits;
json_object_start(response, "our_features");
json_add_hex_talarr(response, "init",
featurebits_or(cmd, bits[INIT_FEATURE], bits[GLOBAL_INIT_FEATURE]));
json_add_hex_talarr(response, "node", bits[NODE_ANNOUNCE_FEATURE]);
json_add_hex_talarr(response, "channel", bits[CHANNEL_FEATURE]);
json_add_hex_talarr(response, "invoice", bits[BOLT11_FEATURE]);
json_object_end(response);
return command_success(cmd, response);
}

View File

@ -184,6 +184,9 @@ bool feature_is_set(const u8 *features UNNEEDED, size_t bit UNNEEDED)
bool feature_negotiated(const struct feature_set *our_features UNNEEDED,
const u8 *their_features UNNEEDED, size_t f UNNEEDED)
{ fprintf(stderr, "feature_negotiated called!\n"); abort(); }
/* Generated stub for featurebits_or */
u8 *featurebits_or(const tal_t *ctx UNNEEDED, const u8 *f1 TAKES UNNEEDED, const u8 *f2 TAKES UNNEEDED)
{ fprintf(stderr, "featurebits_or called!\n"); abort(); }
/* Generated stub for find_plugin_for_command */
struct plugin *find_plugin_for_command(struct lightningd *ld UNNEEDED,
const char *cmd_name UNNEEDED)