Skip to content

Commit c0ed812

Browse files
lightnind: remove the DEFAULT_PORT global definition.
Signed-off-by: Vincenzo Palazzo <[email protected]>
1 parent 7ec6353 commit c0ed812

File tree

8 files changed

+16
-17
lines changed

8 files changed

+16
-17
lines changed

common/test/run-wireaddr.c

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
#include <common/setup.h>
55
#include <stdio.h>
66

7+
/* DEFAULT_PORT of the current network */
8+
#define DEFAULT_PORT 9735
9+
710
/* AUTOGENERATED MOCKS START */
811
/* Generated stub for amount_asset_is_main */
912
bool amount_asset_is_main(struct amount_asset *asset UNNEEDED)

common/wireaddr.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "config.h"
22
#include <arpa/inet.h>
33
#include <assert.h>
4+
#include <bitcoin/chainparams.h>
45
#include <ccan/mem/mem.h>
56
#include <ccan/tal/str/str.h>
67
#include <common/base32.h>
@@ -612,7 +613,7 @@ bool parse_wireaddr_internal(const char *arg, struct wireaddr_internal *addr,
612613
* an onion address. */
613614
if (strstarts(arg, "autotor:")) {
614615
addr->itype = ADDR_INTERNAL_AUTOTOR;
615-
addr->u.torservice.port = DEFAULT_PORT;
616+
addr->u.torservice.port = chainparams->ln_port;
616617
/* Format is separated by slash. */
617618
char **parts = tal_strsplit(tmpctx, arg, "/", STR_EMPTY_OK);
618619

@@ -644,7 +645,7 @@ bool parse_wireaddr_internal(const char *arg, struct wireaddr_internal *addr,
644645
if (strstarts(arg, "statictor:")) {
645646
bool use_magic_blob = true;
646647
addr->itype = ADDR_INTERNAL_STATICTOR;
647-
addr->u.torservice.port = DEFAULT_PORT;
648+
addr->u.torservice.port = chainparams->ln_port;
648649
memset(addr->u.torservice.blob, 0, sizeof(addr->u.torservice.blob));
649650

650651
/* Format is separated by slash. */

common/wireaddr.h

-8
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@ struct sockaddr_in6;
1212
struct sockaddr_in;
1313
struct sockaddr_un;
1414

15-
/* BOLT #1:
16-
*
17-
* The default TCP port is 9735. This corresponds to hexadecimal
18-
* `0x2607`: the Unicode code point for LIGHTNING.
19-
*/
20-
#define DEFAULT_PORT 9735
21-
22-
2315
/* BOLT #7:
2416
*
2517
* The following `address descriptor` types are defined:

connectd/connectd.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* it.
99
*/
1010
#include "config.h"
11+
#include <bitcoin/chainparams.h>
1112
#include <ccan/array_size/array_size.h>
1213
#include <ccan/asort/asort.h>
1314
#include <ccan/closefrom/closefrom.h>
@@ -1707,7 +1708,7 @@ static void add_seed_addrs(struct wireaddr_internal **addrs,
17071708

17081709
for (size_t i = 0; i < tal_count(hostnames); i++) {
17091710
status_peer_debug(id, "Resolving %s", hostnames[i]);
1710-
new_addrs = wireaddr_from_hostname(tmpctx, hostnames[i], DEFAULT_PORT,
1711+
new_addrs = wireaddr_from_hostname(tmpctx, hostnames[i], chainparams->ln_port,
17111712
NULL, broken_reply, NULL);
17121713
if (new_addrs) {
17131714
for (size_t j = 0; j < tal_count(new_addrs); j++) {
@@ -1859,7 +1860,7 @@ static void try_connect_peer(struct daemon *daemon,
18591860
for (size_t i = 0; i < tal_count(hostnames); i++) {
18601861
wireaddr_from_unresolved(&unresolved,
18611862
hostnames[i],
1862-
DEFAULT_PORT);
1863+
chainparams->ln_port);
18631864
tal_arr_expand(&addrs, unresolved);
18641865
}
18651866
} else if (daemon->use_dns) {

connectd/test/run-netaddress.c

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
#include <stdio.h>
1111
#include <wire/wire.h>
1212

13+
/* Default port of the current network */
14+
#define DEFAULT_PORT 9735
15+
1316
/* AUTOGENERATED MOCKS START */
1417
/* Generated stub for amount_asset_is_main */
1518
bool amount_asset_is_main(struct amount_asset *asset UNNEEDED)

devtools/gossipwith.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ int main(int argc, char *argv[])
322322
opt_usage_exit_fail("Invalid id %.*s",
323323
(int)(at - argv[1]), argv[1]);
324324

325-
if (!parse_wireaddr_internal(at+1, &addr, DEFAULT_PORT, NULL,
325+
if (!parse_wireaddr_internal(at+1, &addr, chainparams->ln_port, NULL,
326326
true, false, true, &err_msg))
327327
opt_usage_exit_fail("%s '%s'", err_msg, argv[1]);
328328

@@ -376,4 +376,3 @@ int main(int argc, char *argv[])
376376
handshake_success, argv+2);
377377
exit(0);
378378
}
379-

gossipd/gossipd.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,8 @@ static void handle_remote_addr(struct daemon *daemon, const u8 *msg)
350350
if (!fromwire_gossipd_remote_addr(msg, &remote_addr))
351351
master_badmsg(WIRE_GOSSIPD_REMOTE_ADDR, msg);
352352

353-
/* current best guess is that we use DEFAULT_PORT on public internet */
354-
remote_addr.port = DEFAULT_PORT;
353+
/* current best guess is that we use default port on public internet */
354+
remote_addr.port = chainparams->ln_port;
355355

356356
switch (remote_addr.type) {
357357
case ADDR_TYPE_IPV4:

wallet/wallet.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ static struct peer *wallet_peer_load(struct wallet *w, const u64 dbid)
837837
db_col_node_id(stmt, "node_id", &id);
838838

839839
addrstr = db_col_strdup(tmpctx, stmt, "address");
840-
if (!parse_wireaddr_internal(addrstr, &addr, DEFAULT_PORT,
840+
if (!parse_wireaddr_internal(addrstr, &addr, chainparams->ln_port,
841841
false, false, true, true, NULL))
842842
goto done;
843843

0 commit comments

Comments
 (0)