mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-04-09 20:49:08 +02:00
channeldb: also store their current revocation hash
We now also store their current revocation hash which is given to us along with the revocation key once an initial HTLC is added to a commitment transaction.
This commit is contained in:
parent
06af4b130f
commit
1f7d9b6425
@ -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 {
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user