mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-17 19:03:42 +01:00
dev: add option flag for specifying temporary channel id
--dev-force-tmp-channel-id flag takes a 64-character hex string to use as the temporary channel id. Useful for spec tests [ Fixed crash in non-DEVELOPER mode --RR ] Changelog-None
This commit is contained in:
parent
a333df449a
commit
28cdccfb11
@ -126,6 +126,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
|
||||
ld->dev_force_bip32_seed = NULL;
|
||||
ld->dev_force_channel_secrets = NULL;
|
||||
ld->dev_force_channel_secrets_shaseed = NULL;
|
||||
ld->dev_force_tmp_channel_id = NULL;
|
||||
#endif
|
||||
|
||||
/*~ These are CCAN lists: an embedded double-linked list. It's not
|
||||
|
@ -223,6 +223,8 @@ struct lightningd {
|
||||
/* These are the forced channel secrets for the node. */
|
||||
struct secrets *dev_force_channel_secrets;
|
||||
struct sha256 *dev_force_channel_secrets_shaseed;
|
||||
|
||||
struct channel_id *dev_force_tmp_channel_id;
|
||||
#endif /* DEVELOPER */
|
||||
|
||||
/* tor support */
|
||||
|
@ -965,6 +965,7 @@ void peer_start_openingd(struct peer *peer,
|
||||
feature_negotiated(peer->features,
|
||||
OPT_STATIC_REMOTEKEY),
|
||||
send_msg,
|
||||
IFDEV(peer->ld->dev_force_tmp_channel_id, NULL),
|
||||
IFDEV(peer->ld->dev_fast_gossip, false));
|
||||
subd_send_msg(uc->openingd, take(msg));
|
||||
}
|
||||
|
@ -449,6 +449,17 @@ static char *opt_force_bip32_seed(const char *optarg, struct lightningd *ld)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *opt_force_tmp_channel_id(const char *optarg, struct lightningd *ld)
|
||||
{
|
||||
tal_free(ld->dev_force_tmp_channel_id);
|
||||
ld->dev_force_tmp_channel_id = tal(ld, struct channel_id);
|
||||
if (!hex_decode(optarg, strlen(optarg),
|
||||
ld->dev_force_tmp_channel_id,
|
||||
sizeof(*ld->dev_force_tmp_channel_id)))
|
||||
return tal_fmt(NULL, "Unable to parse channel id '%s'", optarg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *opt_force_channel_secrets(const char *optarg,
|
||||
struct lightningd *ld)
|
||||
{
|
||||
@ -535,6 +546,8 @@ static void dev_register_opts(struct lightningd *ld)
|
||||
"Maximum number of blocks we wait for a channel "
|
||||
"funding transaction to confirm, if we are the "
|
||||
"fundee.");
|
||||
opt_register_arg("--dev-force-tmp-channel-id", opt_force_tmp_channel_id, NULL, ld,
|
||||
"Force the temporary channel id, instead of random");
|
||||
}
|
||||
#endif /* DEVELOPER */
|
||||
|
||||
|
@ -24,6 +24,7 @@ msgdata,opening_init,option_static_remotekey,bool,
|
||||
# Optional msg to send.
|
||||
msgdata,opening_init,len,u16,
|
||||
msgdata,opening_init,msg,u8,len
|
||||
msgdata,opening_init,dev_temporary_channel_id,?byte,32
|
||||
msgdata,opening_init,dev_fast_gossip,bool,
|
||||
|
||||
# Openingd->master: they offered channel, should we continue?
|
||||
|
|
@ -15,6 +15,7 @@
|
||||
#include <ccan/breakpoint/breakpoint.h>
|
||||
#include <ccan/cast/cast.h>
|
||||
#include <ccan/fdpass/fdpass.h>
|
||||
#include <ccan/mem/mem.h>
|
||||
#include <ccan/tal/str/str.h>
|
||||
#include <common/crypto_sync.h>
|
||||
#include <common/derive_basepoints.h>
|
||||
@ -54,6 +55,11 @@
|
||||
#define REQ_FD STDIN_FILENO
|
||||
#define HSM_FD 6
|
||||
|
||||
#if DEVELOPER
|
||||
/* If --dev-force-tmp-channel-id is set, it ends up here */
|
||||
static struct channel_id *dev_force_tmp_channel_id;
|
||||
#endif /* DEVELOPER */
|
||||
|
||||
/* Global state structure. This is only for the one specific peer and channel */
|
||||
struct state {
|
||||
struct per_peer_state *pps;
|
||||
@ -463,6 +469,11 @@ static bool setup_channel_funder(struct state *state)
|
||||
* until we know their funding_pubkey) */
|
||||
temporary_channel_id(&state->channel_id);
|
||||
|
||||
#if DEVELOPER
|
||||
/* --dev-force-tmp-channel-id specified */
|
||||
if (dev_force_tmp_channel_id)
|
||||
state->channel_id = *dev_force_tmp_channel_id;
|
||||
#endif
|
||||
/* BOLT #2:
|
||||
*
|
||||
* The sending node:
|
||||
@ -1420,6 +1431,7 @@ int main(int argc, char *argv[])
|
||||
struct pollfd pollfd[3];
|
||||
struct state *state = tal(NULL, struct state);
|
||||
struct secret *none;
|
||||
struct channel_id *force_tmp_channel_id;
|
||||
|
||||
subdaemon_setup(argc, argv);
|
||||
|
||||
@ -1442,9 +1454,14 @@ int main(int argc, char *argv[])
|
||||
&state->features,
|
||||
&state->option_static_remotekey,
|
||||
&inner,
|
||||
&force_tmp_channel_id,
|
||||
&dev_fast_gossip))
|
||||
master_badmsg(WIRE_OPENING_INIT, msg);
|
||||
|
||||
#if DEVELOPER
|
||||
dev_force_tmp_channel_id = force_tmp_channel_id;
|
||||
#endif
|
||||
|
||||
/* 3 == peer, 4 == gossipd, 5 = gossip_store, 6 = hsmd */
|
||||
per_peer_state_set_fds(state->pps, 3, 4, 5);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user