[...]There must be a way to incentivize peers to act honestly; this is where penalty transactions come into place.A penalty transaction can be used by the cheated party to claim all the funds in the channel if the cheater publishes an old commitment transaction on-chain. This works because commitment transactions are represented by the HTLC contract, which enforces how the coins in a lightning channel can be spent.In a scenario where Alice is paying Bob, the HTLC contract if written in English would say something along these lines:
- Alice will pay Bob 0.5 BTC if Bob can reveal the secret of the hash he provided to Alice and provide a valid signature for his public key.
- If Bob doesn’t reveal the secret in a 500-block period, Alice can get her 0.5 BTC back.
- All the funds locked in the channel can be redeemed by whoever can provide a valid signature for the revocation public key present in this contract.
This third clause is what is used by the cheated party to create a penalty transaction. Let’s follow the lifetime of the channel in the images above and simulate a penalty transaction.[...]
A Lightning penalty transaction - by fiatjaf #833634