mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
elements: Global variable whether we are running on elements
Using a global variable is a bit lazy, but weaving the network type through the entire stack is a daunting task. Maybe we can make that happen at a later stage. Most of the changes in `chainparams.c` are just formatting the `genesis_blockhash` a bit nicer (`clang-format` to the rescue). Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
parent
9025a3cd39
commit
a300dea7e6
@ -16,7 +16,11 @@ const struct chainparams networks[] = {
|
|||||||
{.network_name = "bitcoin",
|
{.network_name = "bitcoin",
|
||||||
.bip173_name = "bc",
|
.bip173_name = "bc",
|
||||||
.bip70_name = "main",
|
.bip70_name = "main",
|
||||||
.genesis_blockhash = {{{.u.u8 = {0x6f, 0xe2, 0x8c, 0x0a, 0xb6, 0xf1, 0xb3, 0x72, 0xc1, 0xa6, 0xa2, 0x46, 0xae, 0x63, 0xf7, 0x4f, 0x93, 0x1e, 0x83, 0x65, 0xe1, 0x5a, 0x08, 0x9c, 0x68, 0xd6, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00}}}},
|
.genesis_blockhash = {{{.u.u8 = {0x6f, 0xe2, 0x8c, 0x0a, 0xb6, 0xf1, 0xb3,
|
||||||
|
0x72, 0xc1, 0xa6, 0xa2, 0x46, 0xae, 0x63,
|
||||||
|
0xf7, 0x4f, 0x93, 0x1e, 0x83, 0x65, 0xe1,
|
||||||
|
0x5a, 0x08, 0x9c, 0x68, 0xd6, 0x19, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00}}}},
|
||||||
.rpc_port = 8332,
|
.rpc_port = 8332,
|
||||||
.cli = "bitcoin-cli",
|
.cli = "bitcoin-cli",
|
||||||
.cli_args = NULL,
|
.cli_args = NULL,
|
||||||
@ -35,11 +39,17 @@ const struct chainparams networks[] = {
|
|||||||
.p2pkh_version = 0,
|
.p2pkh_version = 0,
|
||||||
.p2sh_version = 5,
|
.p2sh_version = 5,
|
||||||
.testnet = false,
|
.testnet = false,
|
||||||
.bip32_key_version = {.bip32_pubkey_version = BIP32_VER_MAIN_PUBLIC, .bip32_privkey_version = BIP32_VER_MAIN_PRIVATE}},
|
.bip32_key_version = {.bip32_pubkey_version = BIP32_VER_MAIN_PUBLIC,
|
||||||
|
.bip32_privkey_version = BIP32_VER_MAIN_PRIVATE},
|
||||||
|
.is_elements = false},
|
||||||
{.network_name = "regtest",
|
{.network_name = "regtest",
|
||||||
.bip173_name = "bcrt",
|
.bip173_name = "bcrt",
|
||||||
.bip70_name = "regtest",
|
.bip70_name = "regtest",
|
||||||
.genesis_blockhash = {{{.u.u8 = {0x06, 0x22, 0x6e, 0x46, 0x11, 0x1a, 0x0b, 0x59, 0xca, 0xaf, 0x12, 0x60, 0x43, 0xeb, 0x5b, 0xbf, 0x28, 0xc3, 0x4f, 0x3a, 0x5e, 0x33, 0x2a, 0x1f, 0xc7, 0xb2, 0xb7, 0x3c, 0xf1, 0x88, 0x91, 0x0f}}}},
|
.genesis_blockhash = {{{.u.u8 = {0x06, 0x22, 0x6e, 0x46, 0x11, 0x1a, 0x0b,
|
||||||
|
0x59, 0xca, 0xaf, 0x12, 0x60, 0x43, 0xeb,
|
||||||
|
0x5b, 0xbf, 0x28, 0xc3, 0x4f, 0x3a, 0x5e,
|
||||||
|
0x33, 0x2a, 0x1f, 0xc7, 0xb2, 0xb7, 0x3c,
|
||||||
|
0xf1, 0x88, 0x91, 0x0f}}}},
|
||||||
.rpc_port = 18332,
|
.rpc_port = 18332,
|
||||||
.cli = "bitcoin-cli",
|
.cli = "bitcoin-cli",
|
||||||
.cli_args = "-regtest",
|
.cli_args = "-regtest",
|
||||||
@ -51,7 +61,9 @@ const struct chainparams networks[] = {
|
|||||||
.p2pkh_version = 111,
|
.p2pkh_version = 111,
|
||||||
.p2sh_version = 196,
|
.p2sh_version = 196,
|
||||||
.testnet = true,
|
.testnet = true,
|
||||||
.bip32_key_version = {.bip32_pubkey_version = BIP32_VER_TEST_PUBLIC, .bip32_privkey_version = BIP32_VER_TEST_PRIVATE}},
|
.bip32_key_version = {.bip32_pubkey_version = BIP32_VER_TEST_PUBLIC,
|
||||||
|
.bip32_privkey_version = BIP32_VER_TEST_PRIVATE},
|
||||||
|
.is_elements = false},
|
||||||
{.network_name = "signet",
|
{.network_name = "signet",
|
||||||
.bip173_name = "sb",
|
.bip173_name = "sb",
|
||||||
.bip70_name = "signet",
|
.bip70_name = "signet",
|
||||||
@ -67,11 +79,17 @@ const struct chainparams networks[] = {
|
|||||||
.p2pkh_version = 125,
|
.p2pkh_version = 125,
|
||||||
.p2sh_version = 87,
|
.p2sh_version = 87,
|
||||||
.testnet = true,
|
.testnet = true,
|
||||||
.bip32_key_version = {.bip32_pubkey_version = BIP32_VER_SIGT_PUBLIC, .bip32_privkey_version = BIP32_VER_SIGT_PRIVATE}},
|
.bip32_key_version = {.bip32_pubkey_version = BIP32_VER_SIGT_PUBLIC, .bip32_privkey_version = BIP32_VER_SIGT_PRIVATE},
|
||||||
|
.is_elements = false,
|
||||||
|
},
|
||||||
{.network_name = "testnet",
|
{.network_name = "testnet",
|
||||||
.bip173_name = "tb",
|
.bip173_name = "tb",
|
||||||
.bip70_name = "test",
|
.bip70_name = "test",
|
||||||
.genesis_blockhash = {{{.u.u8 = {0x43, 0x49, 0x7f, 0xd7, 0xf8, 0x26, 0x95, 0x71, 0x08, 0xf4, 0xa3, 0x0f, 0xd9, 0xce, 0xc3, 0xae, 0xba, 0x79, 0x97, 0x20, 0x84, 0xe9, 0x0e, 0xad, 0x01, 0xea, 0x33, 0x09, 0x00, 0x00, 0x00, 0x00}}}},
|
.genesis_blockhash = {{{.u.u8 = {0x43, 0x49, 0x7f, 0xd7, 0xf8, 0x26, 0x95,
|
||||||
|
0x71, 0x08, 0xf4, 0xa3, 0x0f, 0xd9, 0xce,
|
||||||
|
0xc3, 0xae, 0xba, 0x79, 0x97, 0x20, 0x84,
|
||||||
|
0xe9, 0x0e, 0xad, 0x01, 0xea, 0x33, 0x09,
|
||||||
|
0x00, 0x00, 0x00, 0x00}}}},
|
||||||
.rpc_port = 18332,
|
.rpc_port = 18332,
|
||||||
.cli = "bitcoin-cli",
|
.cli = "bitcoin-cli",
|
||||||
.cli_args = "-testnet",
|
.cli_args = "-testnet",
|
||||||
@ -82,11 +100,17 @@ const struct chainparams networks[] = {
|
|||||||
.p2pkh_version = 111,
|
.p2pkh_version = 111,
|
||||||
.p2sh_version = 196,
|
.p2sh_version = 196,
|
||||||
.testnet = true,
|
.testnet = true,
|
||||||
.bip32_key_version = {.bip32_pubkey_version = BIP32_VER_TEST_PUBLIC, .bip32_privkey_version = BIP32_VER_TEST_PRIVATE}},
|
.bip32_key_version = {.bip32_pubkey_version = BIP32_VER_TEST_PUBLIC,
|
||||||
|
.bip32_privkey_version = BIP32_VER_TEST_PRIVATE},
|
||||||
|
.is_elements = false},
|
||||||
{.network_name = "litecoin",
|
{.network_name = "litecoin",
|
||||||
.bip173_name = "ltc",
|
.bip173_name = "ltc",
|
||||||
.bip70_name = "main",
|
.bip70_name = "main",
|
||||||
.genesis_blockhash = {{{.u.u8 = {0xe2, 0xbf, 0x04, 0x7e, 0x7e, 0x5a, 0x19, 0x1a, 0xa4, 0xef, 0x34, 0xd3, 0x14, 0x97, 0x9d, 0xc9, 0x98, 0x6e, 0x0f, 0x19, 0x25, 0x1e, 0xda, 0xba, 0x59, 0x40, 0xfd, 0x1f, 0xe3, 0x65, 0xa7, 0x12 }}}},
|
.genesis_blockhash = {{{.u.u8 = {0xe2, 0xbf, 0x04, 0x7e, 0x7e, 0x5a, 0x19,
|
||||||
|
0x1a, 0xa4, 0xef, 0x34, 0xd3, 0x14, 0x97,
|
||||||
|
0x9d, 0xc9, 0x98, 0x6e, 0x0f, 0x19, 0x25,
|
||||||
|
0x1e, 0xda, 0xba, 0x59, 0x40, 0xfd, 0x1f,
|
||||||
|
0xe3, 0x65, 0xa7, 0x12}}}},
|
||||||
.rpc_port = 9332,
|
.rpc_port = 9332,
|
||||||
.cli = "litecoin-cli",
|
.cli = "litecoin-cli",
|
||||||
.cli_args = NULL,
|
.cli_args = NULL,
|
||||||
@ -98,11 +122,17 @@ const struct chainparams networks[] = {
|
|||||||
.p2pkh_version = 48,
|
.p2pkh_version = 48,
|
||||||
.p2sh_version = 50,
|
.p2sh_version = 50,
|
||||||
.testnet = false,
|
.testnet = false,
|
||||||
.bip32_key_version = {.bip32_pubkey_version = BIP32_VER_MAIN_PUBLIC, .bip32_privkey_version = BIP32_VER_MAIN_PRIVATE}},
|
.bip32_key_version = {.bip32_pubkey_version = BIP32_VER_MAIN_PUBLIC,
|
||||||
|
.bip32_privkey_version = BIP32_VER_MAIN_PRIVATE},
|
||||||
|
.is_elements = false},
|
||||||
{.network_name = "litecoin-testnet",
|
{.network_name = "litecoin-testnet",
|
||||||
.bip173_name = "tltc",
|
.bip173_name = "tltc",
|
||||||
.bip70_name = "test",
|
.bip70_name = "test",
|
||||||
.genesis_blockhash = {{{.u.u8 = { 0xa0, 0x29, 0x3e, 0x4e, 0xeb, 0x3d, 0xa6, 0xe6, 0xf5, 0x6f, 0x81, 0xed, 0x59, 0x5f, 0x57, 0x88, 0x0d, 0x1a, 0x21, 0x56, 0x9e, 0x13, 0xee, 0xfd, 0xd9, 0x51, 0x28, 0x4b, 0x5a, 0x62, 0x66, 0x49 }}}},
|
.genesis_blockhash = {{{.u.u8 = {0xa0, 0x29, 0x3e, 0x4e, 0xeb, 0x3d, 0xa6,
|
||||||
|
0xe6, 0xf5, 0x6f, 0x81, 0xed, 0x59, 0x5f,
|
||||||
|
0x57, 0x88, 0x0d, 0x1a, 0x21, 0x56, 0x9e,
|
||||||
|
0x13, 0xee, 0xfd, 0xd9, 0x51, 0x28, 0x4b,
|
||||||
|
0x5a, 0x62, 0x66, 0x49}}}},
|
||||||
.rpc_port = 19332,
|
.rpc_port = 19332,
|
||||||
.cli = "litecoin-cli",
|
.cli = "litecoin-cli",
|
||||||
.cli_args = "-testnet",
|
.cli_args = "-testnet",
|
||||||
@ -114,21 +144,27 @@ const struct chainparams networks[] = {
|
|||||||
.p2pkh_version = 111,
|
.p2pkh_version = 111,
|
||||||
.p2sh_version = 58,
|
.p2sh_version = 58,
|
||||||
.testnet = true,
|
.testnet = true,
|
||||||
.bip32_key_version = {.bip32_pubkey_version = BIP32_VER_TEST_PUBLIC, .bip32_privkey_version = BIP32_VER_TEST_PRIVATE}},
|
.bip32_key_version = {.bip32_pubkey_version = BIP32_VER_TEST_PUBLIC,
|
||||||
{
|
.bip32_privkey_version = BIP32_VER_TEST_PRIVATE},
|
||||||
.network_name = "liquid-regtest",
|
.is_elements = false},
|
||||||
.bip173_name = "tltc",
|
{.network_name = "liquid-regtest",
|
||||||
.genesis_blockhash = {{{.u.u8 = { 0xa0, 0x29, 0x3e, 0x4e, 0xeb, 0x3d, 0xa6, 0xe6, 0xf5, 0x6f, 0x81, 0xed, 0x59, 0x5f, 0x57, 0x88, 0x0d, 0x1a, 0x21, 0x56, 0x9e, 0x13, 0xee, 0xfd, 0xd9, 0x51, 0x28, 0x4b, 0x5a, 0x62, 0x66, 0x49 }}}},
|
.bip173_name = "ert",
|
||||||
.rpc_port = 19332,
|
.genesis_blockhash = {{{.u.u8 = {0x9f, 0x87, 0xeb, 0x58, 0x0b, 0x9e, 0x5f,
|
||||||
.cli = "elements-cli",
|
0x11, 0xdc, 0x21, 0x1e, 0x9f, 0xb6, 0x6a,
|
||||||
.cli_args = "-chain=liquid-regtest",
|
0xbb, 0x36, 0x99, 0x99, 0x90, 0x44, 0xf8,
|
||||||
.dust_limit = { 546 },
|
0xfe, 0x14, 0x68, 0x01, 0x16, 0x23, 0x93,
|
||||||
.max_funding = AMOUNT_SAT_INIT(((1 << 24) - 1)),
|
0x36, 0x42, 0x86, 0xc6}}}},
|
||||||
.max_payment = AMOUNT_MSAT_INIT(0xFFFFFFFFULL),
|
.rpc_port = 19332,
|
||||||
.when_lightning_became_cool = 1,
|
.cli = "elements-cli",
|
||||||
.testnet = true,
|
.cli_args = "-chain=liquid-regtest",
|
||||||
.bip32_key_version = {.bip32_pubkey_version = BIP32_VER_TEST_PUBLIC, .bip32_privkey_version = BIP32_VER_TEST_PRIVATE}
|
.dust_limit = {546},
|
||||||
},
|
.max_funding = AMOUNT_SAT_INIT((1 << 24) - 1),
|
||||||
|
.max_payment = AMOUNT_MSAT_INIT(0xFFFFFFFFULL),
|
||||||
|
.when_lightning_became_cool = 1,
|
||||||
|
.testnet = true,
|
||||||
|
.bip32_key_version = {.bip32_pubkey_version = BIP32_VER_TEST_PUBLIC,
|
||||||
|
.bip32_privkey_version = BIP32_VER_TEST_PRIVATE},
|
||||||
|
.is_elements = true},
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct chainparams *chainparams_for_network(const char *network_name)
|
const struct chainparams *chainparams_for_network(const char *network_name)
|
||||||
|
@ -37,6 +37,7 @@ struct chainparams {
|
|||||||
|
|
||||||
/* Version codes for BIP32 extended keys in libwally-core*/
|
/* Version codes for BIP32 extended keys in libwally-core*/
|
||||||
const struct bip32_key_version bip32_key_version;
|
const struct bip32_key_version bip32_key_version;
|
||||||
|
const bool is_elements;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
secp256k1_context *secp256k1_ctx;
|
secp256k1_context *secp256k1_ctx;
|
||||||
const tal_t *tmpctx;
|
const tal_t *tmpctx;
|
||||||
|
bool is_elements = false;
|
||||||
|
|
||||||
char *tal_hexstr(const tal_t *ctx, const void *data, size_t len)
|
char *tal_hexstr(const tal_t *ctx, const void *data, size_t len)
|
||||||
{
|
{
|
||||||
|
@ -10,6 +10,10 @@
|
|||||||
|
|
||||||
extern secp256k1_context *secp256k1_ctx;
|
extern secp256k1_context *secp256k1_ctx;
|
||||||
|
|
||||||
|
/* FIXME: Instead of using this as a global, we might want to pass it as
|
||||||
|
* context whenever we need it. The global var is just lazy... */
|
||||||
|
extern bool is_elements;
|
||||||
|
|
||||||
/* Allocate and fill in a hex-encoded string of this data. */
|
/* Allocate and fill in a hex-encoded string of this data. */
|
||||||
char *tal_hexstr(const tal_t *ctx, const void *data, size_t len);
|
char *tal_hexstr(const tal_t *ctx, const void *data, size_t len);
|
||||||
|
|
||||||
|
@ -244,6 +244,7 @@ static char *opt_set_network(const char *arg, struct lightningd *ld)
|
|||||||
ld->topology->bitcoind->chainparams = chainparams_for_network(arg);
|
ld->topology->bitcoind->chainparams = chainparams_for_network(arg);
|
||||||
if (!ld->topology->bitcoind->chainparams)
|
if (!ld->topology->bitcoind->chainparams)
|
||||||
return tal_fmt(NULL, "Unknown network name '%s'", arg);
|
return tal_fmt(NULL, "Unknown network name '%s'", arg);
|
||||||
|
is_elements = ld->topology->bitcoind->chainparams->is_elements;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user