From 4e44528bffc2f4b4840dec0e24d3f24f3ff640b0 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 4 Apr 2018 17:07:07 -0700 Subject: [PATCH] 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. --- lnwallet/channel.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lnwallet/channel.go b/lnwallet/channel.go index 22717eda8..2581c165b 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -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 {