diff --git a/channeldb/channel.go b/channeldb/channel.go index 9a7cfa39..2613269c 100644 --- a/channeldb/channel.go +++ b/channeldb/channel.go @@ -134,9 +134,10 @@ type OpenChannel struct { // Current revocation for their commitment transaction. However, since // this the derived public key, we don't yet have the pre-image so we // aren't yet able to verify that it's actually in the hash chain. - TheirCurrentRevocation *btcec.PublicKey - LocalElkrem *elkrem.ElkremSender - RemoteElkrem *elkrem.ElkremReceiver + TheirCurrentRevocation *btcec.PublicKey + TheirCurrentRevocationHash [32]byte + LocalElkrem *elkrem.ElkremSender + RemoteElkrem *elkrem.ElkremReceiver // The pkScript for both sides to be used for final delivery in the case // of a cooperative close. @@ -1029,6 +1030,10 @@ func putChanEklremState(nodeChanBucket *bolt.Bucket, channel *OpenChannel) error return err } + if _, err := b.Write(channel.TheirCurrentRevocationHash[:]); err != nil { + return err + } + // TODO(roasbeef): shouldn't be storing on disk, should re-derive as // needed senderBytes := channel.LocalElkrem.ToBytes() @@ -1074,6 +1079,10 @@ func fetchChanEklremState(nodeChanBucket *bolt.Bucket, channel *OpenChannel) err return err } + if _, err := elkremStateBytes.Read(channel.TheirCurrentRevocationHash[:]); err != nil { + return err + } + // TODO(roasbeef): should be rederiving on fly, or encrypting on disk. senderBytes, err := wire.ReadVarBytes(elkremStateBytes, 0, 1000, "") if err != nil { diff --git a/channeldb/channel_test.go b/channeldb/channel_test.go index 21507177..3d2c62e5 100644 --- a/channeldb/channel_test.go +++ b/channeldb/channel_test.go @@ -295,6 +295,9 @@ func TestOpenChannelPutGetDelete(t *testing.T) { if !newState.TheirCurrentRevocation.IsEqual(state.TheirCurrentRevocation) { t.Fatalf("revocation keys don't match") } + if !bytes.Equal(newState.TheirCurrentRevocationHash[:], state.TheirCurrentRevocationHash[:]) { + t.Fatalf("revocation hashes don't match") + } // Finally to wrap up the test, delete the state of the channel within // the database. This involves "closing" the channel which removes all