Skip to content

Satoshi amounts must be used for htlc comparison #1804

@pm47

Description

@pm47

Spec says that the equality is based on outputs, which are in sats:

Lexicographic ordering: see BIP69. In the case of identical HTLC outputs, the outputs are ordered in increasing cltv_expiry order.

We're using the millisatoshi amount:

def sort(a: CommitmentOutputLink[CommitmentOutput], b: CommitmentOutputLink[CommitmentOutput]): Boolean = (a.commitmentOutput, b.commitmentOutput) match {
case (OutHtlc(OutgoingHtlc(htlcA)), OutHtlc(OutgoingHtlc(htlcB))) if htlcA.paymentHash == htlcB.paymentHash && htlcA.amountMsat == htlcB.amountMsat =>
htlcA.cltvExpiry <= htlcB.cltvExpiry
case _ => LexicographicalOrdering.isLessThan(a.output, b.output)
}
}

This causes commitment sig mismatch and force closes.

Thanks @Roasbeef for the debug!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions