mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
funding: add a 'inflight' marker
We need a way to gate allowing continue to proceed or not
This commit is contained in:
committed by
Rusty Russell
parent
7ea21c36b1
commit
8a60caaed9
@@ -85,6 +85,9 @@ struct funding_channel {
|
|||||||
|
|
||||||
/* Channel, subsequent owner of us */
|
/* Channel, subsequent owner of us */
|
||||||
struct uncommitted_channel *uc;
|
struct uncommitted_channel *uc;
|
||||||
|
|
||||||
|
/* Whether or not this is in the middle of getting funded */
|
||||||
|
bool inflight;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void uncommitted_channel_disconnect(struct uncommitted_channel *uc,
|
static void uncommitted_channel_disconnect(struct uncommitted_channel *uc,
|
||||||
@@ -318,8 +321,10 @@ static void opening_funder_start_replied(struct subd *openingd, const u8 *resp,
|
|||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: save the peer to the database?
|
|
||||||
funding_started_success(fc, funding_scriptPubkey);
|
funding_started_success(fc, funding_scriptPubkey);
|
||||||
|
|
||||||
|
/* Mark that we're in-flight */
|
||||||
|
fc->inflight = true;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
@@ -1086,7 +1091,7 @@ static struct command_result *json_fund_channel_continue(struct command *cmd,
|
|||||||
if (!peer->uncommitted_channel)
|
if (!peer->uncommitted_channel)
|
||||||
return command_fail(cmd, LIGHTNINGD, "Peer not connected");
|
return command_fail(cmd, LIGHTNINGD, "Peer not connected");
|
||||||
|
|
||||||
if (!peer->uncommitted_channel->fc)
|
if (!peer->uncommitted_channel->fc || !peer->uncommitted_channel->fc->inflight)
|
||||||
return command_fail(cmd, LIGHTNINGD, "No channel funding in progress.");
|
return command_fail(cmd, LIGHTNINGD, "No channel funding in progress.");
|
||||||
|
|
||||||
msg = towire_opening_funder_continue(NULL,
|
msg = towire_opening_funder_continue(NULL,
|
||||||
@@ -1114,6 +1119,7 @@ static struct command_result *json_fund_channel_start(struct command *cmd,
|
|||||||
max_funding_satoshi = get_chainparams(cmd->ld)->max_funding;
|
max_funding_satoshi = get_chainparams(cmd->ld)->max_funding;
|
||||||
fc->cmd = cmd;
|
fc->cmd = cmd;
|
||||||
fc->uc = NULL;
|
fc->uc = NULL;
|
||||||
|
fc->inflight = false;
|
||||||
if (!param(fc->cmd, buffer, params,
|
if (!param(fc->cmd, buffer, params,
|
||||||
p_req("id", param_node_id, &id),
|
p_req("id", param_node_id, &id),
|
||||||
p_req("satoshi", param_sat, &amount),
|
p_req("satoshi", param_sat, &amount),
|
||||||
@@ -1207,6 +1213,7 @@ static struct command_result *json_fund_channel(struct command *cmd,
|
|||||||
|
|
||||||
fc->cmd = cmd;
|
fc->cmd = cmd;
|
||||||
fc->uc = NULL;
|
fc->uc = NULL;
|
||||||
|
fc->inflight = false;
|
||||||
fc->wtx = tal(fc, struct wallet_tx);
|
fc->wtx = tal(fc, struct wallet_tx);
|
||||||
wtx_init(cmd, fc->wtx, max_funding_satoshi);
|
wtx_init(cmd, fc->wtx, max_funding_satoshi);
|
||||||
if (!param(fc->cmd, buffer, params,
|
if (!param(fc->cmd, buffer, params,
|
||||||
|
|||||||
Reference in New Issue
Block a user