diff --git a/bitcoin/chainparams.c b/bitcoin/chainparams.c index 3785a500c731..edc8cdd713e0 100644 --- a/bitcoin/chainparams.c +++ b/bitcoin/chainparams.c @@ -36,6 +36,7 @@ const struct chainparams networks[] = { 0x5a, 0x08, 0x9c, 0x68, 0xd6, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00}}}}, .rpc_port = 8332, + .ln_port = 9735, .cli = "bitcoin-cli", .cli_args = NULL, .cli_min_supported_version = 150000, @@ -67,6 +68,7 @@ const struct chainparams networks[] = { 0x33, 0x2a, 0x1f, 0xc7, 0xb2, 0xb7, 0x3c, 0xf1, 0x88, 0x91, 0x0f}}}}, .rpc_port = 18443, + .ln_port = 9735, .cli = "bitcoin-cli", .cli_args = "-regtest", .cli_min_supported_version = 150000, @@ -92,6 +94,7 @@ const struct chainparams networks[] = { 0x2c, 0x42, 0x25, 0xe9, 0x73, 0x98, 0x81, 0x08, 0x00, 0x00, 0x00}}}}, .rpc_port = 38332, + .ln_port = 39735, .cli = "bitcoin-cli", .cli_args = "-signet", .cli_min_supported_version = 150000, @@ -115,6 +118,7 @@ const struct chainparams networks[] = { 0xe9, 0x0e, 0xad, 0x01, 0xea, 0x33, 0x09, 0x00, 0x00, 0x00, 0x00}}}}, .rpc_port = 18332, + .ln_port = 19735, .cli = "bitcoin-cli", .cli_args = "-testnet", .cli_min_supported_version = 150000, @@ -138,6 +142,7 @@ const struct chainparams networks[] = { 0x1e, 0xda, 0xba, 0x59, 0x40, 0xfd, 0x1f, 0xe3, 0x65, 0xa7, 0x12}}}}, .rpc_port = 9332, + .ln_port = 9735, .cli = "litecoin-cli", .cli_args = NULL, .cli_min_supported_version = 150000, @@ -162,6 +167,7 @@ const struct chainparams networks[] = { 0x13, 0xee, 0xfd, 0xd9, 0x51, 0x28, 0x4b, 0x5a, 0x62, 0x66, 0x49}}}}, .rpc_port = 19332, + .ln_port = 9735, .cli = "litecoin-cli", .cli_args = "-testnet", .cli_min_supported_version = 150000, @@ -186,6 +192,7 @@ const struct chainparams networks[] = { 0xfe, 0x14, 0x68, 0x01, 0x16, 0x23, 0x93, 0x36, 0x42, 0x86, 0xc6}}}}, .rpc_port = 19332, + .ln_port = 9735, .cli = "elements-cli", .cli_args = "-chain=liquid-regtest", .dust_limit = {546}, @@ -209,6 +216,7 @@ const struct chainparams networks[] = { 0x68, 0x8d, 0x2c, 0x37, 0x92, 0x96, 0x88, 0x8a, 0x20, 0x60, 0x03}}}}, .rpc_port = 7041, + .ln_port = 9735, .cli = "elements-cli", .cli_args = "-chain=liquidv1", .dust_limit = {546}, @@ -261,4 +269,3 @@ const char *chainparams_get_network_names(const tal_t *ctx) tal_append_fmt(&networks_string, ", %s", networks[i].network_name); return networks_string; } - diff --git a/bitcoin/chainparams.h b/bitcoin/chainparams.h index b4acb2c27de4..f5c71509dd26 100644 --- a/bitcoin/chainparams.h +++ b/bitcoin/chainparams.h @@ -22,6 +22,14 @@ struct chainparams { const char *bip70_name; const struct bitcoin_blkid genesis_blockhash; const int rpc_port; + /** + * BOLT 1: The default TCP port depends on the network used. The most common networks are: + * + * - Bitcoin mainet with port number 9735 or the corresponding hexadecimal `0x2607`; + * - Bitcoin testnet with port number 19735 (`0x4D17`); + * - Bitcoin signet with port number 39735 (`0xF87`). + */ + const int ln_port; const char *cli; const char *cli_args; /* The min numeric version of cli supported */ diff --git a/lightningd/connect_control.c b/lightningd/connect_control.c index 0fe75804896b..918a9a697cce 100644 --- a/lightningd/connect_control.c +++ b/lightningd/connect_control.c @@ -1,4 +1,5 @@ #include "config.h" +#include #include #include #include @@ -140,7 +141,7 @@ static struct command_result *json_connect(struct command *cmd, /* Is there a port? */ if (!port) { port = tal(cmd, u32); - *port = DEFAULT_PORT; + *port = chainparams->ln_port; } addr = tal(cmd, struct wireaddr_internal); if (!parse_wireaddr_internal(name, addr, *port, false, diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index b8e60b3fff65..08f72a02d8da 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -969,7 +969,7 @@ int main(int argc, char *argv[]) /*~ Set the default portnum according to the used network * similarly to what Bitcoin Core does to ports by default. */ - ld->portnum = DEFAULT_PORT + chainparams->rpc_port - 8332; + ld->portnum = chainparams->ln_port; /*~ Initialize all the plugins we just registered, so they can * do their thing and tell us about themselves (including