mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +01:00
state: use INPUT_RVALUE instead of CMD_SEND_HTLC_FULFILL during closing.
We'd expect stop_commands to stop all commands, but we (ab)used CMD_SEND_HTLC_FULFILL to send us R values even in closing state. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
6
state.c
6
state.c
@@ -740,7 +740,7 @@ enum state state(const enum state state, const struct state_data *sdata,
|
|||||||
idata->cmd,
|
idata->cmd,
|
||||||
BITCOIN_HTLC_RETURN_SPEND_DONE));
|
BITCOIN_HTLC_RETURN_SPEND_DONE));
|
||||||
return state;
|
return state;
|
||||||
} else if (input_is(input, CMD_SEND_HTLC_FULFILL)) {
|
} else if (input_is(input, INPUT_RVALUE)) {
|
||||||
/* This gives us the r value. */
|
/* This gives us the r value. */
|
||||||
set_effect(effect, r_value,
|
set_effect(effect, r_value,
|
||||||
r_value_from_cmd(effect, sdata,
|
r_value_from_cmd(effect, sdata,
|
||||||
@@ -1060,8 +1060,8 @@ fail_during_close:
|
|||||||
BITCOIN_HTLC_TOTHEM_TIMEOUT);
|
BITCOIN_HTLC_TOTHEM_TIMEOUT);
|
||||||
/* Expect either close or spendthem to complete */
|
/* Expect either close or spendthem to complete */
|
||||||
if (htlcs) {
|
if (htlcs) {
|
||||||
/* FIXME: Make sure caller uses CMD_HTLC_FULFILL again
|
/* FIXME: Make sure caller uses INPUT_RVAL
|
||||||
* if they were in the middle of one! */
|
* if they were in the middle of FULFILL! */
|
||||||
set_effect(effect, watch_htlcs, htlcs);
|
set_effect(effect, watch_htlcs, htlcs);
|
||||||
return STATE_CLOSE_WAIT_SPENDTHEM_CLOSE_WITH_HTLCS;
|
return STATE_CLOSE_WAIT_SPENDTHEM_CLOSE_WITH_HTLCS;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -258,6 +258,14 @@ enum state_input {
|
|||||||
*/
|
*/
|
||||||
INPUT_CLOSE_COMPLETE_TIMEOUT,
|
INPUT_CLOSE_COMPLETE_TIMEOUT,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Inject a known R value.
|
||||||
|
*
|
||||||
|
* In normal operation, use CMD_SEND_HTLC_FULFILL; this is for
|
||||||
|
* after a unilateral close.
|
||||||
|
*/
|
||||||
|
INPUT_RVALUE,
|
||||||
|
|
||||||
/* Commands */
|
/* Commands */
|
||||||
CMD_SEND_HTLC_UPDATE,
|
CMD_SEND_HTLC_UPDATE,
|
||||||
CMD_SEND_HTLC_FULFILL,
|
CMD_SEND_HTLC_FULFILL,
|
||||||
|
|||||||
@@ -1019,6 +1019,7 @@ static struct trail *add_trail(enum state_input input,
|
|||||||
t->before = *before;
|
t->before = *before;
|
||||||
t->after = *after;
|
t->after = *after;
|
||||||
if (input == CMD_SEND_HTLC_FULFILL
|
if (input == CMD_SEND_HTLC_FULFILL
|
||||||
|
|| input == INPUT_RVALUE
|
||||||
|| input == BITCOIN_HTLC_TOTHEM_TIMEOUT
|
|| input == BITCOIN_HTLC_TOTHEM_TIMEOUT
|
||||||
|| input == BITCOIN_HTLC_TOTHEM_SPENT
|
|| input == BITCOIN_HTLC_TOTHEM_SPENT
|
||||||
|| input == BITCOIN_HTLC_TOUS_TIMEOUT
|
|| input == BITCOIN_HTLC_TOUS_TIMEOUT
|
||||||
@@ -1741,7 +1742,7 @@ static bool can_refire(enum state_input i)
|
|||||||
|
|
||||||
/* They could have lots of htlcs. */
|
/* They could have lots of htlcs. */
|
||||||
if (i == BITCOIN_HTLC_TOTHEM_SPENT || i == BITCOIN_HTLC_TOTHEM_TIMEOUT
|
if (i == BITCOIN_HTLC_TOTHEM_SPENT || i == BITCOIN_HTLC_TOTHEM_TIMEOUT
|
||||||
|| i == BITCOIN_HTLC_TOUS_TIMEOUT || i == CMD_SEND_HTLC_FULFILL)
|
|| i == BITCOIN_HTLC_TOUS_TIMEOUT)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/* We manually remove these if they're not watching any more spends */
|
/* We manually remove these if they're not watching any more spends */
|
||||||
@@ -1870,7 +1871,7 @@ static struct trail *run_peer(const struct state_data *sdata,
|
|||||||
idata->htlc = (struct htlc *)©.live_htlcs_to_us[i];
|
idata->htlc = (struct htlc *)©.live_htlcs_to_us[i];
|
||||||
/* Only send this once. */
|
/* Only send this once. */
|
||||||
if (!rval_known(sdata, idata->htlc->id)) {
|
if (!rval_known(sdata, idata->htlc->id)) {
|
||||||
t = try_input(©, CMD_SEND_HTLC_FULFILL,
|
t = try_input(©, INPUT_RVALUE,
|
||||||
idata, normalpath, errorpath,
|
idata, normalpath, errorpath,
|
||||||
depth, hist);
|
depth, hist);
|
||||||
if (t)
|
if (t)
|
||||||
|
|||||||
Reference in New Issue
Block a user