mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-18 22:54:25 +01:00
devtools/features: tool to convert feature bitmap to names.
For example: ``` $ ./devtools/features 80008008226aa2 option_data_loss_protect/odd (optional) option_upfront_shutdown_script/odd (optional) option_gossip_queries/odd (optional) option_var_onion_optin/odd (optional) option_gossip_queries_ex/odd (optional) option_static_remotekey/odd (optional) option_payment_secret/even (compulsory) option_basic_mpp/odd (optional) option_anchor_outputs/odd (optional) option_shutdown_anysegwit/odd (optional) option_onion_messages/odd (optional) option_unknown_54/odd (optional) ``` Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
be8e45b16d
commit
7ef2f4d7fb
@@ -373,7 +373,7 @@ int features_unsupported(const struct feature_set *our_features,
|
|||||||
return all_supported_features(our_features, their_features, p);
|
return all_supported_features(our_features, their_features, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *feature_name(const tal_t *ctx, size_t f)
|
const char *feature_name(const tal_t *ctx, size_t f)
|
||||||
{
|
{
|
||||||
static const char *fnames[] = {
|
static const char *fnames[] = {
|
||||||
"option_data_loss_protect", /* 0/1 */
|
"option_data_loss_protect", /* 0/1 */
|
||||||
|
|||||||
@@ -64,6 +64,9 @@ bool feature_check_depends(const u8 *their_features,
|
|||||||
const char **list_supported_features(const tal_t *ctx,
|
const char **list_supported_features(const tal_t *ctx,
|
||||||
const struct feature_set *fset);
|
const struct feature_set *fset);
|
||||||
|
|
||||||
|
/* Give a name for this feature */
|
||||||
|
const char *feature_name(const tal_t *ctx, size_t f);
|
||||||
|
|
||||||
/* Low-level helpers to deal with big-endian bitfields. */
|
/* Low-level helpers to deal with big-endian bitfields. */
|
||||||
bool feature_is_set(const u8 *features, size_t bit);
|
bool feature_is_set(const u8 *features, size_t bit);
|
||||||
void set_feature_bit(u8 **ptr, u32 bit);
|
void set_feature_bit(u8 **ptr, u32 bit);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
DEVTOOLS := devtools/bolt11-cli devtools/decodemsg devtools/onion devtools/dump-gossipstore devtools/gossipwith devtools/create-gossipstore devtools/mkcommit devtools/mkfunding devtools/mkclose devtools/mkgossip devtools/mkencoded devtools/mkquery devtools/lightning-checkmessage devtools/topology devtools/route devtools/blindedpath devtools/bolt12-cli devtools/encodeaddr
|
DEVTOOLS := devtools/bolt11-cli devtools/decodemsg devtools/onion devtools/dump-gossipstore devtools/gossipwith devtools/create-gossipstore devtools/mkcommit devtools/mkfunding devtools/mkclose devtools/mkgossip devtools/mkencoded devtools/mkquery devtools/lightning-checkmessage devtools/topology devtools/route devtools/blindedpath devtools/bolt12-cli devtools/encodeaddr devtools/features
|
||||||
ifeq ($(HAVE_SQLITE3),1)
|
ifeq ($(HAVE_SQLITE3),1)
|
||||||
DEVTOOLS += devtools/checkchannels
|
DEVTOOLS += devtools/checkchannels
|
||||||
endif
|
endif
|
||||||
@@ -47,6 +47,8 @@ DEVTOOLS_COMMON_OBJS := \
|
|||||||
wire/channel_type_wiregen.o \
|
wire/channel_type_wiregen.o \
|
||||||
wire/tlvstream.o
|
wire/tlvstream.o
|
||||||
|
|
||||||
|
devtools/features: $(CCAN_OBJS) common/features.o common/utils.o wire/fromwire.o wire/towire.o devtools/features.o
|
||||||
|
|
||||||
devtools/bolt11-cli: $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o devtools/bolt11-cli.o
|
devtools/bolt11-cli: $(DEVTOOLS_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) $(BITCOIN_OBJS) wire/fromwire.o wire/towire.o devtools/bolt11-cli.o
|
||||||
|
|
||||||
devtools/encodeaddr: common/utils.o common/bech32.o devtools/encodeaddr.o
|
devtools/encodeaddr: common/utils.o common/bech32.o devtools/encodeaddr.o
|
||||||
|
|||||||
28
devtools/features.c
Normal file
28
devtools/features.c
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/* Turns a hex string into feature. */
|
||||||
|
#include "config.h"
|
||||||
|
#include <ccan/err/err.h>
|
||||||
|
#include <common/features.h>
|
||||||
|
#include <common/utils.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
const u8 *features;
|
||||||
|
|
||||||
|
setup_locale();
|
||||||
|
|
||||||
|
if (argc != 2)
|
||||||
|
errx(1, "Usage: %s <hexstring>", argv[0]);
|
||||||
|
|
||||||
|
features = tal_hexdata(NULL, argv[1], strlen(argv[1]));
|
||||||
|
if (!features)
|
||||||
|
errx(1, "bad hexstring");
|
||||||
|
|
||||||
|
for (size_t i = 0; i < tal_bytelen(features) * 8; i++) {
|
||||||
|
if (feature_is_set(features, i))
|
||||||
|
printf("%s (%s)\n",
|
||||||
|
feature_name(features, i),
|
||||||
|
i % 2 ? "optional" : "compulsory");
|
||||||
|
}
|
||||||
|
tal_free(features);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user