lnwire: remove the Validate method from the Message interface
This commit revues the Validate method from the Message interface as the method is no longer used and is a relic from an older version of the codebase.
This commit is contained in:
parent
920fcf3392
commit
c8d978261b
@ -40,14 +40,6 @@ type AnnounceSignatures struct {
|
|||||||
// lnwire.Message interface.
|
// lnwire.Message interface.
|
||||||
var _ Message = (*AnnounceSignatures)(nil)
|
var _ Message = (*AnnounceSignatures)(nil)
|
||||||
|
|
||||||
// Validate performs any necessary sanity checks to ensure all fields present
|
|
||||||
// on the AnnounceSignatures are valid.
|
|
||||||
//
|
|
||||||
// This is part of the lnwire.Message interface.
|
|
||||||
func (a *AnnounceSignatures) Validate() error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode deserializes a serialized AnnounceSignatures stored in the passed
|
// Decode deserializes a serialized AnnounceSignatures stored in the passed
|
||||||
// io.Reader observing the specified protocol version.
|
// io.Reader observing the specified protocol version.
|
||||||
//
|
//
|
||||||
|
@ -43,14 +43,6 @@ type ChannelAnnouncement struct {
|
|||||||
// lnwire.Message interface.
|
// lnwire.Message interface.
|
||||||
var _ Message = (*ChannelAnnouncement)(nil)
|
var _ Message = (*ChannelAnnouncement)(nil)
|
||||||
|
|
||||||
// Validate performs any necessary sanity checks to ensure all fields present
|
|
||||||
// on the ChannelAnnouncement are valid.
|
|
||||||
//
|
|
||||||
// This is part of the lnwire.Message interface.
|
|
||||||
func (a *ChannelAnnouncement) Validate() error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode deserializes a serialized ChannelAnnouncement stored in the passed
|
// Decode deserializes a serialized ChannelAnnouncement stored in the passed
|
||||||
// io.Reader observing the specified protocol version.
|
// io.Reader observing the specified protocol version.
|
||||||
//
|
//
|
||||||
|
@ -2,7 +2,6 @@ package lnwire
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/roasbeef/btcd/btcec"
|
"github.com/roasbeef/btcd/btcec"
|
||||||
@ -51,22 +50,6 @@ type ChannelUpdate struct {
|
|||||||
// interface.
|
// interface.
|
||||||
var _ Message = (*ChannelUpdate)(nil)
|
var _ Message = (*ChannelUpdate)(nil)
|
||||||
|
|
||||||
// Validate performs any necessary sanity checks to ensure all fields present
|
|
||||||
// on the ChannelUpdate are valid.
|
|
||||||
//
|
|
||||||
// This is part of the lnwire.Message interface.
|
|
||||||
func (a *ChannelUpdate) Validate() error {
|
|
||||||
// NOTE: As far as we don't have the node id (public key) in this
|
|
||||||
// message, we can't validate the signature on this stage, it should
|
|
||||||
// be validated latter - in discovery service handler.
|
|
||||||
|
|
||||||
if a.TimeLockDelta == 0 {
|
|
||||||
return errors.New("expiry should be greater then zero")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode deserializes a serialized ChannelUpdate stored in the passed
|
// Decode deserializes a serialized ChannelUpdate stored in the passed
|
||||||
// io.Reader observing the specified protocol version.
|
// io.Reader observing the specified protocol version.
|
||||||
//
|
//
|
||||||
|
@ -76,12 +76,3 @@ func (c *CloseComplete) MaxPayloadLength(uint32) uint32 {
|
|||||||
// 141 + 73 + 32
|
// 141 + 73 + 32
|
||||||
return 141
|
return 141
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate performs any necessary sanity checks to ensure all fields present
|
|
||||||
// on the CloseComplete are valid.
|
|
||||||
//
|
|
||||||
// This is part of the lnwire.Message interface.
|
|
||||||
func (c *CloseComplete) Validate() error {
|
|
||||||
// We're good!
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
@ -85,17 +85,3 @@ func (c *CloseRequest) MaxPayloadLength(pver uint32) uint32 {
|
|||||||
// 36 + 73 + 8
|
// 36 + 73 + 8
|
||||||
return 117
|
return 117
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate performs any necessary sanity checks to ensure all fields present
|
|
||||||
// on the CloseRequest are valid.
|
|
||||||
//
|
|
||||||
// This is part of the lnwire.Message interface.
|
|
||||||
func (c *CloseRequest) Validate() error {
|
|
||||||
// Fee must be greater than 0.
|
|
||||||
if c.Fee < 0 {
|
|
||||||
return fmt.Errorf("fee must be greater than zero")
|
|
||||||
}
|
|
||||||
|
|
||||||
// We're good!
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
@ -76,12 +76,3 @@ func (c *CommitSig) MaxPayloadLength(uint32) uint32 {
|
|||||||
// 32 + 64
|
// 32 + 64
|
||||||
return 96
|
return 96
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate performs any necessary sanity checks to ensure all fields present
|
|
||||||
// on the CommitSig are valid.
|
|
||||||
//
|
|
||||||
// This is part of the lnwire.Message interface.
|
|
||||||
func (c *CommitSig) Validate() error {
|
|
||||||
// We're good!
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
@ -108,16 +108,3 @@ func (c *Error) MaxPayloadLength(uint32) uint32 {
|
|||||||
// 32 + 2 + 655326
|
// 32 + 2 + 655326
|
||||||
return 65536
|
return 65536
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate performs any necessary sanity checks to ensure all fields present
|
|
||||||
// on the Error are valid.
|
|
||||||
//
|
|
||||||
// This is part of the lnwire.Message interface.
|
|
||||||
func (c *Error) Validate() error {
|
|
||||||
if len(c.Data) > math.MaxUint16 {
|
|
||||||
return fmt.Errorf("problem string length too long")
|
|
||||||
}
|
|
||||||
|
|
||||||
// We're good!
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
@ -82,17 +82,3 @@ func (c *FundingLocked) MaxPayloadLength(uint32) uint32 {
|
|||||||
// 65 bytes
|
// 65 bytes
|
||||||
return length
|
return length
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate examines each populated field within the FundingLocked message for
|
|
||||||
// field sanity. For example, signature fields MUST NOT be nil.
|
|
||||||
//
|
|
||||||
// This is part of the lnwire.Message interface.
|
|
||||||
func (c *FundingLocked) Validate() error {
|
|
||||||
if c.NextPerCommitmentPoint == nil {
|
|
||||||
return fmt.Errorf("the next per commitment point must be " +
|
|
||||||
"non-nil.")
|
|
||||||
}
|
|
||||||
|
|
||||||
// We're good!
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
@ -70,21 +70,3 @@ func (msg *Init) Command() uint32 {
|
|||||||
func (msg *Init) MaxPayloadLength(uint32) uint32 {
|
func (msg *Init) MaxPayloadLength(uint32) uint32 {
|
||||||
return 2 + maxAllowedSize + 2 + maxAllowedSize
|
return 2 + maxAllowedSize + 2 + maxAllowedSize
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate performs any necessary sanity checks to ensure all fields present
|
|
||||||
// on the Init are valid.
|
|
||||||
//
|
|
||||||
// This is part of the lnwire.Message interface.
|
|
||||||
func (msg *Init) Validate() error {
|
|
||||||
if msg.GlobalFeatures.serializedSize() > maxAllowedSize {
|
|
||||||
return errors.Errorf("global feature vector exceed max allowed "+
|
|
||||||
"size %v", maxAllowedSize)
|
|
||||||
}
|
|
||||||
|
|
||||||
if msg.LocalFeatures.serializedSize() > maxAllowedSize {
|
|
||||||
return errors.Errorf("local feature vector exceed max allowed "+
|
|
||||||
"size %v", maxAllowedSize)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
@ -84,7 +84,6 @@ type Message interface {
|
|||||||
Encode(io.Writer, uint32) error
|
Encode(io.Writer, uint32) error
|
||||||
Command() uint32
|
Command() uint32
|
||||||
MaxPayloadLength(uint32) uint32
|
MaxPayloadLength(uint32) uint32
|
||||||
Validate() error
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeEmptyMessage creates a new empty message of the proper concrete type
|
// makeEmptyMessage creates a new empty message of the proper concrete type
|
||||||
|
@ -109,15 +109,6 @@ type NodeAnnouncement struct {
|
|||||||
// lnwire.Message interface.
|
// lnwire.Message interface.
|
||||||
var _ Message = (*NodeAnnouncement)(nil)
|
var _ Message = (*NodeAnnouncement)(nil)
|
||||||
|
|
||||||
// Validate performs any necessary sanity checks to ensure all fields present
|
|
||||||
// on the NodeAnnouncement are valid.
|
|
||||||
//
|
|
||||||
// This is part of the lnwire.Message interface.
|
|
||||||
func (a *NodeAnnouncement) Validate() error {
|
|
||||||
// TODO(roasbeef): move validation to discovery service
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode deserializes a serialized NodeAnnouncement stored in the passed
|
// Decode deserializes a serialized NodeAnnouncement stored in the passed
|
||||||
// io.Reader observing the specified protocol version.
|
// io.Reader observing the specified protocol version.
|
||||||
//
|
//
|
||||||
|
@ -65,11 +65,3 @@ func (p *Ping) Command() uint32 {
|
|||||||
func (p Ping) MaxPayloadLength(uint32) uint32 {
|
func (p Ping) MaxPayloadLength(uint32) uint32 {
|
||||||
return 65532
|
return 65532
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate performs any necessary sanity checks to ensure all fields present
|
|
||||||
// on the Ping are valid.
|
|
||||||
//
|
|
||||||
// This is part of the lnwire.Message interface.
|
|
||||||
func (p *Ping) Validate() error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
@ -61,11 +61,3 @@ func (p *Pong) Command() uint32 {
|
|||||||
func (p *Pong) MaxPayloadLength(uint32) uint32 {
|
func (p *Pong) MaxPayloadLength(uint32) uint32 {
|
||||||
return 65532
|
return 65532
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate performs any necessary sanity checks to ensure all fields present
|
|
||||||
// on the Pong are valid.
|
|
||||||
//
|
|
||||||
// This is part of the lnwire.Message interface.
|
|
||||||
func (p *Pong) Validate() error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
@ -94,12 +94,3 @@ func (c *RevokeAndAck) MaxPayloadLength(uint32) uint32 {
|
|||||||
// 32 + 32 + 33 + 32
|
// 32 + 32 + 33 + 32
|
||||||
return 129
|
return 129
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate performs any necessary sanity checks to ensure all fields present
|
|
||||||
// on the RevokeAndAck are valid.
|
|
||||||
//
|
|
||||||
// This is part of the lnwire.Message interface.
|
|
||||||
func (c *RevokeAndAck) Validate() error {
|
|
||||||
// We're good!
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
@ -103,23 +103,3 @@ func (s *SingleFundingComplete) MaxPayloadLength(uint32) uint32 {
|
|||||||
// 32 + 36 + 64 + 33 + 6
|
// 32 + 36 + 64 + 33 + 6
|
||||||
return 171
|
return 171
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate examines each populated field within the SingleFundingComplete for
|
|
||||||
// field sanity.
|
|
||||||
//
|
|
||||||
// This is part of the lnwire.Message interface.
|
|
||||||
func (s *SingleFundingComplete) Validate() error {
|
|
||||||
var zeroHash [32]byte
|
|
||||||
if bytes.Equal(zeroHash[:], s.FundingOutPoint.Hash[:]) {
|
|
||||||
return fmt.Errorf("funding outpoint hash must be non-zero")
|
|
||||||
}
|
|
||||||
|
|
||||||
if s.CommitSignature == nil {
|
|
||||||
return fmt.Errorf("commitment signature must be non-nil")
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(roasbeef): fin validation
|
|
||||||
|
|
||||||
// We're good!
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
@ -203,43 +203,3 @@ func (c *SingleFundingRequest) MaxPayloadLength(uint32) uint32 {
|
|||||||
|
|
||||||
return length
|
return length
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate examines each populated field within the SingleFundingRequest for
|
|
||||||
// field sanity. For example, all fields MUST NOT be negative, and all pkScripts
|
|
||||||
// must belong to the allowed set of public key scripts.
|
|
||||||
//
|
|
||||||
// This is part of the lnwire.Message interface.
|
|
||||||
func (c *SingleFundingRequest) Validate() error {
|
|
||||||
// Negative values is are allowed.
|
|
||||||
if c.FeePerKb < 0 {
|
|
||||||
return fmt.Errorf("'MinFeePerKb' cannot be negative")
|
|
||||||
}
|
|
||||||
if c.FundingAmount < 0 {
|
|
||||||
return fmt.Errorf("'FundingAmount' cannot be negative")
|
|
||||||
}
|
|
||||||
|
|
||||||
// The CSV delay MUST be non-zero.
|
|
||||||
if c.CsvDelay == 0 {
|
|
||||||
return fmt.Errorf("commitment transaction must have non-zero" +
|
|
||||||
" CSV delay")
|
|
||||||
}
|
|
||||||
|
|
||||||
// The delivery pkScript must be amongst the supported script
|
|
||||||
// templates.
|
|
||||||
if !isValidPkScript(c.DeliveryPkScript) {
|
|
||||||
// TODO(roasbeef): move into actual error
|
|
||||||
return fmt.Errorf("valid delivery public key scripts MUST " +
|
|
||||||
"be: P2PKH, P2WKH, P2SH, or P2WSH")
|
|
||||||
}
|
|
||||||
|
|
||||||
if c.DustLimit <= 0 {
|
|
||||||
return fmt.Errorf("DustLimit' should be greater than zero")
|
|
||||||
}
|
|
||||||
|
|
||||||
if c.ConfirmationDepth == 0 {
|
|
||||||
return fmt.Errorf("ConfirmationDepth must be non-zero")
|
|
||||||
}
|
|
||||||
|
|
||||||
// We're good!
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
@ -157,35 +157,3 @@ func (c *SingleFundingResponse) MaxPayloadLength(uint32) uint32 {
|
|||||||
|
|
||||||
return length
|
return length
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate examines each populated field within the SingleFundingResponse for
|
|
||||||
// field sanity. For example, all fields MUST NOT be negative, and all pkScripts
|
|
||||||
// must belong to the allowed set of public key scripts.
|
|
||||||
//
|
|
||||||
// This is part of the lnwire.Message interface.
|
|
||||||
func (c *SingleFundingResponse) Validate() error {
|
|
||||||
// The channel derivation point must be non-nil, and have an odd
|
|
||||||
// y-coordinate.
|
|
||||||
if c.ChannelDerivationPoint == nil {
|
|
||||||
return fmt.Errorf("The channel derivation point must be non-nil")
|
|
||||||
}
|
|
||||||
|
|
||||||
// The delivery pkScript must be amongst the supported script
|
|
||||||
// templates.
|
|
||||||
if !isValidPkScript(c.DeliveryPkScript) {
|
|
||||||
return fmt.Errorf("Valid delivery public key scripts MUST be: " +
|
|
||||||
"P2PKH, P2WKH, P2SH, or P2WSH.")
|
|
||||||
}
|
|
||||||
|
|
||||||
if c.DustLimit <= 0 {
|
|
||||||
return fmt.Errorf("Dust limit shouldn't be below or equal to " +
|
|
||||||
"zero.")
|
|
||||||
}
|
|
||||||
|
|
||||||
if c.ConfirmationDepth == 0 {
|
|
||||||
return fmt.Errorf("ConfirmationDepth must be non-zero")
|
|
||||||
}
|
|
||||||
|
|
||||||
// We're good!
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
@ -71,16 +71,3 @@ func (c *SingleFundingSignComplete) MaxPayloadLength(uint32) uint32 {
|
|||||||
// 32 + 64
|
// 32 + 64
|
||||||
return 96
|
return 96
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate examines each populated field within the SingleFundingSignComplete
|
|
||||||
// for field sanity.
|
|
||||||
//
|
|
||||||
// This is part of the lnwire.Message interface.
|
|
||||||
func (c *SingleFundingSignComplete) Validate() error {
|
|
||||||
if c.CommitSignature == nil {
|
|
||||||
return fmt.Errorf("commitment signature must be non-nil")
|
|
||||||
}
|
|
||||||
|
|
||||||
// We're good!
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
@ -110,18 +110,3 @@ func (c *UpdateAddHTLC) MaxPayloadLength(uint32) uint32 {
|
|||||||
// 1338
|
// 1338
|
||||||
return 32 + 8 + 4 + 8 + 32 + 1254
|
return 32 + 8 + 4 + 8 + 32 + 1254
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate performs any necessary sanity checks to ensure all fields present
|
|
||||||
// on the UpdateAddHTLC are valid.
|
|
||||||
//
|
|
||||||
// This is part of the lnwire.Message interface.
|
|
||||||
func (c *UpdateAddHTLC) Validate() error {
|
|
||||||
if c.Amount < 0 {
|
|
||||||
// While fees can be negative, it's too confusing to allow
|
|
||||||
// negative payments. Maybe for some wallets, but not this one!
|
|
||||||
return fmt.Errorf("amount paid cannot be negative")
|
|
||||||
}
|
|
||||||
|
|
||||||
// We're good!
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
@ -136,12 +136,3 @@ func (c *UpdateFailHTLC) MaxPayloadLength(uint32) uint32 {
|
|||||||
// 32 + 8 + 154
|
// 32 + 8 + 154
|
||||||
return 194
|
return 194
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate performs any necessary sanity checks to ensure all fields present
|
|
||||||
// on the UpdateFailHTLC are valid.
|
|
||||||
//
|
|
||||||
// This is part of the lnwire.Message interface.
|
|
||||||
func (c *UpdateFailHTLC) Validate() error {
|
|
||||||
// We're good!
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
@ -76,12 +76,3 @@ func (c *UpdateFufillHTLC) MaxPayloadLength(uint32) uint32 {
|
|||||||
// 32 + 8 + 32
|
// 32 + 8 + 32
|
||||||
return 72
|
return 72
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate performs any necessary sanity checks to ensure all fields present
|
|
||||||
// on the UpdateFufillHTLC are valid.
|
|
||||||
//
|
|
||||||
// This is part of the lnwire.Message interface.
|
|
||||||
func (c *UpdateFufillHTLC) Validate() error {
|
|
||||||
// We're good!
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user