Skip to content

Commit

Permalink
lightningd/opening_control: store funding scriptpubkey.
Browse files Browse the repository at this point in the history
We'll need it in next patch to identify the funding output.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Mar 12, 2021
1 parent 6b778a0 commit 1fc3cc8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 3 additions & 0 deletions lightningd/opening_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ struct funding_channel {
/* Channel, subsequent owner of us */
struct uncommitted_channel *uc;

/* The scriptpubkey to pay (once started) */
u8 *funding_scriptpubkey;

/* Whether or not this is in the middle of getting funded */
bool inflight;

Expand Down
14 changes: 8 additions & 6 deletions lightningd/opening_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,7 @@ static void funding_success(struct channel *channel)
was_pending(command_success(cmd, response));
}

static void funding_started_success(struct funding_channel *fc,
u8 *scriptPubkey,
bool supports_shutdown)
static void funding_started_success(struct funding_channel *fc)
{
struct json_stream *response;
struct command *cmd = fc->cmd;
Expand All @@ -277,10 +275,11 @@ static void funding_started_success(struct funding_channel *fc,
response = json_stream_success(cmd);
out = encode_scriptpubkey_to_addr(cmd,
chainparams,
scriptPubkey);
fc->funding_scriptpubkey);
if (out) {
json_add_string(response, "funding_address", out);
json_add_hex_talarr(response, "scriptpubkey", scriptPubkey);
json_add_hex_talarr(response, "scriptpubkey",
fc->funding_scriptpubkey);
if (fc->our_upfront_shutdown_script)
json_add_hex_talarr(response, "close_to", fc->our_upfront_shutdown_script);
}
Expand Down Expand Up @@ -314,7 +313,9 @@ static void opening_funder_start_replied(struct subd *openingd, const u8 *resp,
fc->our_upfront_shutdown_script =
tal_free(fc->our_upfront_shutdown_script);

funding_started_success(fc, funding_scriptPubkey, supports_shutdown_script);
/* Save this so we can indentify output for scriptpubkey */
fc->funding_scriptpubkey = tal_steal(fc, funding_scriptPubkey);
funding_started_success(fc);

/* Mark that we're in-flight */
fc->inflight = true;
Expand Down Expand Up @@ -1062,6 +1063,7 @@ static struct command_result *json_fundchannel_start(struct command *cmd,
fc->cancels = tal_arr(fc, struct command *, 0);
fc->uc = NULL;
fc->inflight = false;
fc->funding_scriptpubkey = NULL;

if (!param(fc->cmd, buffer, params,
p_req("id", param_node_id, &id),
Expand Down

0 comments on commit 1fc3cc8

Please sign in to comment.