21
21
#include <stdio.h>
22
22
#include <wire/peer_wire.h>
23
23
24
- #define chainparams_get_ln_port simple_get_ln_port
25
24
#define io_write_ simple_write
26
25
#define io_read_ simple_read
27
26
#define io_close simple_close
28
27
static bool stream_stdin = false;
29
28
static bool no_init = false;
30
29
static bool hex = false;
30
+ static bool explicit_network = false;
31
31
static int timeout_after = -1 ;
32
32
static u8 * features ;
33
33
@@ -46,11 +46,6 @@ static struct io_plan *simple_close(struct io_conn *conn)
46
46
return NULL ;
47
47
}
48
48
49
- static int simple_get_ln_port (const struct chainparams * params UNNEEDED )
50
- {
51
- return 9735 ;
52
- }
53
-
54
49
#include "../connectd/handshake.c"
55
50
56
51
/* This makes the handshake prototypes work. */
@@ -83,6 +78,7 @@ static char *opt_set_network(const char *arg, void *unused)
83
78
chainparams = chainparams_for_network (arg );
84
79
if (!chainparams )
85
80
return tal_fmt (NULL , "Unknown network name '%s'" , arg );
81
+ explicit_network = true;
86
82
return NULL ;
87
83
}
88
84
@@ -184,12 +180,12 @@ static struct io_plan *handshake_success(struct io_conn *conn,
184
180
185
181
if (!no_init ) {
186
182
struct tlv_init_tlvs * tlvs = NULL ;
187
- if (chainparams ) {
183
+ if (explicit_network ) {
188
184
tlvs = tlv_init_tlvs_new (NULL );
189
185
tlvs -> networks = tal_arr (tlvs , struct bitcoin_blkid , 1 );
190
186
tlvs -> networks [0 ] = chainparams -> genesis_blockhash ;
191
187
}
192
- msg = towire_init (NULL , NULL , features , tlvs );
188
+ msg = towire_init (NULL , NULL , features , tlvs );
193
189
194
190
sync_crypto_write (peer_fd , cs , take (msg ));
195
191
/* Ignore their init message. */
@@ -287,6 +283,7 @@ int main(int argc, char *argv[])
287
283
288
284
memset (& notsosecret , 0x42 , sizeof (notsosecret ));
289
285
features = tal_arr (conn , u8 , 0 );
286
+ chainparams = chainparams_for_network ("bitcoin" );
290
287
291
288
opt_register_noarg ("--initial-sync" , opt_set_bool , & initial_sync ,
292
289
"Stream complete gossip history at start" );
@@ -328,7 +325,7 @@ int main(int argc, char *argv[])
328
325
opt_usage_exit_fail ("Invalid id %.*s" ,
329
326
(int )(at - argv [1 ]), argv [1 ]);
330
327
331
- if (!parse_wireaddr_internal (at + 1 , & addr , simple_get_ln_port ( NULL ), NULL ,
328
+ if (!parse_wireaddr_internal (at + 1 , & addr , chainparams_get_ln_port ( chainparams ), NULL ,
332
329
true, false, true, & err_msg ))
333
330
opt_usage_exit_fail ("%s '%s'" , err_msg , argv [1 ]);
334
331
0 commit comments