mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 07:34:24 +01:00
plugin: make sure multifundchannel / fundchannel unreserve correctly on failure.
We were marking our inputs very late, which means any early failure would not know to unreserve them. This becomes particularly bad when we start enforcing emergency reserves. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -1203,11 +1203,6 @@ mfc_psbt_acquired(struct multifundchannel_command *mfc)
|
|||||||
* for the life of the tx */
|
* for the life of the tx */
|
||||||
psbt_add_serials(mfc->psbt, TX_INITIATOR);
|
psbt_add_serials(mfc->psbt, TX_INITIATOR);
|
||||||
|
|
||||||
/* We also mark all of our inputs as *ours*, so we
|
|
||||||
* can easily identify them for `signpsbt`, later */
|
|
||||||
for (size_t i = 0; i < mfc->psbt->num_inputs; i++)
|
|
||||||
psbt_input_mark_ours(mfc->psbt, &mfc->psbt->inputs[i]);
|
|
||||||
|
|
||||||
return perform_channel_start(mfc);
|
return perform_channel_start(mfc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1372,6 +1367,10 @@ after_fundpsbt(struct command *cmd,
|
|||||||
if (!psbt_set_version(mfc->psbt, 2))
|
if (!psbt_set_version(mfc->psbt, 2))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
/* Mark our inputs now, so we unreserve correctly on failure! */
|
||||||
|
for (size_t i = 0; i < mfc->psbt->num_inputs; i++)
|
||||||
|
psbt_input_mark_ours(mfc->psbt, &mfc->psbt->inputs[i]);
|
||||||
|
|
||||||
field = json_get_member(buf, result, "feerate_per_kw");
|
field = json_get_member(buf, result, "feerate_per_kw");
|
||||||
if (!field || !json_to_u32(buf, field, &mfc->feerate_per_kw))
|
if (!field || !json_to_u32(buf, field, &mfc->feerate_per_kw))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|||||||
Reference in New Issue
Block a user