mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-08 16:44:22 +01:00
dynamically generate string of network names
This commit is contained in:
committed by
neil saitug
parent
bb301040e4
commit
ff2bfe3bdb
@@ -123,3 +123,11 @@ const struct chainparams *chainparams_by_bip173(const char *bip173_name)
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *chainparams_get_network_names(const tal_t *ctx)
|
||||
{
|
||||
char *networks_string = tal_strdup(ctx, networks[0].network_name);
|
||||
for (size_t i = 1; i < ARRAY_SIZE(networks); ++i)
|
||||
tal_append_fmt(&networks_string, ", %s", networks[i].network_name);
|
||||
return networks_string;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "config.h"
|
||||
#include <bitcoin/block.h>
|
||||
#include <ccan/short_types/short_types.h>
|
||||
#include <ccan/tal/str/str.h>
|
||||
#include <common/amount.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
@@ -53,4 +54,9 @@ const struct chainparams *chainparams_by_bip173(const char *bip173_name);
|
||||
*/
|
||||
const struct chainparams *chainparams_by_chainhash(const struct bitcoin_blkid *chain_hash);
|
||||
|
||||
/**
|
||||
* chainparams_get_network_names - Produce a comma-separated list of network names
|
||||
*/
|
||||
const char *chainparams_get_network_names(const tal_t *ctx);
|
||||
|
||||
#endif /* LIGHTNING_BITCOIN_CHAINPARAMS_H */
|
||||
|
||||
@@ -2239,12 +2239,12 @@ bool wallet_network_check(struct wallet *w,
|
||||
"match network blockchain hash: %s "
|
||||
"!= %s. "
|
||||
"Are you on the right network? "
|
||||
"(--network={bitcoin, testnet, regtest, "
|
||||
"litecoin or litecoin-testnet})",
|
||||
"(--network={one of %s})",
|
||||
type_to_string(w, struct bitcoin_blkid,
|
||||
&chainhash),
|
||||
type_to_string(w, struct bitcoin_blkid,
|
||||
&chainparams->genesis_blockhash));
|
||||
&chainparams->genesis_blockhash),
|
||||
chainparams_get_network_names(tmpctx));
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user