Skip to content

Commit c5cd479

Browse files
rustyrussellcdecker
authored andcommitted
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 <[email protected]>
1 parent c919551 commit c5cd479

File tree

3 files changed

+193
-80
lines changed

3 files changed

+193
-80
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ changes.
5252
- Protocol: fix occasional deadlock when both peers flood with gossip.
5353
- Protocol: fix occasional long delay on sending `reply_short_channel_ids_end`.
5454
- Protocol: re-send `node_announcement` when address/alias/color etc change.
55+
- Protocol: multiple HTLCs with the same payment_hash are handled correctly.
5556
- Options: 'autotor' defaults to port 9051 if not specified.
5657

5758
### Security

0 commit comments

Comments
 (0)