Module BSV::Wallet::Serializer::Common ¶
Shared binary encoding helpers for BRC-103 per-call serializers.
Port of the shared helpers in go-sdk/wallet/serializer/serializer.go. All methods operate on BSV::Wallet::Wire::Writer / Reader instances.
Constants¶
COUNTERPARTY_ANYONE ¶
0x0C
COUNTERPARTY_SELF ¶
0x0B
PUBKEY_SIZE ¶
compressed secp256k1 public key
SEND_WITH_CODE_STATUSES ¶
Not documented.
SEND_WITH_STATUS_CODES ¶
Not documented.
SEND_WITH_STATUS_FAILED ¶
Not documented.
SEND_WITH_STATUS_SENDING ¶
Not documented.
SEND_WITH_STATUS_UNPROVEN ¶
Send-with result status codes (Go status.go).
Public Class Methods¶
decode_outpoints(bytes) ¶
Decode a list of outpoints from binary (encoded as encode_outpoints). - @param bytes [String, nil] binary data - @return [Array
encode_outpoints(outpoints) ¶
Encode a list of outpoints (varint count + 32-byte wire-order txid + varint vout each). Returns nil bytes for nil input. - @param outpoints [Array
read_counterparty(reader) ¶
Not documented.
read_key_related_params(reader) ¶
Not documented.
read_privileged_params(reader) ¶
Not documented.
read_protocol(reader) ¶
Not documented.
read_send_with_results(reader) ¶
Read a send_with_results array. - @param reader [Wire::Reader] - @return [Array
to_binary(bytes) ¶
Coerce a byte payload to a binary String (ASCII-8BIT encoding).
Accepts either an Array
write_counterparty(writer, counterparty) ¶
Encode a counterparty: 'self' | 'anyone' | 66-char hex compressed pubkey.
Wire format: 0x0B — self 0x0C — anyone 02/03 <32 bytes> — specific pubkey (first byte is the prefix of the 33-byte key)
write_key_related_params(writer, protocol_id:, key_id:, counterparty:, privileged: = nil, privileged_reason: = nil) ¶
Encode key-related params: protocol + key_id + counterparty + privileged params.
write_privileged_params(writer, privileged, privileged_reason) ¶
Encode privileged flag + privileged_reason.
Wire format: optional_bool (0xFF=nil, 0x00=false, 0x01=true) + reason as varint-len string, or 0xFF if reason is nil/empty (NegativeOneByte sentinel).
write_protocol(writer, protocol_id) ¶
Encode a BRC-43 protocol ID: [security_level (0-2), protocol_name].
Wire format: 1-byte security level + varint-len string.
write_send_with_results(writer, results) ¶
Write a send_with_results array: varint count + txid (32 bytes) + status byte each. nil or empty → writes 0 count. - @param writer [Wire::Writer] - @param results [Array