wire

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

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

View Source
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

func Parse(raw []byte) (Artifact, error)

Parse 从 exact bytes 解析一个 Artifact:外层头自读 version/kind,显式 switch 分派到对应严格 decoder。未知版本/Kind 返回 unsupported 错误并保留原 bytes 供调用方升级或审计。

func ParseAs

func ParseAs(expected Kind, raw []byte) (Artifact, error)

ParseAs 在 Parse 的基础上额外验证传输路由声明的 Kind 与报文自描述 Kind 一致; 路由声明可以用于分发,但不能成为唯一 Kind 真值。

func (Artifact) Bytes

func (a Artifact) Bytes() []byte

Bytes 返回 exact CBOR 字节的副本;调用方修改副本不会影响本 Artifact。

func (Artifact) IsZero

func (a Artifact) IsZero() bool

IsZero 报告该 Artifact 是否为空值(未经过 Parse 或编码失败后的零值)。

func (Artifact) Kind

func (a Artifact) Kind() Kind

Kind 返回报文自描述的 Kind(从 outer header 派生)。

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
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL