btclib_node.p2p.messages package¶
Submodules¶
btclib_node.p2p.messages.errors module¶
Reject, BIP61’s message, and the codes it carries.
p2p.callbacks.reject is the only handler that reads one, logging what a peer sent; this node never constructs or sends one of its own.
Every way parse below refuses a payload is a BTClibException, which is what handle_p2p (p2p/main.py) sorts a peer’s fault from this node’s by: btclib.var_int.parse’s own refusal of a length prefix, and InvalidRejectPayloadError for everything this module decides itself.
- class btclib_node.p2p.messages.errors.Reject(message: str, code: RejectCode, reason: str, data: bytes)[source]¶
Bases:
PayloadBIP61’s reject message: what a peer refused, and why.
The module docstring above is where its one reader is named.
- classmethod parse(data: BinaryData, *, check_validity: bool = True) Reject[source]¶
Parse a Reject from the bytes a peer sent.
Accepts exactly what serialize below writes, so a payload holding anything else – a field cut short, a trailing octet past the hash – is refused rather than parsed into an object that reserializes to something the peer did not send.
Module contents¶
The p2p payloads this node carries itself.
Most of what this node speaks is btclib.p2p’s, imported where it is used. What is here is the remainder: BIP61’s reject, a command Bitcoin Core’s NetMsgType does not name and btclib.p2p holds no codec for.
Reject subclasses btclib.p2p.payload.Payload and owns the command its octets travel under, so the name it serializes under and the name p2p.callbacks dispatches on are one constant. The four header fields are btclib.p2p.message.Message’s, and p2p.connection.Connection is the single place that puts them on and takes them off.