fundchannel, multifundchannel: reserve inputs for two weeks, not 12 hours.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: Plugins: `fundchannel` and `multifundchannel` will now reserve funding they use for 2 weeks instead of 12 hours.
This commit is contained in:
Rusty Russell
2021-05-26 10:49:38 +09:30
parent efe29c9db8
commit 14eddb95ba
2 changed files with 18 additions and 7 deletions

View File

@@ -205,6 +205,7 @@ mfc_cleanup_psbt(struct command *cmd,
}
json_add_psbt(req->js, "psbt", take(pruned_psbt));
json_add_u32(req->js, "reserve", 2016);
send_outreq(cmd->plugin, req);
}
@@ -651,6 +652,9 @@ after_signpsbt(struct command *cmd,
&mfc_forward_error,
mfc);
json_add_psbt(req->js, "psbt", mfc->psbt);
/* We already reserved inputs by 2 weeks, we don't need
* another 72 blocks. */
json_add_u32(req->js, "reserve", 0);
return send_outreq(mfc->cmd->plugin, req);
}
@@ -1406,7 +1410,13 @@ perform_fundpsbt(struct multifundchannel_command *mfc)
}
/* The entire point is to reserve the inputs. */
json_add_bool(req->js, "reserve", true);
/* BOLT #2:
* The sender:
*...
* - SHOULD ensure the funding transaction confirms in the next 2016
* blocks.
*/
json_add_u32(req->js, "reserve", 2016);
/* How much do we need to reserve? */
if (has_all(mfc))
json_add_string(req->js, "satoshi", "all");

View File

@@ -260,11 +260,12 @@ def test_channel_abandon(node_factory, bitcoind):
opening_utxo = only_one([o for o in l1.rpc.listfunds()['outputs'] if o['reserved']])
psbt = l1.rpc.utxopsbt(0, "253perkw", 0, [opening_utxo['txid'] + ':' + str(opening_utxo['output'])], reserve=False, reservedok=True)['psbt']
# Unreserve until it's considered unreserved.
count = 0
while only_one(l1.rpc.unreserveinputs(psbt)['reservations'])['reserved']:
count += 1
assert count == 1
# We expect a reservation for 2016 blocks; unreserve it.
reservations = only_one(l1.rpc.unreserveinputs(psbt, reserve=2015)['reservations'])
assert reservations['reserved']
assert reservations['reserved_to_block'] == bitcoind.rpc.getblockchaininfo()['blocks'] + 1
assert only_one(l1.rpc.unreserveinputs(psbt, reserve=1)['reservations'])['reserved'] is False
# Now it's unreserved, we can doublespend it (as long as we exceed
# previous fee to RBF!).