closingd: fix case where we we can pass under min-relay-fee for mutual close.

In spec commit 498f104fd399488c77f449d05cb21c0b604636a2 (August 2021),
Bastien Teinturier removed the requirement that the mutual close fee be
less than or equal the final commitment tx.

We adopted that change in v0.10.2, but we made sure to never offer a fee
under the final commitment tx's fee, so we didn't break older nodes.

However, the closing tx can actually be larger than the final commitment tx!
The final commit tx has a 22-byte P2WKH output and a 34-byte P2WSH output;
the closing can have two 34-byte outputs, making it 4*8 = 32 Sipa heavier.
Previously this would only happen if both sides asked for P2WSH outputs,
but now it happens with P2TR, which we now do.

The result is that we create a tx which is below the finally commitment
tx fee, and may be below minrelayfee (as it was in regtest).

So it's time to remove that backwards-compatibility hack.

Changelog-Fixed: Protocol: We may propose mutual close transaction which has a slightly higher fee than the final commitment tx (depending on the outputs, e.g. two taproot outputs).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Fixes: #6545
This commit is contained in:
Rusty Russell
2023-08-12 09:44:11 +09:30
parent 8f16b0593c
commit 6a16a6fe25
4 changed files with 39 additions and 72 deletions

View File

@@ -3354,13 +3354,15 @@ Try a range of future segwit versions as shutdown scripts. We create many nodes
@pytest.mark.developer("needs to set dev-disconnect")
def test_closing_higherfee(node_factory, bitcoind, executor):
"""With anchor outputs we can ask for a *higher* fee than the last commit tx"""
@pytest.mark.parametrize("anchors", [False, True])
def test_closing_higherfee(node_factory, bitcoind, executor, anchors):
"""We can ask for a *higher* fee than the last commit tx"""
opts = {'may_reconnect': True,
'dev-no-reconnect': None,
'experimental-anchors': None,
'feerates': (7500, 7500, 7500, 7500)}
if anchors:
opts['experimental-anchors'] = None
# We change the feerate before it starts negotiating close, so it aims
# for *higher* than last commit tx.
@@ -3379,7 +3381,7 @@ def test_closing_higherfee(node_factory, bitcoind, executor):
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
# This causes us to *exceed* previous requirements!
l1.daemon.wait_for_log(r'deriving max fee from rate 30000 -> .*sat \(not 1000000sat\)')
l1.daemon.wait_for_log(r'deriving max fee from rate 30000 -> .*sat')
# This will fail because l1 restarted!
with pytest.raises(RpcError, match=r'Connection to RPC server lost.'):
@@ -3904,7 +3906,6 @@ def test_closing_tx_valid(node_factory, bitcoind):
assert bitcoind.rpc.getrawtransaction(close['txid']) == close['tx']
@pytest.mark.xfail(strict=True)
@pytest.mark.developer("needs dev-no-reconnect")
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd does not provide feerates on regtest')
def test_closing_minfee(node_factory, bitcoind):