lightningd: don't print nasty message when onchaind fails partially-failed HTLC

1. We set an outgoing htlc's `failonion` when we get a commitment_signed.
2. We don't transfer it to the corresponding incoming HTLC until we send
   commitment_signed and receive revoke_and_ack (meaning, outgoing htlc is
   completely dead).
3. If between these steps we go onchain, onchaind (after 3 blocks) tells us
   to fail the HTLC.
4. hout->failonion is set, but hout->hin has not been failed yet.  We
   do a sanity check and print a nasty message, and fail it with
   WIRE_PERMANENT_CHANNEL_FAILURE instead of relaying the error.

So handle this case explicitly.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2022-06-26 14:10:01 +09:30
parent 353361a05c
commit 517828adb2
2 changed files with 13 additions and 2 deletions

View File

@@ -5267,7 +5267,6 @@ def test_pay_bolt11_metadata(node_factory, bitcoind):
l2.daemon.wait_for_log("Unexpected payment_metadata {}".format(b'this is metadata'.hex()))
@pytest.mark.xfail(strict=True)
@pytest.mark.developer("needs to dev-disconnect")
def test_pay_middle_fail(node_factory, bitcoind, executor):
"""Test the case where a HTLC is failed, but not on peer's side, then
@@ -5308,5 +5307,5 @@ def test_pay_middle_fail(node_factory, bitcoind, executor):
bitcoind.generate_block(3, wait_for_mempool=1)
# And that will fail upstream
with pytest.raises(RpcError, match=r'WIRE_PERMANENT_CHANNEL_FAILURE'):
with pytest.raises(RpcError, match=r'WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS'):
l1.rpc.waitsendpay('00' * 32)