mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
onchaind: allow multiple candidate HTLCs for output match
When we have multiple HTLCs with the same preimage and the same CLTV, it doesn't matter what order we treat them (they're literally identical). But when we offer HTLCs with the same preimage but different CLTVs, the commitment tx outputs look identical, but the HTLC txs are different: if we simply take the first HTLC which matches (and that's not the right one), the HTLC signature we got from them won't match. As we rely on the signature matching to detect the fee paid, we get: onchaind: STATUS_FAIL_INTERNAL_ERROR: grind_fee failed So we alter match_htlc_output() to return an array of all matching HTLC indices, which can have more than one entry for offered HTLCs. If it's our commitment, we loop through until one of the HTLC signatures matches. If it's their commitment, we choose the HTLC with the largest CLTV: we're going to ignore it once that hits anyway, so this is the most conservative approach. If it's a penalty, it doesn't matter since we steal all HTLC outputs the same independent of CLTV. For accepted HTLCs, the CLTV value is encoded in the witness script, so this confusion isn't possible. We nonetheless assert that the CLTVs all match in that case. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
c919551109
commit
c5cd4791be
@@ -630,7 +630,6 @@ def test_onchain_dust_out(node_factory, bitcoind, executor):
|
||||
assert only_one(l2.rpc.listinvoices('onchain_dust_out')['invoices'])['status'] == 'unpaid'
|
||||
|
||||
|
||||
@pytest.mark.xfail(strict=True)
|
||||
@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1")
|
||||
def test_onchain_timeout(node_factory, bitcoind, executor):
|
||||
"""Onchain handling of outgoing failed htlcs"""
|
||||
@@ -1094,7 +1093,6 @@ def setup_multihtlc_test(node_factory, bitcoind):
|
||||
return h, nodes
|
||||
|
||||
|
||||
@pytest.mark.xfail(strict=True)
|
||||
@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1 for dev_ignore_htlcs")
|
||||
def test_onchain_multihtlc_our_unilateral(node_factory, bitcoind):
|
||||
"""Node pushes a channel onchain with multiple HTLCs with same payment_hash """
|
||||
@@ -1182,7 +1180,6 @@ def test_onchain_multihtlc_our_unilateral(node_factory, bitcoind):
|
||||
assert only_one(nodes[i].rpc.listpeers(nodes[i + 1].info['id'])['peers'])['connected']
|
||||
|
||||
|
||||
@pytest.mark.xfail(strict=True)
|
||||
@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1 for dev_ignore_htlcs")
|
||||
def test_onchain_multihtlc_their_unilateral(node_factory, bitcoind):
|
||||
"""Node pushes a channel onchain with multiple HTLCs with same payment_hash """
|
||||
|
||||
Reference in New Issue
Block a user