Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add signet support #2816

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions bitcoin/chainparams.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#define BIP32_VER_MAIN_PRIVATE 0x0488ADE4
#define BIP32_VER_TEST_PUBLIC 0x043587CF
#define BIP32_VER_TEST_PRIVATE 0x04358394
#define BIP32_VER_SIGT_PUBLIC 0x043587CF
#define BIP32_VER_SIGT_PRIVATE 0x04358394

const struct chainparams networks[] = {
{.network_name = "bitcoin",
Expand Down Expand Up @@ -48,6 +50,21 @@ const struct chainparams networks[] = {
.p2sh_version = 196,
.testnet = true,
.bip32_key_version = {.bip32_pubkey_version = BIP32_VER_TEST_PUBLIC, .bip32_privkey_version = BIP32_VER_TEST_PRIVATE}},
{.network_name = "signet",
.bip173_name = "sb",
.bip70_name = "signet",
.genesis_blockhash = {{{.u.u8 = {0x2d, 0x09, 0x8b, 0x08, 0x55, 0x1b, 0xf3, 0xda, 0xb1, 0xa2, 0x72, 0xa8, 0x71, 0x4a, 0x12, 0x9d, 0x06, 0x5c, 0xfb, 0x32, 0xfa, 0x7e, 0x18, 0xdf, 0x00, 0x99, 0x09, 0x5f, 0xbc, 0xd8, 0x53, 0x62}}}},
.rpc_port = 38332,
.cli = "bitcoin-cli",
.cli_args = "-signet",
.dust_limit = { 546 },
.max_funding = AMOUNT_SAT_INIT((1 << 24) - 1),
.max_payment = AMOUNT_MSAT_INIT(0xFFFFFFFFULL),
.when_lightning_became_cool = 1,
.p2pkh_version = 125,
.p2sh_version = 87,
.testnet = true,
.bip32_key_version = {.bip32_pubkey_version = BIP32_VER_SIGT_PUBLIC, .bip32_privkey_version = BIP32_VER_SIGT_PRIVATE}},
{.network_name = "testnet",
.bip173_name = "tb",
.bip70_name = "test",
Expand Down Expand Up @@ -123,3 +140,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;
}
6 changes: 6 additions & 0 deletions bitcoin/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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 */
6 changes: 6 additions & 0 deletions doc/lightningd-config.5
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ Alias for
\fInetwork=testnet\fR\&.
.RE
.PP
\fBsignet\fR
.RS 4
Alias for
\fInetwork=signet\fR\&.
.RE
.PP
\fBmainnet\fR
.RS 4
Alias for
Expand Down
3 changes: 3 additions & 0 deletions doc/lightningd-config.5.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ Bitcoin control options:
*testnet*::
Alias for 'network=testnet'.

*signet*::
Alias for 'network=signet'.

*mainnet*::
Alias for 'network=bitcoin'.

Expand Down
4 changes: 2 additions & 2 deletions lightningd/jsonrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -976,11 +976,11 @@ void jsonrpc_listen(struct jsonrpc *jsonrpc, struct lightningd *ld)

/**
* segwit_addr_net_decode - Try to decode a Bech32 address and detect
* testnet/mainnet/regtest
* testnet/mainnet/regtest/signet
*
* This processes the address and returns a string if it is a Bech32
* address specified by BIP173. The string is set whether it is
* testnet ("tb"), mainnet ("bc"), or regtest ("bcrt")
* testnet ("tb"), mainnet ("bc"), regtest ("bcrt"), or signet ("sb")
* It does not check, witness version and program size restrictions.
*
* Out: witness_version: Pointer to an int that will be updated to contain
Expand Down
8 changes: 8 additions & 0 deletions lightningd/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ static char *opt_set_testnet(struct lightningd *ld)
return opt_set_network("testnet", ld);
}

static char *opt_set_signet(struct lightningd *ld)
{
return opt_set_network("signet", ld);
}

static char *opt_set_mainnet(struct lightningd *ld)
{
return opt_set_network("bitcoin", ld);
Expand Down Expand Up @@ -403,6 +408,8 @@ static void config_register_opts(struct lightningd *ld)
" regtest, litecoin or litecoin-testnet)");
opt_register_early_noarg("--testnet", opt_set_testnet, ld,
"Alias for --network=testnet");
opt_register_early_noarg("--signet", opt_set_signet, ld,
"Alias for --network=signet");
opt_register_early_noarg("--mainnet", opt_set_mainnet, ld,
"Alias for --network=bitcoin");
opt_register_early_arg("--allow-deprecated-apis",
Expand Down Expand Up @@ -1022,6 +1029,7 @@ static void add_config(struct lightningd *ld,
|| opt->cb == (void *)version_and_exit
/* These two show up as --network= */
|| opt->cb == (void *)opt_set_testnet
|| opt->cb == (void *)opt_set_signet
|| opt->cb == (void *)opt_set_mainnet
|| opt->cb == (void *)opt_lightningd_usage
|| opt->cb == (void *)test_subdaemons_and_exit
Expand Down
6 changes: 3 additions & 3 deletions wallet/wallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down