lnwallet: fix ordering of keys when we generate the sender script during a breach

In this commit, we fix an existing within lnd. Before this commit,
within NewBreachRetribution the order of the keys when generating the
sender HTLC script was incorrect. As in this case, the remote party is
the sender, their key should be first. However, the order was swapped,
meaning that at breach time, our transaction would be rejected as it had
the incorrect witness script.

The fix is simple: swap the ordering of the keys. After this commit, the
test extension added in the prior commit now passes.
This commit is contained in:
Olaoluwa Osuntokun 2018-04-04 17:07:07 -07:00
parent e91dff44e6
commit 4e44528bff
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

View File

@ -1992,7 +1992,7 @@ func NewBreachRetribution(chanState *channeldb.OpenChannel, stateNum uint64,
// re-generate the sender HTLC script.
if htlc.Incoming {
htlcScript, err = senderHTLCScript(
keyRing.LocalHtlcKey, keyRing.RemoteHtlcKey,
keyRing.RemoteHtlcKey, keyRing.LocalHtlcKey,
keyRing.RevocationKey, htlc.RHash[:],
)
if err != nil {