1 package wire
2 3 import (
4 "fmt"
5 "io"
6 )
7 8 // MsgSendAddrV2 defines a bitcoin sendaddrv2 message which is used for a peer
9 // to signal support for receiving ADDRV2 messages (BIP155). It implements the
10 // Message interface.
11 //
12 // This message has no payload.
13 type MsgSendAddrV2 struct{}
14 15 // BtcDecode decodes r using the bitcoin protocol encoding into the receiver.
16 // This is part of the Message interface implementation.
17 func (msg *MsgSendAddrV2) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error {
18 if pver < AddrV2Version {
19 str := fmt.Sprintf("sendaddrv2 message invalid for protocol "+
20 "version %d", pver)
21 return messageError("MsgSendAddrV2.BtcDecode", str)
22 }
23 24 return nil
25 }
26 27 // BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
28 // This is part of the Message interface implementation.
29 func (msg *MsgSendAddrV2) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error {
30 if pver < AddrV2Version {
31 str := fmt.Sprintf("sendaddrv2 message invalid for protocol "+
32 "version %d", pver)
33 return messageError("MsgSendAddrV2.BtcEncode", str)
34 }
35 36 return nil
37 }
38 39 // Command returns the protocol command string for the message. This is part
40 // of the Message interface implementation.
41 func (msg *MsgSendAddrV2) Command() string {
42 return CmdSendAddrV2
43 }
44 45 // MaxPayloadLength returns the maximum length the payload can be for the
46 // receiver. This is part of the Message interface implementation.
47 func (msg *MsgSendAddrV2) MaxPayloadLength(pver uint32) uint32 {
48 return 0
49 }
50 51 // NewMsgSendAddrV2 returns a new bitcoin sendaddrv2 message that conforms to the
52 // Message interface.
53 func NewMsgSendAddrV2() *MsgSendAddrV2 {
54 return &MsgSendAddrV2{}
55 }
56