lnwire: add a ChainHash field to ChannelUpdate
This commit adds a ChainHash field to the ChannelUpdate message in order to ensure that we’re compatible with the recent change to BOLT-0007.
This commit is contained in:
parent
50c679afa3
commit
e93197b303
@ -5,6 +5,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/roasbeef/btcd/btcec"
|
"github.com/roasbeef/btcd/btcec"
|
||||||
|
"github.com/roasbeef/btcd/chaincfg/chainhash"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ChannelUpdate message is used after channel has been initially announced.
|
// ChannelUpdate message is used after channel has been initially announced.
|
||||||
@ -16,11 +17,17 @@ type ChannelUpdate struct {
|
|||||||
// ownership of node id.
|
// ownership of node id.
|
||||||
Signature *btcec.Signature
|
Signature *btcec.Signature
|
||||||
|
|
||||||
|
// ChainHash denotes the target chain that this channel was opened
|
||||||
|
// within. This value should be the genesis hash of the target chain.
|
||||||
|
// Along with the short channel ID, this uniquely identifies the
|
||||||
|
// channel globally in a blockchain.
|
||||||
|
ChainHash chainhash.Hash
|
||||||
|
|
||||||
// ShortChannelID is the unique description of the funding transaction.
|
// ShortChannelID is the unique description of the funding transaction.
|
||||||
ShortChannelID ShortChannelID
|
ShortChannelID ShortChannelID
|
||||||
|
|
||||||
// Timestamp allows ordering in the case of multiple announcements.
|
// Timestamp allows ordering in the case of multiple announcements. We
|
||||||
// We should ignore the message if timestamp is not greater than
|
// should ignore the message if timestamp is not greater than
|
||||||
// the last-received.
|
// the last-received.
|
||||||
Timestamp uint32
|
Timestamp uint32
|
||||||
|
|
||||||
@ -37,7 +44,7 @@ type ChannelUpdate struct {
|
|||||||
TimeLockDelta uint16
|
TimeLockDelta uint16
|
||||||
|
|
||||||
// HtlcMinimumMsat is the minimum HTLC value which will be accepted.
|
// HtlcMinimumMsat is the minimum HTLC value which will be accepted.
|
||||||
HtlcMinimumMsat uint64
|
HtlcMinimumMsat MilliSatoshi
|
||||||
|
|
||||||
// BaseFee is the base fee that must be used for incoming HTLC's to
|
// BaseFee is the base fee that must be used for incoming HTLC's to
|
||||||
// this particular channel. This value will be tacked onto the required
|
// this particular channel. This value will be tacked onto the required
|
||||||
@ -60,6 +67,7 @@ var _ Message = (*ChannelUpdate)(nil)
|
|||||||
func (a *ChannelUpdate) Decode(r io.Reader, pver uint32) error {
|
func (a *ChannelUpdate) Decode(r io.Reader, pver uint32) error {
|
||||||
return readElements(r,
|
return readElements(r,
|
||||||
&a.Signature,
|
&a.Signature,
|
||||||
|
a.ChainHash[:],
|
||||||
&a.ShortChannelID,
|
&a.ShortChannelID,
|
||||||
&a.Timestamp,
|
&a.Timestamp,
|
||||||
&a.Flags,
|
&a.Flags,
|
||||||
@ -77,6 +85,7 @@ func (a *ChannelUpdate) Decode(r io.Reader, pver uint32) error {
|
|||||||
func (a *ChannelUpdate) Encode(w io.Writer, pver uint32) error {
|
func (a *ChannelUpdate) Encode(w io.Writer, pver uint32) error {
|
||||||
return writeElements(w,
|
return writeElements(w,
|
||||||
a.Signature,
|
a.Signature,
|
||||||
|
a.ChainHash[:],
|
||||||
a.ShortChannelID,
|
a.ShortChannelID,
|
||||||
a.Timestamp,
|
a.Timestamp,
|
||||||
a.Flags,
|
a.Flags,
|
||||||
@ -105,6 +114,9 @@ func (a *ChannelUpdate) MaxPayloadLength(pver uint32) uint32 {
|
|||||||
// Signature - 64 bytes
|
// Signature - 64 bytes
|
||||||
length += 64
|
length += 64
|
||||||
|
|
||||||
|
// ChainHash - 64 bytes
|
||||||
|
length += 32
|
||||||
|
|
||||||
// ShortChannelID - 8 bytes
|
// ShortChannelID - 8 bytes
|
||||||
length += 8
|
length += 8
|
||||||
|
|
||||||
@ -136,6 +148,7 @@ func (a *ChannelUpdate) DataToSign() ([]byte, error) {
|
|||||||
// We should not include the signatures itself.
|
// We should not include the signatures itself.
|
||||||
var w bytes.Buffer
|
var w bytes.Buffer
|
||||||
err := writeElements(&w,
|
err := writeElements(&w,
|
||||||
|
a.ChainHash[:],
|
||||||
a.ShortChannelID,
|
a.ShortChannelID,
|
||||||
a.Timestamp,
|
a.Timestamp,
|
||||||
a.Flags,
|
a.Flags,
|
||||||
|
Loading…
Reference in New Issue
Block a user