Skip to content

Commit 905a85d

Browse files
SimonVrouwerustyrussell
authored andcommitted
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
1 parent 32fb8a4 commit 905a85d

File tree

5 files changed

+55
-6
lines changed

5 files changed

+55
-6
lines changed

bitcoin/test/run-tx-bitcoin_tx_2of2_input_witness_weight.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ struct amount_sat amount_asset_to_sat(struct amount_asset *asset UNNEEDED)
2424
struct amount_sat a UNNEEDED,
2525
struct amount_sat b UNNEEDED)
2626
{ fprintf(stderr, "amount_sat_add called!\n"); abort(); }
27-
/* Generated stub for amount_sat_eq */
28-
bool amount_sat_eq(struct amount_sat a UNNEEDED, struct amount_sat b UNNEEDED)
29-
{ fprintf(stderr, "amount_sat_eq called!\n"); abort(); }
3027
/* Generated stub for amount_sat_greater_eq */
3128
bool amount_sat_greater_eq(struct amount_sat a UNNEEDED, struct amount_sat b UNNEEDED)
3229
{ fprintf(stderr, "amount_sat_greater_eq called!\n"); abort(); }

doc/lightning-getinfo.7.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ On success, an object is returned, containing:
3939
- **blockheight** (u32): The highest block height we've learned
4040
- **network** (string): represents the type of network on the node are working (e.g: `bitcoin`, `testnet`, or `regtest`)
4141
- **fees_collected_msat** (msat): Total routing fees collected by this node
42+
- **our_features** (object, optional): Our BOLT #9 feature bits (as hexstring) for various contexts:
43+
- **init** (hex): features (incl. globalfeatures) in our init message, these also restrict what we offer in open_channel or accept in accept_channel
44+
- **node** (hex): features in our node_announcement message
45+
- **channel** (hex): negotiated channel features we — as channel initiator — publish in the channel_announcement message
46+
- **invoice** (hex): features in our BOLT11 invoices
4247
- **address** (array of objects, optional): The addresses we announce to the world:
4348
- **type** (string): Type of connection (one of "dns", "ipv4", "ipv6", "torv2", "torv3", "websocket")
4449
- **port** (u16): port number
@@ -91,12 +96,18 @@ EXAMPLE JSON RESPONSE
9196
"port": 9736
9297
}
9398
],
94-
"version": "0.9.0",
95-
"blockheight": 644297,
99+
"version": "v0.10.2",
100+
"blockheight": 724302,
96101
"network": "bitcoin",
97102
"msatoshi_fees_collected": 0,
98103
"fees_collected_msat": "0msat",
99104
"lightning-dir": "/media/vincent/Maxtor/C-lightning/node/bitcoin"
105+
"our_features": {
106+
"init": "8828226aa2",
107+
"node": "80008828226aa2",
108+
"channel": "",
109+
"invoice": "20024200"
110+
}
100111
}
101112

102113
```
@@ -117,4 +128,4 @@ RESOURCES
117128
---------
118129

119130
Main web site: <https://github.com/ElementsProject/lightning>
120-
[comment]: # ( SHA256STAMP:90a3bacb6cb4456119afee8e60677c29bf5f46c4cd950e660a9f9c8e0433b473)
131+
[comment]: # ( SHA256STAMP:041768347542d7cf4260739ad8934c77d52682d089d9fe07499e22f7331b53f5)

doc/schemas/getinfo.schema.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,35 @@
5656
"type": "string",
5757
"description": "Identifies where you can find the configuration and other related files"
5858
},
59+
"our_features": {
60+
"type": "object",
61+
"description": "Our BOLT #9 feature bits (as hexstring) for various contexts",
62+
"additionalProperties": true,
63+
"required": [
64+
"init",
65+
"node",
66+
"channel",
67+
"invoice"
68+
],
69+
"properties": {
70+
"init": {
71+
"type": "hex",
72+
"description": "features (incl. globalfeatures) in our init message, these also restrict what we offer in open_channel or accept in accept_channel"
73+
},
74+
"node": {
75+
"type": "hex",
76+
"description": "features in our node_announcement message"
77+
},
78+
"channel": {
79+
"type": "hex",
80+
"description": "negotiated channel features we — as channel initiator — publish in the channel_announcement message"
81+
},
82+
"invoice": {
83+
"type": "hex",
84+
"description": "features in our BOLT11 invoices"
85+
}
86+
}
87+
},
5988
"blockheight": {
6089
"type": "u32",
6190
"description": "The highest block height we've learned"

lightningd/peer_control.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,6 +1747,15 @@ static struct command_result *json_getinfo(struct command *cmd,
17471747
json_add_string(response, "warning_lightningd_sync",
17481748
"Still loading latest blocks from bitcoind.");
17491749

1750+
u8 **bits = cmd->ld->our_features->bits;
1751+
json_object_start(response, "our_features");
1752+
json_add_hex_talarr(response, "init",
1753+
featurebits_or(cmd, bits[INIT_FEATURE], bits[GLOBAL_INIT_FEATURE]));
1754+
json_add_hex_talarr(response, "node", bits[NODE_ANNOUNCE_FEATURE]);
1755+
json_add_hex_talarr(response, "channel", bits[CHANNEL_FEATURE]);
1756+
json_add_hex_talarr(response, "invoice", bits[BOLT11_FEATURE]);
1757+
json_object_end(response);
1758+
17501759
return command_success(cmd, response);
17511760
}
17521761

lightningd/test/run-invoice-select-inchan.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ bool feature_is_set(const u8 *features UNNEEDED, size_t bit UNNEEDED)
184184
bool feature_negotiated(const struct feature_set *our_features UNNEEDED,
185185
const u8 *their_features UNNEEDED, size_t f UNNEEDED)
186186
{ fprintf(stderr, "feature_negotiated called!\n"); abort(); }
187+
/* Generated stub for featurebits_or */
188+
u8 *featurebits_or(const tal_t *ctx UNNEEDED, const u8 *f1 TAKES UNNEEDED, const u8 *f2 TAKES UNNEEDED)
189+
{ fprintf(stderr, "featurebits_or called!\n"); abort(); }
187190
/* Generated stub for find_plugin_for_command */
188191
struct plugin *find_plugin_for_command(struct lightningd *ld UNNEEDED,
189192
const char *cmd_name UNNEEDED)

0 commit comments

Comments
 (0)