1 // Copyright (c) 2024 The btcsuite developers
2 // Use of this source code is governed by an ISC
3 // license that can be found in the LICENSE file.
4 5 package wire
6 7 import (
8 "fmt"
9 "io"
10 )
11 12 // MsgWTxIdRelay defines a bitcoin wtxidrelay message which is used for a peer
13 // to signal support for relaying witness transaction id (BIP141). It
14 // implements the Message interface.
15 //
16 // This message has no payload.
17 type MsgWTxIdRelay struct{}
18 19 // BtcDecode decodes r using the bitcoin protocol encoding into the receiver.
20 // This is part of the Message interface implementation.
21 func (msg *MsgWTxIdRelay) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error {
22 if pver < AddrV2Version {
23 str := fmt.Sprintf("wtxidrelay message invalid for protocol "+
24 "version %d", pver)
25 return messageError("MsgWTxIdRelay.BtcDecode", str)
26 }
27 28 return nil
29 }
30 31 // BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
32 // This is part of the Message interface implementation.
33 func (msg *MsgWTxIdRelay) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error {
34 if pver < AddrV2Version {
35 str := fmt.Sprintf("wtxidrelay message invalid for protocol "+
36 "version %d", pver)
37 return messageError("MsgWTxIdRelay.BtcEncode", str)
38 }
39 40 return nil
41 }
42 43 // Command returns the protocol command string for the message. This is part
44 // of the Message interface implementation.
45 func (msg *MsgWTxIdRelay) Command() string {
46 return CmdWTxIdRelay
47 }
48 49 // MaxPayloadLength returns the maximum length the payload can be for the
50 // receiver. This is part of the Message interface implementation.
51 func (msg *MsgWTxIdRelay) MaxPayloadLength(pver uint32) uint32 {
52 return 0
53 }
54 55 // NewMsgWTxIdRelay returns a new bitcoin wtxidrelay message that conforms
56 // to the Message interface.
57 func NewMsgWTxIdRelay() *MsgWTxIdRelay {
58 return &MsgWTxIdRelay{}
59 }
60