discovery: utilize exactly 9 bytes for serialized waitingProofKey

This commit is contained in:
Olaoluwa Osuntokun 2017-04-01 12:25:12 +02:00
parent 608b9d96d1
commit 1894a208bd
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
1 changed files with 5 additions and 5 deletions

View File

@ -10,7 +10,7 @@ import (
"github.com/roasbeef/btcd/btcec" "github.com/roasbeef/btcd/btcec"
) )
// newProofKey constructs new announcement signature message key. // newProofKey constructs a new announcement signature message key.
func newProofKey(chanID uint64, isRemote bool) waitingProofKey { func newProofKey(chanID uint64, isRemote bool) waitingProofKey {
return waitingProofKey{ return waitingProofKey{
chanID: chanID, chanID: chanID,
@ -18,9 +18,9 @@ func newProofKey(chanID uint64, isRemote bool) waitingProofKey {
} }
} }
// ToBytes represents the key in the byte format. // ToBytes returns a serialized representation of the key.
func (k waitingProofKey) ToBytes() []byte { func (k waitingProofKey) ToBytes() []byte {
var key [10]byte var key [9]byte
var b uint8 var b uint8
if k.isRemote { if k.isRemote {
@ -29,8 +29,8 @@ func (k waitingProofKey) ToBytes() []byte {
b = 1 b = 1
} }
binary.BigEndian.PutUint64(key[:], k.chanID) binary.BigEndian.PutUint64(key[:8], k.chanID)
key[9] = b key[8] = b
return key[:] return key[:]
} }