跳到主要内容

arbitration

import "github.com/bsv8/go-bitfs/arbitration"

arbitration 包实现 BitFS v3 的卖方仲裁签名工作流。它验证买方授权和卖方候选交易,然后只添加仲裁人签名。它不负责定价、构造交易或接收 005 买方签名。

索引

常量

MajorVersion 是当前费用池工作流协议的主版本号。

const MajorVersion uint64 = 3

函数 MarshalRequest

func MarshalRequest(request *ArbitrationRequest) ([]byte, error)

MarshalRequest 验证并编码包含五个字段的 007 仲裁请求。

函数 MarshalResponse

func MarshalResponse(response *ArbitrationResponse) ([]byte, error)

MarshalResponse 验证并编码包含四个字段的 007 仲裁响应。

函数 ValidateRequest

func ValidateRequest(request *ArbitrationRequest) error

ValidateRequest 在解码证据前检查 007 版本、必需的 CBOR/交易字节字段、SHA-256 哈希长度以及卖方分离签名。

函数 ValidateResponse

func ValidateResponse(response *ArbitrationResponse) error

ValidateResponse 在调用方接受响应前检查 007 响应版本、授权/状态哈希以及仲裁人分离签名的长度。

类型 ArbitrationRequest

ArbitrationRequest 是完整的 v3 线协议请求。所有交易字节都是未签名模板字节;卖方签名被有意单独传输。

type ArbitrationRequest struct {
Version uint64
PoolOpeningProofCBOR []byte
PaymentAuthorizationCBOR []byte
UnsignedStateTxRaw []byte
SellerTransactionSignature []byte
}

函数 UnmarshalRequest

func UnmarshalRequest(data []byte) (*ArbitrationRequest, error)

UnmarshalRequest 严格解码并规范化 007 仲裁请求。

类型 ArbitrationResponse

ArbitrationResponse 包含仲裁人的裁决签名以及由此产生的支付交易信息。

type ArbitrationResponse struct {
Version uint64
PaymentAuthorizationHash []byte
UnsignedStateTxHash []byte
ArbiterTransactionSignature []byte
}

函数 UnmarshalResponse

func UnmarshalResponse(data []byte) (*ArbitrationResponse, error)

UnmarshalResponse 严格解码并规范化 007 仲裁响应。

类型 PoolPort

PoolPort 是仲裁工作流唯一需要的交易能力。实现必须使用 MultisigPool 验证交易,绝不能修改候选交易或构造替代交易,并在卖方验证成功后提供仲裁人角色签名。

type PoolPort interface {
VerifyOpening(*pool.OpeningProof) error
VerifyArbitrationCandidate(context.Context, []byte, *pool.OpeningProof, *bitfs.ContentRequestTerms, []byte) (*pool.UnsignedPayment, error)
SignArbitrationCandidate(context.Context, []byte, *pool.OpeningProof, pool.Signer) ([]byte, error)
}

类型 Workflow

Workflow 验证 007 证据并只添加仲裁人签名。它绝不负责内容定价、替换卖方候选交易,也不代表仲裁人向节点提交交易。

type Workflow struct {
// contains filtered or unexported fields
}

函数 NewWorkflow

func NewWorkflow(config WorkflowConfig) (*Workflow, error)

NewWorkflow 要求非 nil 的仲裁人 Signer、PoolPort 和授权验证器。它返回仲裁工作流,创建过程中不会产生存储或网络副作用。

函数 (*Workflow) SignPayment

func (workflow *Workflow) SignPayment(ctx context.Context, request *ArbitrationRequest) (*ArbitrationResponse, error)

SignPayment 解码并验证开池证明、独立的 003 买方授权、卖方候选交易及卖方签名。成功时返回包含已授权字节哈希和仲裁人分离签名的 007 响应;它不会广播交易或修改候选交易。

类型 WorkflowConfig

WorkflowConfig 提供仲裁人签名器、MultisigPool 验证/签名端口,以及用于验证买方已签名 003 授权的验证器。

type WorkflowConfig struct {
Signer pool.Signer
Pool PoolPort
AuthorizationVerifier bitfs.ContentTermsSignatureVerifier
}

gomarkdoc 生成