Documentation
¶
Overview ¶
Package wire 是 Wire v1 的 exact Artifact 层与严格分派入口。每个完整报文 以 [protocol.WireVersion, kind] 开头:Parse 从外层头自读版本与 Kind,分派到 对应的严格 decoder,验证完整数组长度、canonical CBOR、attachment 分支与 trailing 字段;ParseAs 额外交叉验证传输路由声明的 Kind 与报文自描述 Kind。 本包复制 exact CBOR 字节,不添加 envelope、签名、存储、业务验证或网络行为; 签名、金额、身份与业务状态验证由角色 API 或领域包完成。
Index ¶
- Constants
- func DecodeArbitrationRequest(artifact Artifact) (*arbitration.ArbitrationRequest, error)
- func DecodeArbitrationResponse(artifact Artifact) (*arbitration.ArbitrationResponse, error)
- func DecodeContentDelivery(artifact Artifact) (*content.SignedContentDelivery, error)
- func DecodeContentRequest(artifact Artifact) (*content.SignedContentRequest, error)
- func DecodeContentRetrievalRequest(artifact Artifact) (*arbitration.ContentRetrievalRequest, error)
- func DecodeContentRetrievalResponse(artifact Artifact) (*arbitration.ContentRetrievalResponse, error)
- func DecodeFileQuote(artifact Artifact) (*content.SignedFileQuote, error)
- func DecodeFundingTransactionDelivery(artifact Artifact) (*pool.FundingTransactionDelivery, error)
- func DecodePaymentUpdate(artifact Artifact) (*pool.PaymentUpdate, error)
- func DecodeRefundPresignRequest(artifact Artifact) (*pool.RefundPresignRequest, error)
- func DecodeRefundPresignResponse(artifact Artifact) (*pool.RefundPresignResponse, error)
- type Artifact
- func EncodeArbitrationRequest(request *arbitration.ArbitrationRequest) (Artifact, error)
- func EncodeArbitrationResponse(response *arbitration.ArbitrationResponse) (Artifact, error)
- func EncodeContentDelivery(delivery *content.SignedContentDelivery) (Artifact, error)
- func EncodeContentRequest(request *content.SignedContentRequest) (Artifact, error)
- func EncodeContentRetrievalRequest(request *arbitration.ContentRetrievalRequest) (Artifact, error)
- func EncodeContentRetrievalResponse(response *arbitration.ContentRetrievalResponse) (Artifact, error)
- func EncodeFileQuote(quote *content.SignedFileQuote) (Artifact, error)
- func EncodeFundingTransactionDelivery(delivery *pool.FundingTransactionDelivery) (Artifact, error)
- func EncodePaymentUpdate(update *pool.PaymentUpdate) (Artifact, error)
- func EncodeRefundPresignRequest(request *pool.RefundPresignRequest) (Artifact, error)
- func EncodeRefundPresignResponse(response *pool.RefundPresignResponse) (Artifact, error)
- func Parse(raw []byte) (Artifact, error)
- func ParseAs(expected Kind, raw []byte) (Artifact, error)
- type Kind
Constants ¶
const ProtocolFamily = protocol.ProtocolFamily
ProtocolFamily 是外部协议族/manifest 标识字符串(wire 报文本身只携带 [WireVersion, kind, ...],不含族名称)。它是 protocol.ProtocolFamily 的 别名,仓库内不存在第二份版本字符串。
Variables ¶
This section is empty.
Functions ¶
func DecodeArbitrationRequest ¶
func DecodeArbitrationRequest(artifact Artifact) (*arbitration.ArbitrationRequest, error)
DecodeArbitrationRequest strictly decodes a Kind 8 Artifact.
func DecodeArbitrationResponse ¶
func DecodeArbitrationResponse(artifact Artifact) (*arbitration.ArbitrationResponse, error)
DecodeArbitrationResponse strictly decodes a Kind 9 Artifact.
func DecodeContentDelivery ¶
func DecodeContentDelivery(artifact Artifact) (*content.SignedContentDelivery, error)
DecodeContentDelivery strictly decodes a Kind 6 Artifact.
func DecodeContentRequest ¶
func DecodeContentRequest(artifact Artifact) (*content.SignedContentRequest, error)
DecodeContentRequest strictly decodes a Kind 5 Artifact.
func DecodeContentRetrievalRequest ¶
func DecodeContentRetrievalRequest(artifact Artifact) (*arbitration.ContentRetrievalRequest, error)
DecodeContentRetrievalRequest strictly decodes a Kind 10 Artifact.
func DecodeContentRetrievalResponse ¶
func DecodeContentRetrievalResponse(artifact Artifact) (*arbitration.ContentRetrievalResponse, error)
DecodeContentRetrievalResponse strictly decodes a Kind 11 Artifact.
func DecodeFileQuote ¶
func DecodeFileQuote(artifact Artifact) (*content.SignedFileQuote, error)
DecodeFileQuote strictly decodes a Kind 1 Artifact.
func DecodeFundingTransactionDelivery ¶
func DecodeFundingTransactionDelivery(artifact Artifact) (*pool.FundingTransactionDelivery, error)
DecodeFundingTransactionDelivery strictly decodes a Kind 4 Artifact.
func DecodePaymentUpdate ¶
func DecodePaymentUpdate(artifact Artifact) (*pool.PaymentUpdate, error)
DecodePaymentUpdate strictly decodes a Kind 7 Artifact.
func DecodeRefundPresignRequest ¶
func DecodeRefundPresignRequest(artifact Artifact) (*pool.RefundPresignRequest, error)
DecodeRefundPresignRequest strictly decodes a Kind 2 Artifact.
func DecodeRefundPresignResponse ¶
func DecodeRefundPresignResponse(artifact Artifact) (*pool.RefundPresignResponse, error)
DecodeRefundPresignResponse strictly decodes a Kind 3 Artifact.
Types ¶
type Artifact ¶
type Artifact struct {
// contains filtered or unexported fields
}
Artifact 是已通过严格解析的不可变 exact bytes:它证明 complete wire 的规范 结构(outer header、canonical CBOR、attachment 分支、trailing 字段全部 正确),不代表签名、金额、身份或业务状态已经验证。字段私有:构造只能经 Parse/ParseAs 或 typed encoder;Bytes() 返回副本,调用方无法修改内部字节, 输入 raw 的后续变异也不影响 Artifact。
func EncodeArbitrationRequest ¶
func EncodeArbitrationRequest(request *arbitration.ArbitrationRequest) (Artifact, error)
EncodeArbitrationRequest encodes the complete 007 evidence package into a Kind 8 Artifact.
func EncodeArbitrationResponse ¶
func EncodeArbitrationResponse(response *arbitration.ArbitrationResponse) (Artifact, error)
EncodeArbitrationResponse encodes the four-element receipt response into a Kind 9 Artifact.
func EncodeContentDelivery ¶
func EncodeContentDelivery(delivery *content.SignedContentDelivery) (Artifact, error)
EncodeContentDelivery encodes a signed delivery into a Kind 6 Artifact.
func EncodeContentRequest ¶
func EncodeContentRequest(request *content.SignedContentRequest) (Artifact, error)
EncodeContentRequest encodes a signed payment authorization into a Kind 5 Artifact.
func EncodeContentRetrievalRequest ¶
func EncodeContentRetrievalRequest(request *arbitration.ContentRetrievalRequest) (Artifact, error)
EncodeContentRetrievalRequest encodes a buyer retrieval request into a Kind 10 Artifact.
func EncodeContentRetrievalResponse ¶
func EncodeContentRetrievalResponse(response *arbitration.ContentRetrievalResponse) (Artifact, error)
EncodeContentRetrievalResponse encodes an arbiter-signed retrieval result into a Kind 11 Artifact.
func EncodeFileQuote ¶
func EncodeFileQuote(quote *content.SignedFileQuote) (Artifact, error)
EncodeFileQuote encodes a SignedFileQuote into a Kind 1 Artifact.
func EncodeFundingTransactionDelivery ¶
func EncodeFundingTransactionDelivery(delivery *pool.FundingTransactionDelivery) (Artifact, error)
EncodeFundingTransactionDelivery encodes the funding delivery into a Kind 4 Artifact.
func EncodePaymentUpdate ¶
func EncodePaymentUpdate(update *pool.PaymentUpdate) (Artifact, error)
EncodePaymentUpdate encodes a buyer payment credential into a Kind 7 Artifact.
func EncodeRefundPresignRequest ¶
func EncodeRefundPresignRequest(request *pool.RefundPresignRequest) (Artifact, error)
EncodeRefundPresignRequest encodes a pool-opening presign request into a Kind 2 Artifact.
func EncodeRefundPresignResponse ¶
func EncodeRefundPresignResponse(response *pool.RefundPresignResponse) (Artifact, error)
EncodeRefundPresignResponse encodes a presign response into a Kind 3 Artifact.
func Parse ¶
Parse 从 exact bytes 解析一个 Artifact:外层头自读 version/kind,显式 switch 分派到对应严格 decoder。未知版本/Kind 返回 unsupported 错误并保留原 bytes 供调用方升级或审计。
type Kind ¶
type Kind uint16
Kind identifies the message type selected by the transport. The outer pair [protocol.WireVersion, kind] opens every complete wire message; the strict decoder selected by Kind re-checks both values before interpreting any child document. Kind never identifies a pool instance: messages that define a RefundTemplateTxID carry it in their payload, while the presign request derives it from refund_template_raw.
const ( // FileQuote is a signed file quote. Direction: seller -> buyer. FileQuote Kind = 1 // RefundPresignRequest requests the seller's refund transaction signature. // Direction: buyer -> seller. RefundPresignRequest Kind = 2 // RefundPresignResponse carries the seller's refund transaction signature. // Direction: seller -> buyer. RefundPresignResponse Kind = 3 // FundingTransactionDelivery carries the signed funding transaction. // Direction: buyer -> seller. FundingTransactionDelivery Kind = 4 // ContentRequest carries the signed payment authorization. // Direction: buyer -> seller. ContentRequest Kind = 5 // ContentDelivery carries the signed content delivery and its payload // attachment. Direction: seller -> buyer. ContentDelivery Kind = 6 // PaymentUpdate carries a minimal cumulative payment credential: the // payment authorization ID plus the buyer transaction signature over the // locally rebuilt state transaction. The receiver routes it by the // authorization ID to the exact saved signed content request; no pool ID // or raw transaction travels on the wire. // Direction: buyer -> seller. PaymentUpdate Kind = 7 // ArbitrationRequest carries evidence for arbitration. // Direction: seller -> arbiter. ArbitrationRequest Kind = 8 // ArbitrationResponse carries the arbitration receipt and the arbiter's // unified signature over [1, 9, exact_receipt_cbor]; the receipt binds the // Claim ID, the positive arbiter amount, and the arbitration transaction // signature over the independently rebuilt candidate. // Direction: arbiter -> seller. ArbitrationResponse Kind = 9 // ContentRetrievalRequest carries a buyer's authenticated retrieval request // for one arbitrated custody record: // [1, 10, content_retrieval_request_cbor, buyer_signature]. The Claim ID // inside the signed document routes the lookup; only the buyer key // recovered from the stored Claim can authorize it. // Direction: buyer -> arbiter. ContentRetrievalRequest Kind = 10 // ContentRetrievalResponse returns one arbiter-signed retrieval result: // branch 0 answers unavailable with a structured reason and no attachment; // branch 1 binds the exact content_payloads_cbor through its // content_payloads_id and attaches the payloads verbatim. // Direction: arbiter -> buyer. ContentRetrievalResponse Kind = 11 )