multi: rename ChannelUpdate to ChannelUpdate1
In preparation for adding a new ChannelUpdate2 message and a ChannelUpdate interface, we rename the existing message to ChannelUpdate1.
This commit is contained in:
43 files changed
+198
-172
No files matched your search
@@ -56,11 +56,11 @@ func (c ChanUpdateChanFlags) String() string {
|
||||
return fmt.Sprintf("%08b", c)
|
||||
}
|
||||
|
||||
// ChannelUpdate message is used after channel has been initially announced.
|
||||
// ChannelUpdate1 message is used after channel has been initially announced.
|
||||
// Each side independently announces its fees and minimum expiry for HTLCs and
|
||||
// other parameters. Also this message is used to redeclare initially set
|
||||
// channel parameters.
|
||||
type ChannelUpdate struct {
|
||||
type ChannelUpdate1 struct {
|
||||
// Signature is used to validate the announced data and prove the
|
||||
// ownership of node id.
|
||||
Signature Sig
|
||||
@@ -122,13 +122,13 @@ type ChannelUpdate struct {
|
||||
|
||||
// A compile time check to ensure ChannelUpdate implements the lnwire.Message
|
||||
// interface.
|
||||
var _ Message = (*ChannelUpdate)(nil)
|
||||
var _ Message = (*ChannelUpdate1)(nil)
|
||||
|
||||
// Decode deserializes a serialized ChannelUpdate stored in the passed
|
||||
// io.Reader observing the specified protocol version.
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (a *ChannelUpdate) Decode(r io.Reader, pver uint32) error {
|
||||
func (a *ChannelUpdate1) Decode(r io.Reader, pver uint32) error {
|
||||
err := ReadElements(r,
|
||||
&a.Signature,
|
||||
a.ChainHash[:],
|
||||
@@ -159,7 +159,7 @@ func (a *ChannelUpdate) Decode(r io.Reader, pver uint32) error {
|
||||
// observing the protocol version specified.
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (a *ChannelUpdate) Encode(w *bytes.Buffer, pver uint32) error {
|
||||
func (a *ChannelUpdate1) Encode(w *bytes.Buffer, pver uint32) error {
|
||||
if err := WriteSig(w, a.Signature); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -217,13 +217,13 @@ func (a *ChannelUpdate) Encode(w *bytes.Buffer, pver uint32) error {
|
||||
// wire.
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (a *ChannelUpdate) MsgType() MessageType {
|
||||
func (a *ChannelUpdate1) MsgType() MessageType {
|
||||
return MsgChannelUpdate
|
||||
}
|
||||
|
||||
// DataToSign is used to retrieve part of the announcement message which should
|
||||
// be signed.
|
||||
func (a *ChannelUpdate) DataToSign() ([]byte, error) {
|
||||
func (a *ChannelUpdate1) DataToSign() ([]byte, error) {
|
||||
// We should not include the signatures itself.
|
||||
b := make([]byte, 0, MaxMsgBody)
|
||||
buf := bytes.NewBuffer(b)
|
||||
|
||||
@@ -1100,7 +1100,7 @@ func TestLightningWireProtocol(t *testing.T) {
|
||||
maxHtlc = 0
|
||||
}
|
||||
|
||||
req := ChannelUpdate{
|
||||
req := ChannelUpdate1{
|
||||
ShortChannelID: NewShortChanIDFromInt(uint64(r.Int63())),
|
||||
Timestamp: uint32(r.Int31()),
|
||||
MessageFlags: msgFlags,
|
||||
@@ -1643,7 +1643,7 @@ func TestLightningWireProtocol(t *testing.T) {
|
||||
},
|
||||
{
|
||||
msgType: MsgChannelUpdate,
|
||||
scenario: func(m ChannelUpdate) bool {
|
||||
scenario: func(m ChannelUpdate1) bool {
|
||||
return mainScenario(&m)
|
||||
},
|
||||
},
|
||||
|
||||
+1
-1
@@ -261,7 +261,7 @@ func makeEmptyMessage(msgType MessageType) (Message, error) {
|
||||
case MsgChannelAnnouncement:
|
||||
msg = &ChannelAnnouncement1{}
|
||||
case MsgChannelUpdate:
|
||||
msg = &ChannelUpdate{}
|
||||
msg = &ChannelUpdate1{}
|
||||
case MsgNodeAnnouncement:
|
||||
msg = &NodeAnnouncement{}
|
||||
case MsgPing:
|
||||
|
||||
@@ -692,7 +692,7 @@ func newMsgNodeAnnouncement(t testing.TB,
|
||||
return msg
|
||||
}
|
||||
|
||||
func newMsgChannelUpdate(t testing.TB, r *rand.Rand) *lnwire.ChannelUpdate {
|
||||
func newMsgChannelUpdate(t testing.TB, r *rand.Rand) *lnwire.ChannelUpdate1 {
|
||||
t.Helper()
|
||||
|
||||
msgFlags := lnwire.ChanUpdateMsgFlags(r.Int31())
|
||||
@@ -706,7 +706,7 @@ func newMsgChannelUpdate(t testing.TB, r *rand.Rand) *lnwire.ChannelUpdate {
|
||||
maxHtlc = 0
|
||||
}
|
||||
|
||||
msg := &lnwire.ChannelUpdate{
|
||||
msg := &lnwire.ChannelUpdate1{
|
||||
ShortChannelID: lnwire.NewShortChanIDFromInt(r.Uint64()),
|
||||
Timestamp: uint32(r.Int31()),
|
||||
MessageFlags: msgFlags,
|
||||
|
||||
+24
-20
@@ -601,7 +601,7 @@ func (f *FailInvalidOnionKey) Error() string {
|
||||
// unable to pull out a fully valid version, then we'll fall back to the
|
||||
// regular parsing mechanism which includes the length prefix an NO type byte.
|
||||
func parseChannelUpdateCompatibilityMode(reader io.Reader, length uint16,
|
||||
chanUpdate *ChannelUpdate, pver uint32) error {
|
||||
chanUpdate *ChannelUpdate1, pver uint32) error {
|
||||
|
||||
// Instantiate a LimitReader because there may be additional data
|
||||
// present after the channel update. Without limiting the stream, the
|
||||
@@ -648,11 +648,13 @@ type FailTemporaryChannelFailure struct {
|
||||
// which caused the failure.
|
||||
//
|
||||
// NOTE: This field is optional.
|
||||
Update *ChannelUpdate
|
||||
Update *ChannelUpdate1
|
||||
}
|
||||
|
||||
// NewTemporaryChannelFailure creates new instance of the FailTemporaryChannelFailure.
|
||||
func NewTemporaryChannelFailure(update *ChannelUpdate) *FailTemporaryChannelFailure {
|
||||
func NewTemporaryChannelFailure(
|
||||
update *ChannelUpdate1) *FailTemporaryChannelFailure {
|
||||
|
||||
return &FailTemporaryChannelFailure{Update: update}
|
||||
}
|
||||
|
||||
@@ -686,7 +688,7 @@ func (f *FailTemporaryChannelFailure) Decode(r io.Reader, pver uint32) error {
|
||||
}
|
||||
|
||||
if length != 0 {
|
||||
f.Update = &ChannelUpdate{}
|
||||
f.Update = &ChannelUpdate1{}
|
||||
|
||||
return parseChannelUpdateCompatibilityMode(
|
||||
r, length, f.Update, pver,
|
||||
@@ -721,12 +723,12 @@ type FailAmountBelowMinimum struct {
|
||||
|
||||
// Update is used to update information about state of the channel
|
||||
// which caused the failure.
|
||||
Update ChannelUpdate
|
||||
Update ChannelUpdate1
|
||||
}
|
||||
|
||||
// NewAmountBelowMinimum creates new instance of the FailAmountBelowMinimum.
|
||||
func NewAmountBelowMinimum(htlcMsat MilliSatoshi,
|
||||
update ChannelUpdate) *FailAmountBelowMinimum {
|
||||
update ChannelUpdate1) *FailAmountBelowMinimum {
|
||||
|
||||
return &FailAmountBelowMinimum{
|
||||
HtlcMsat: htlcMsat,
|
||||
@@ -762,7 +764,7 @@ func (f *FailAmountBelowMinimum) Decode(r io.Reader, pver uint32) error {
|
||||
return err
|
||||
}
|
||||
|
||||
f.Update = ChannelUpdate{}
|
||||
f.Update = ChannelUpdate1{}
|
||||
|
||||
return parseChannelUpdateCompatibilityMode(
|
||||
r, length, &f.Update, pver,
|
||||
@@ -791,12 +793,12 @@ type FailFeeInsufficient struct {
|
||||
|
||||
// Update is used to update information about state of the channel
|
||||
// which caused the failure.
|
||||
Update ChannelUpdate
|
||||
Update ChannelUpdate1
|
||||
}
|
||||
|
||||
// NewFeeInsufficient creates new instance of the FailFeeInsufficient.
|
||||
func NewFeeInsufficient(htlcMsat MilliSatoshi,
|
||||
update ChannelUpdate) *FailFeeInsufficient {
|
||||
update ChannelUpdate1) *FailFeeInsufficient {
|
||||
return &FailFeeInsufficient{
|
||||
HtlcMsat: htlcMsat,
|
||||
Update: update,
|
||||
@@ -831,7 +833,7 @@ func (f *FailFeeInsufficient) Decode(r io.Reader, pver uint32) error {
|
||||
return err
|
||||
}
|
||||
|
||||
f.Update = ChannelUpdate{}
|
||||
f.Update = ChannelUpdate1{}
|
||||
|
||||
return parseChannelUpdateCompatibilityMode(
|
||||
r, length, &f.Update, pver,
|
||||
@@ -862,12 +864,12 @@ type FailIncorrectCltvExpiry struct {
|
||||
|
||||
// Update is used to update information about state of the channel
|
||||
// which caused the failure.
|
||||
Update ChannelUpdate
|
||||
Update ChannelUpdate1
|
||||
}
|
||||
|
||||
// NewIncorrectCltvExpiry creates new instance of the FailIncorrectCltvExpiry.
|
||||
func NewIncorrectCltvExpiry(cltvExpiry uint32,
|
||||
update ChannelUpdate) *FailIncorrectCltvExpiry {
|
||||
update ChannelUpdate1) *FailIncorrectCltvExpiry {
|
||||
|
||||
return &FailIncorrectCltvExpiry{
|
||||
CltvExpiry: cltvExpiry,
|
||||
@@ -900,7 +902,7 @@ func (f *FailIncorrectCltvExpiry) Decode(r io.Reader, pver uint32) error {
|
||||
return err
|
||||
}
|
||||
|
||||
f.Update = ChannelUpdate{}
|
||||
f.Update = ChannelUpdate1{}
|
||||
|
||||
return parseChannelUpdateCompatibilityMode(
|
||||
r, length, &f.Update, pver,
|
||||
@@ -925,11 +927,11 @@ func (f *FailIncorrectCltvExpiry) Encode(w *bytes.Buffer, pver uint32) error {
|
||||
type FailExpiryTooSoon struct {
|
||||
// Update is used to update information about state of the channel
|
||||
// which caused the failure.
|
||||
Update ChannelUpdate
|
||||
Update ChannelUpdate1
|
||||
}
|
||||
|
||||
// NewExpiryTooSoon creates new instance of the FailExpiryTooSoon.
|
||||
func NewExpiryTooSoon(update ChannelUpdate) *FailExpiryTooSoon {
|
||||
func NewExpiryTooSoon(update ChannelUpdate1) *FailExpiryTooSoon {
|
||||
return &FailExpiryTooSoon{
|
||||
Update: update,
|
||||
}
|
||||
@@ -958,7 +960,7 @@ func (f *FailExpiryTooSoon) Decode(r io.Reader, pver uint32) error {
|
||||
return err
|
||||
}
|
||||
|
||||
f.Update = ChannelUpdate{}
|
||||
f.Update = ChannelUpdate1{}
|
||||
|
||||
return parseChannelUpdateCompatibilityMode(
|
||||
r, length, &f.Update, pver,
|
||||
@@ -984,11 +986,13 @@ type FailChannelDisabled struct {
|
||||
|
||||
// Update is used to update information about state of the channel
|
||||
// which caused the failure.
|
||||
Update ChannelUpdate
|
||||
Update ChannelUpdate1
|
||||
}
|
||||
|
||||
// NewChannelDisabled creates new instance of the FailChannelDisabled.
|
||||
func NewChannelDisabled(flags uint16, update ChannelUpdate) *FailChannelDisabled {
|
||||
func NewChannelDisabled(flags uint16,
|
||||
update ChannelUpdate1) *FailChannelDisabled {
|
||||
|
||||
return &FailChannelDisabled{
|
||||
Flags: flags,
|
||||
Update: update,
|
||||
@@ -1023,7 +1027,7 @@ func (f *FailChannelDisabled) Decode(r io.Reader, pver uint32) error {
|
||||
return err
|
||||
}
|
||||
|
||||
f.Update = ChannelUpdate{}
|
||||
f.Update = ChannelUpdate1{}
|
||||
|
||||
return parseChannelUpdateCompatibilityMode(
|
||||
r, length, &f.Update, pver,
|
||||
@@ -1516,7 +1520,7 @@ func makeEmptyOnionError(code FailCode) (FailureMessage, error) {
|
||||
// writeOnionErrorChanUpdate writes out a ChannelUpdate using the onion error
|
||||
// format. The format is that we first write out the true serialized length of
|
||||
// the channel update, followed by the serialized channel update itself.
|
||||
func writeOnionErrorChanUpdate(w *bytes.Buffer, chanUpdate *ChannelUpdate,
|
||||
func writeOnionErrorChanUpdate(w *bytes.Buffer, chanUpdate *ChannelUpdate1,
|
||||
pver uint32) error {
|
||||
|
||||
// First, we encode the channel update in a temporary buffer in order
|
||||
|
||||
@@ -21,7 +21,7 @@ var (
|
||||
testType = uint64(3)
|
||||
testOffset = uint16(24)
|
||||
sig, _ = NewSigFromSignature(testSig)
|
||||
testChannelUpdate = ChannelUpdate{
|
||||
testChannelUpdate = ChannelUpdate1{
|
||||
Signature: sig,
|
||||
ShortChannelID: NewShortChanIDFromInt(1),
|
||||
Timestamp: 1,
|
||||
@@ -138,7 +138,7 @@ func TestChannelUpdateCompatibilityParsing(t *testing.T) {
|
||||
// Now that we have the set of bytes encoded, we'll ensure that we're
|
||||
// able to decode it using our compatibility method, as it's a regular
|
||||
// encoded channel update message.
|
||||
var newChanUpdate ChannelUpdate
|
||||
var newChanUpdate ChannelUpdate1
|
||||
err := parseChannelUpdateCompatibilityMode(
|
||||
&b, uint16(b.Len()), &newChanUpdate, 0,
|
||||
)
|
||||
@@ -165,7 +165,7 @@ func TestChannelUpdateCompatibilityParsing(t *testing.T) {
|
||||
|
||||
// We should be able to properly parse the encoded channel update
|
||||
// message even with the extra two bytes.
|
||||
var newChanUpdate2 ChannelUpdate
|
||||
var newChanUpdate2 ChannelUpdate1
|
||||
err = parseChannelUpdateCompatibilityMode(
|
||||
&b, uint16(b.Len()), &newChanUpdate2, 0,
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user