diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index effb92dcf..2341dd283 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -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 diff --git a/lightningd/lightningd.h b/lightningd/lightningd.h index 084f1901c..e3902211d 100644 --- a/lightningd/lightningd.h +++ b/lightningd/lightningd.h @@ -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 */ diff --git a/lightningd/opening_control.c b/lightningd/opening_control.c index 18319611c..57d04871e 100644 --- a/lightningd/opening_control.c +++ b/lightningd/opening_control.c @@ -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)); } diff --git a/lightningd/options.c b/lightningd/options.c index a962eaf40..a86acf557 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -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 */ diff --git a/openingd/opening_wire.csv b/openingd/opening_wire.csv index 69642a5d2..ecc743443 100644 --- a/openingd/opening_wire.csv +++ b/openingd/opening_wire.csv @@ -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? diff --git a/openingd/openingd.c b/openingd/openingd.c index 35fe7d52d..79a859f5c 100644 --- a/openingd/openingd.c +++ b/openingd/openingd.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -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);