decred / dcrlnd

Decred Lightning Network Daemon ⚡️
MIT License
36 stars 24 forks source link

Breach arbiter should watch for spends that invalidate justice tx #96

Open matheusd opened 4 years ago

matheusd commented 4 years ago

When publishing the justice transaction (https://github.com/decred/dcrlnd/blob/29759788a0212a4777aac8a7bd0f4410a9a9b3a6/breacharbiter.go#L572-L573) if the transaction is successfully published the breach arbiter assumes the transaction will be mined.

However it might be the case that one of the inputs gets double spent making the justice tx invalid. One way this can happen is in SPV mode where the transaction fails to be relayed in time and a different second-level htlc transaction is published.

The breach arbiter should watch for spends of the inputs of the justice transaction and craft a different justice tx even if the original publishing was correct.

Fixing this will allow enabling the "testRevokedCloseRetributionRemoteHodlSecondLevel" test for the SPV backend.