wire
import "github.com/bsv8/go-bitfs/wire"
wire 包将传输层消息类型映射到 001–007 的规范编码器和严格解码器。它只复制精确的 CBOR 字节,不添加信封、签名、存储、业务验证或网络行为;调用方解码后必须调用所属 bitfs、pool 或 arbitration 包的验证器。
索引
- 常量
- 函数 MarshalArbitrationRequest(message *arbitration.ArbitrationRequest) ([]byte, error)
- 函数 MarshalArbitrationResponse(message *arbitration.ArbitrationResponse) ([]byte, error)
- 函数 MarshalContentDelivery(message *bitfs.SignedContentDelivery) ([]byte, error)
- 函数 MarshalContentRequest(message *bitfs.SignedContentRequest) ([]byte, error)
- 函数 MarshalPaymentUpdate(message *pool.PaymentUpdate) ([]byte, error)
- 函数 MarshalPoolFundingTxDelivery(message *pool.FundingTxDelivery) ([]byte, error)
- 函数 MarshalPoolRefundPresignRequest(message *pool.RefundPresignRequest) ([]byte, error)
- 函数 MarshalPoolRefundPresignResponse(message *pool.RefundPresignResponse) ([]byte, error)
- 函数 MarshalQuote(message *bitfs.SignedFileQuote) ([]byte, error)
- 函数 Unmarshal(kind Kind, rawCBOR []byte) (any, error)
- 函数 UnmarshalArbitrationRequest(rawCBOR []byte) (*arbitration.ArbitrationRequest, error)
- 函数 UnmarshalArbitrationResponse(rawCBOR []byte) (*arbitration.ArbitrationResponse, error)
- 函数 UnmarshalContentDelivery(rawCBOR []byte) (*bitfs.SignedContentDelivery, error)
- 函数 UnmarshalContentRequest(rawCBOR []byte) (*bitfs.SignedContentRequest, error)
- 函数 UnmarshalPaymentUpdate(rawCBOR []byte) (*pool.PaymentUpdate, error)
- 函数 UnmarshalPoolFundingTxDelivery(rawCBOR []byte) (*pool.FundingTxDelivery, error)
- 函数 UnmarshalPoolRefundPresignRequest(rawCBOR []byte) (*pool.RefundPresignRequest, error)
- 函数 UnmarshalPoolRefundPresignResponse(rawCBOR []byte) (*pool.RefundPresignResponse, error)
- 函数 UnmarshalQuote(rawCBOR []byte) (*bitfs.SignedFileQuote, error)
- 类型 Kind
- 类型 Packet
常量
ProtocolFamily 是由传输层携带的 wire 协议标识符。
const ProtocolFamily = "bitfs.protocol.v3"
函数 MarshalArbitrationRequest
func MarshalArbitrationRequest(message *arbitration.ArbitrationRequest) ([]byte, error)
MarshalArbitrationRequest 编码卖方完整的 007 证据包。
函数 MarshalArbitrationResponse
func MarshalArbitrationResponse(message *arbitration.ArbitrationResponse) ([]byte, error)
MarshalArbitrationResponse 编码仲裁人返回的哈希和分离签名。
函数 MarshalContentDelivery
func MarshalContentDelivery(message *bitfs.SignedContentDelivery) ([]byte, error)
MarshalContentDelivery 使用 bitfs 的规范编码器编码 SignedContentDelivery。
函数 MarshalContentRequest
func MarshalContentRequest(message *bitfs.SignedContentRequest) ([]byte, error)
MarshalContentRequest 使用 bitfs 的规范编码器编码 SignedContentRequest。
函数 MarshalPaymentUpdate
func MarshalPaymentUpdate(message *pool.PaymentUpdate) ([]byte, error)
MarshalPaymentUpdate 编码买方授权的累计支付更新。
函数 MarshalPoolFundingTxDelivery
func MarshalPoolFundingTxDelivery(message *pool.FundingTxDelivery) ([]byte, error)
MarshalPoolFundingTxDelivery 编码费用池注资交易的交付。
函数 MarshalPoolRefundPresignRequest
func MarshalPoolRefundPresignRequest(message *pool.RefundPresignRequest) ([]byte, error)
MarshalPoolRefundPresignRequest 编码费用池开池预签名请求。
函数 MarshalPoolRefundPresignResponse
func MarshalPoolRefundPresignResponse(message *pool.RefundPresignResponse) ([]byte, error)
MarshalPoolRefundPresignResponse 编码费用池开池预签名响应。
函数 MarshalQuote
func MarshalQuote(message *bitfs.SignedFileQuote) ([]byte, error)
MarshalQuote 使用 bitfs 的规范编码器编码 SignedFileQuote。
函数 Unmarshal
func Unmarshal(kind Kind, rawCBOR []byte) (any, error)
Unmarshal 将 rawCBOR 分派给 kind 选定的严格解码器。它检查规范编码和结构;调用方仍必须运行所属包的验证器。
函数 UnmarshalArbitrationRequest
func UnmarshalArbitrationRequest(rawCBOR []byte) (*arbitration.ArbitrationRequest, error)
UnmarshalArbitrationRequest 严格解码 007 证据包。
函数 UnmarshalArbitrationResponse
func UnmarshalArbitrationResponse(rawCBOR []byte) (*arbitration.ArbitrationResponse, error)
UnmarshalArbitrationResponse 严格解码仲裁人响应。
函数 UnmarshalContentDelivery
func UnmarshalContentDelivery(rawCBOR []byte) (*bitfs.SignedContentDelivery, error)
UnmarshalContentDelivery 严格解码 SignedContentDelivery。
函数 UnmarshalContentRequest
func UnmarshalContentRequest(rawCBOR []byte) (*bitfs.SignedContentRequest, error)
UnmarshalContentRequest 严格解码 SignedContentRequest。
函数 UnmarshalPaymentUpdate
func UnmarshalPaymentUpdate(rawCBOR []byte) (*pool.PaymentUpdate, error)
UnmarshalPaymentUpdate 严格解码累计支付更新。
函数 UnmarshalPoolFundingTxDelivery
func UnmarshalPoolFundingTxDelivery(rawCBOR []byte) (*pool.FundingTxDelivery, error)
UnmarshalPoolFundingTxDelivery 严格解码费用池注资交易的交付。
函数 UnmarshalPoolRefundPresignRequest
func UnmarshalPoolRefundPresignRequest(rawCBOR []byte) (*pool.RefundPresignRequest, error)
UnmarshalPoolRefundPresignRequest 严格解码费用池开池预签名请求。
函数 UnmarshalPoolRefundPresignResponse
func UnmarshalPoolRefundPresignResponse(rawCBOR []byte) (*pool.RefundPresignResponse, error)
UnmarshalPoolRefundPresignResponse 严格解码费用池开池预签名响应。
函数 UnmarshalQuote
func UnmarshalQuote(rawCBOR []byte) (*bitfs.SignedFileQuote, error)
UnmarshalQuote 严格解码 SignedFileQuote。
类型 Kind
Kind 标识传输层选定的消息类型。该标签不会插入已签名的 001–007 CBOR 文档。
type Kind uint16
const (
// Quote identifies a signed file quote message.
Quote Kind = 1
// PoolRefundPresignRequest identifies a pool opening request.
PoolRefundPresignRequest Kind = 2
// PoolRefundPresignResponse identifies a pool opening response.
PoolRefundPresignResponse Kind = 3
// PoolFundingTxDelivery identifies delivery of the pool funding transaction.
PoolFundingTxDelivery Kind = 4
// ContentRequest identifies a buyer's signed content request.
ContentRequest Kind = 5
// ContentDelivery identifies a seller's signed content delivery.
ContentDelivery Kind = 6
// CumulativePayment identifies a buyer-authorized payment update.
CumulativePayment Kind = 7
// ArbitrationRequest identifies evidence sent from a seller to an arbiter.
ArbitrationRequest Kind = 8
// ArbitrationResponse identifies the arbiter signature returned to a seller.
ArbitrationResponse Kind = 9
)
类型 Packet
Packet 携带传输层选定的 Kind 以及相应协议编码器生成的精确规范 CBOR 字节。它不添加任何信封。
type Packet struct {
Kind Kind
CBOR []byte
}
函数 Marshal
func Marshal(kind Kind, message any) (Packet, error)
Marshal 根据 kind 分派到规范编码器,拒绝类型不匹配的 Go 值,并在不改变签名字节的情况下返回可传输的 CBOR。
由 gomarkdoc 生成