Skip to content

Commit

Permalink
Add support for receiving sendaddrv2 message from peers (#554)
Browse files Browse the repository at this point in the history
  • Loading branch information
OPReturnCode authored Dec 19, 2024
1 parent 9283458 commit 98b8c45
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
4 changes: 4 additions & 0 deletions wire/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const (
CmdCmpctBlock = "cmpctblock"
CmdGetBlockTxns = "getblocktxn"
CmdBlockTxns = "blocktxn"
CmdSendAddrV2 = "sendaddrv2"
)

// MessageEncoding represents the wire message encoding format to be used.
Expand Down Expand Up @@ -114,6 +115,9 @@ func makeEmptyMessage(command string) (Message, error) {
case CmdVerAck:
msg = &MsgVerAck{}

case CmdSendAddrV2:
msg = &MsgSendAddrV2{}

case CmdXVerAck:
msg = &MsgXVerAck{}

Expand Down
45 changes: 45 additions & 0 deletions wire/msgsendaddrv2.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) 2013-2015 The btcsuite developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

package wire

import (
"io"
)

// MsgSendAddrV2 defines a bitcoin sendaddrv2 message which is used for a peer to
// signal support for receiving addrv2 messages (BIP155). It implements the Message interface.
//
// This message has no payload.
type MsgSendAddrV2 struct{}

// BchDecode decodes r using the bitcoin protocol encoding into the receiver.
// This is part of the Message interface implementation.
func (msg *MsgSendAddrV2) BchDecode(r io.Reader, pver uint32, enc MessageEncoding) error {
return nil
}

// BchEncode encodes the receiver to w using the bitcoin protocol encoding.
// This is part of the Message interface implementation.
func (msg *MsgSendAddrV2) BchEncode(w io.Writer, pver uint32, enc MessageEncoding) error {
return nil
}

// Command returns the protocol command string for the message. This is part
// of the Message interface implementation.
func (msg *MsgSendAddrV2) Command() string {
return CmdSendAddrV2
}

// MaxPayloadLength returns the maximum length the payload can be for the
// receiver. This is part of the Message interface implementation.
func (msg *MsgSendAddrV2) MaxPayloadLength(pver uint32) uint32 {
return 0
}

// NewMsgSendAddrV2 returns a new bitcoin sendaddrv2 message that conforms to the
// Message interface.
func NewMsgSendAddrV2() *MsgSendAddrV2 {
return &MsgSendAddrV2{}
}

0 comments on commit 98b8c45

Please sign in to comment.