Skip to main content

seller

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

Index​

type ArbitratedPaymentCommand​

ArbitratedPaymentCommand 携带完成仲裁收款所需的 exact Kind 8/9 与本地证据。

type ArbitratedPaymentCommand struct {
// RequestRaw 是 exact Kind 8 bytes。
RequestRaw []byte
// ResponseRaw 是 exact Kind 9 bytes。
ResponseRaw []byte
// DeliveryPayloadsCBOR 是本方保存的 exact content_payloads_cbor(可选;
// 提供时与 Kind 8 attachment 逐字节比对)。
DeliveryPayloadsCBOR []byte
}

type ArbitrationCommand​

ArbitrationCommand 携带构造 Kind 8 所需的本地证据。

type ArbitrationCommand struct {
// Pool 是当前池 checkpoint。
Pool *PoolCheckpoint
// Request 是被托管批次的 exact 已签 003。
Request *content.SignedContentRequest
// DeliveryRaw 是本方发出的 exact Kind 6 bytes。
DeliveryRaw []byte
}

type CloseCommand​

CloseCommand 携带完成立即关闭所需的买方材料。

type CloseCommand struct {
// Pool 是当前池 checkpoint。
Pool *PoolCheckpoint
// Unsigned 是买方 prepared 的未签名关闭 candidate。
Unsigned *pool.UnsignedPayment
// BuyerSignature 是买方对该 candidate 的 detached 交易签名。
BuyerSignature []byte
}

type CompletePaymentResult​

CompletePaymentResult 是 CompletePayment 的统一 Result:Transaction 是完整 签名交易(是否广播由应用决定);NextPool 是合并后的本地 verified 状态。

type CompletePaymentResult struct {
// Transaction 是签名完整的付款交易;广播边界属于应用。
Transaction *pool.VerifiedSignedTransaction
// NextPool 是本笔付款之后的池 checkpoint(verified 本地状态)。
NextPool *PoolCheckpoint
}

type DeliveryCheckpoint​

DeliveryCheckpoint 是无锁本地角色状态:记录验收 005 时必需的目标序号与 绝对累计金额等上下文。它不携带 owner/lease/expiry 语义,也不复制 base 值。

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

func RestoreDeliveryCheckpoint​

func RestoreDeliveryCheckpoint(rawKind1, openingProofCBOR, rawKind5, rawKind6 []byte) (*DeliveryCheckpoint, error)

RestoreDeliveryCheckpoint 从本方生成并签署该交付时的完整 exact evidence (exact Kind 1 + canonical opening proof 编码 + exact 已签 Kind 5 + 本方发出 的 exact Kind 6)恢复交付 checkpoint,并做全量重验:

  • 003 全链证据:报价证据与卖方签名、池绑定、买方统一签名、条款 ID 与角色绑定;
  • 004 归属:content_delivery_cbor 绑定的授权 ID 与 Kind 5 重算值一致, 卖方对精确 content_delivery_cbor 的统一签名有效(证明本方确实签署过该交付);
  • 四个 checkpoint 字段全部从授权原文重派生,绝不信任持久化派生值。

func (*DeliveryCheckpoint) AuthorizationID​

func (c *DeliveryCheckpoint) AuthorizationID() protocol.PaymentAuthorizationID

AuthorizationID 返回本批次的授权 typed ID。

func (*DeliveryCheckpoint) PaymentSequence​

func (c *DeliveryCheckpoint) PaymentSequence() protocol.PaymentSequence

PaymentSequence 返回目标付款序号。

func (*DeliveryCheckpoint) RefundTemplateTxID​

func (c *DeliveryCheckpoint) RefundTemplateTxID() pool.RefundTemplateTxID

RefundTemplateTxID 返回所属费用池关联 ID。

func (*DeliveryCheckpoint) SellerAmountAfterSatoshis​

func (c *DeliveryCheckpoint) SellerAmountAfterSatoshis() protocol.Satoshis

SellerAmountAfterSatoshis 返回绝对累计卖方金额(绝对聪数)。

type DeliveryCommand​

DeliveryCommand 携带构造一次 004 交付所需的全部输入。授权哈希绝不重复提供: 它们只来自买方已签 003。

type DeliveryCommand struct {
// Quote 是本池对应的已签报价凭证(exact Kind 1 解码结果)。
Quote *content.SignedFileQuote
// Pool 是当前池 checkpoint。
Pool *PoolCheckpoint
// RequestRaw 是买方发来的 exact Kind 5 bytes。
RequestRaw []byte
// ContentPayloads 是原始 payload 批次,顺序与授权哈希一一对应。
ContentPayloads [][]byte
// Seed 在批次包含任何块时提供 seed 原文;纯 seed 批次可空。
Seed []byte
}

type DeliveryResult​

DeliveryResult 是 DeliverContent 的统一 Result:Outbound 是待发送 exact Kind 6——发送前必须先保存 Payloads 与 Checkpoint(先保存后发送)。

type DeliveryResult struct {
// Outbound 是待发送 exact Kind 6 wire Artifact。
Outbound wire.Artifact
// Checkpoint 记录验收买方 005 所需的全部协议上下文。
Checkpoint *DeliveryCheckpoint
}

type FundingVerificationResult​

FundingVerificationResult 是 VerifyFundingDelivery 的统一 Result: FundingTransactionRaw 仅供应用经自己的节点适配器广播;SDK 不广播也不声称 节点接受。InitialPool 必须在广播决策前持久化。

type FundingVerificationResult struct {
// Opening 是含资金交易原文的完整 verified 开池证明。
Opening *pool.VerifiedOpening
// InitialPool 是初始池 checkpoint。
InitialPool *PoolCheckpoint
// FundingTransactionRaw 是已验证资金交易字节的原样副本,供应用广播。
FundingTransactionRaw []byte
}

type OpeningCheckpoint​

OpeningCheckpoint 是卖方本地预签状态(尚未注资):应用必须在发送 Kind 3 之前 先持久化本 checkpoint 的 evidence;VerifyFundingDelivery 与仲裁路径需要它。

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

func RestoreOpeningCheckpoint​

func RestoreOpeningCheckpoint(rawKind2 []byte, rawKind3 []byte) (*OpeningCheckpoint, error)

RestoreOpeningCheckpoint 从 exact evidence(exact Kind 2 请求 bytes + exact Kind 3 响应 bytes)恢复卖方预签 checkpoint:请求侧做完整证据验证(结构、 角色、canonical 模板重建、买方交易签名),响应侧验证其关联 ID 与请求重派生 值一致、并确认其中的卖方签名确实覆盖该模板——预签证明只能由真实证据重建。

func (*OpeningCheckpoint) Opening​

func (c *OpeningCheckpoint) Opening() *pool.OpeningProof

Opening 返回深拷贝的预签开池证据。

type PaymentCommand​

PaymentCommand 携带完成一笔累计付款所需的全部证据。

type PaymentCommand struct {
// Pool 是当前池 checkpoint。
Pool *PoolCheckpoint
// Request 是按 005 携带的 AuthorizationID 取回的 exact 已签 003。
Request *content.SignedContentRequest
// Update 是对端发来的 exact Kind 7 bytes。
UpdateRaw []byte
// Checkpoint 是生成本批次 004 时保存的 DeliveryCheckpoint。
Checkpoint *DeliveryCheckpoint
}

type PoolCheckpoint​

PoolCheckpoint 是卖方本地资金池状态:完整开池证明 + 当前付款状态。

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

func RestorePoolCheckpoint​

func RestorePoolCheckpoint(openingProofCBOR []byte, paymentRawTx []byte) (*PoolCheckpoint, error)

RestorePoolCheckpoint 从 exact evidence(canonical opening proof 编码 + 当前 完整付款状态 raw tx)恢复池 checkpoint:opening 与付款状态都走完整签名验证 路径;角色归属绑定由后续操作用 Workflow 公钥再次强制执行。

func (*PoolCheckpoint) Opening​

func (c *PoolCheckpoint) Opening() *pool.OpeningProof

Opening 返回深拷贝的完整开池证据。

func (*PoolCheckpoint) Payment​

func (c *PoolCheckpoint) Payment() *pool.PaymentState

Payment 返回深拷贝的当前付款状态。

func (*PoolCheckpoint) RefundTemplateTxID​

func (c *PoolCheckpoint) RefundTemplateTxID() pool.RefundTemplateTxID

RefundTemplateTxID 返回费用池统一关联 ID。

func (*PoolCheckpoint) VerifiedOpening​

func (c *PoolCheckpoint) VerifiedOpening() (*pool.VerifiedOpening, error)

VerifiedOpening 返回经完整重验的不可变 verified opening。

type PreparePoolOpeningResult​

PreparePoolOpeningResult 是 PreparePoolOpening 的统一 Result:Outbound 是 待发送 exact Kind 3——发送前必须先持久化 Checkpoint。

type PreparePoolOpeningResult struct {
// Outbound 是待发送 exact Kind 3 预签响应 Artifact。
Outbound wire.Artifact
// Checkpoint 是必须先持久化的卖方预签 checkpoint。
Checkpoint *OpeningCheckpoint
}

type QuoteDraft​

QuoteDraft 是 CreateQuote 的单一完整草稿:filename 只能有一个来源 (RecommendedFilename 字段,SDK 会先 sanitize 再签署并在最终 terms 中展示 实际签署值)。

type QuoteDraft struct {
// SeedHash 是内容仓库种子摘要(SHA-256,32 字节)。
SeedHash []byte
// BuyerPublicKey 是唯一被授权买方的压缩公钥。
BuyerPublicKey protocol.PublicKey
// SeedPriceSatoshis 是整个 MasterSeed 的绝对单价(绝对聪数)。
SeedPriceSatoshis protocol.Satoshis
// FullBlockPriceSatoshis 是一个完整块(256 KiB)的绝对单价(绝对聪数);
// 尾块按比例并享 10% 让利。
FullBlockPriceSatoshis protocol.Satoshis
// FileSizeBytes 是文件总字节数;块数由它派生。
FileSizeBytes uint64
// QuoteExpiresAtUnixSeconds 是报价失效时间(UTC Unix 秒);必须晚于 Facts.Now。
QuoteExpiresAtUnixSeconds content.UnixSeconds
// SupportedArbiterPublicKeys 是允许的仲裁强类型公钥列表;可为空但不得重复。
SupportedArbiterPublicKeys []protocol.PublicKey
// RecommendedFilename 是唯一的文件名来源:sanitize 后进入签名条款。
RecommendedFilename string
}

type QuoteResult​

QuoteResult 是 CreateQuote 的统一 Result:Outbound 是待发送 exact Kind 1; Terms 是实际签署的最终规范化条款(含 sanitize 后的 RecommendedFilename)。

type QuoteResult struct {
// Outbound 是待发送 exact Kind 1 wire Artifact。
Outbound wire.Artifact
// Terms 是最终规范化并已签署的条款快照。
Terms *content.FileQuoteTerms
}

type Workflow​

Workflow 是 Seller 角色 API(001–007)。它只持有固定的受约束 Signer 及其 派生公钥;没有存储、待处理请求索引、内容仓库、节点、时钟或广播副作用。 所有时间/高度判断使用调用方显式传入的一份 Facts。

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

func NewWorkflow​

func NewWorkflow(signer protocol.Signer) (*Workflow, error)

NewWorkflow 固定并验证 Signer 公钥后返回 Seller 角色 API。直接私钥必须经 protocol.NewPrivateKeySigner 进入,不存在第二构造器。

func (*Workflow) CompleteArbitratedPayment​

func (workflow *Workflow) CompleteArbitratedPayment(ctx context.Context, facts protocol.Facts, command ArbitratedPaymentCommand) (*pool.VerifiedSignedTransaction, error)

CompleteArbitratedPayment 从 exact Kind 8/9 完整验证托管收款路径:独立重建 paid candidate、验证回执消息签名与仲裁交易签名,然后补签卖方交易签名并合并 完整交易。不广播;是否入账由应用决定。

func (*Workflow) CompleteClose​

func (workflow *Workflow) CompleteClose(ctx context.Context, facts protocol.Facts, command CloseCommand) (*pool.VerifiedSignedTransaction, error)

CompleteClose 校验买方关闭 candidate 结构与角色签名后补签并合并完整交易。 它不读取任何卖方数据库金额,也不判断 candidate 是否匹配业务目标。

func (*Workflow) CompletePayment​

func (workflow *Workflow) CompletePayment(ctx context.Context, facts protocol.Facts, command PaymentCommand) (*CompletePaymentResult, error)

CompletePayment 验证买方最小 Kind 7 凭证、补签并合并完整交易:返回完整交易 (仅供应用决定是否广播)与 next pool checkpoint;SDK 不声称节点接受。

func (*Workflow) CreateQuote​

func (workflow *Workflow) CreateQuote(ctx context.Context, facts protocol.Facts, draft QuoteDraft) (*QuoteResult, error)

CreateQuote 以单一 QuoteDraft 签署确定性 Kind 1 条款:先 sanitize 文件名再 编码与签名,返回待发送 Artifact 与最终规范化 terms(展示实际签署值)。 唯一时间事实为 facts.Now。

func (*Workflow) DeliverContent​

func (workflow *Workflow) DeliverContent(ctx context.Context, facts protocol.Facts, command DeliveryCommand) (*DeliveryResult, error)

DeliverContent 验证买方 003 全链证据后构造并签署 Kind 6:返回待发送 Artifact 与必须先持久化的 DeliveryCheckpoint(先保存后发送)。

func (*Workflow) PrepareArbitration​

func (workflow *Workflow) PrepareArbitration(ctx context.Context, facts protocol.Facts, command ArbitrationCommand) (wire.Artifact, error)

PrepareArbitration 验证本地开池、买方授权与本方已发交付后,签署紧凑 Claim 证据并返回 exact Kind 8 Artifact。它不构造也不预测仲裁方响应。

func (*Workflow) PreparePoolOpening​

func (workflow *Workflow) PreparePoolOpening(ctx context.Context, rawKind2 []byte) (*PreparePoolOpeningResult, error)

PreparePoolOpening 验证 exact Kind 2 并计算卖方退款预签:返回待发送 Kind 3 Artifact 与必须先持久化的 OpeningCheckpoint。相同的重复请求只会得到等价的 新鲜计算结果——SDK 不存储、不重放。

func (*Workflow) PublicKey​

func (workflow *Workflow) PublicKey() []byte

PublicKey 返回本角色的固定压缩公钥副本。

func (*Workflow) VerifyFundingDelivery​

func (workflow *Workflow) VerifyFundingDelivery(checkpoint *OpeningCheckpoint, rawKind4 []byte) (*FundingVerificationResult, error)

VerifyFundingDelivery 用保存的预签 checkpoint 验收 exact Kind 4:完成开池 证明并解析初始退款状态。返回的 FundingTransactionRaw 由应用自行广播; InitialPool 必须在广播决策前持久化。方法名不含 Accept/Broadcast:验收证据 与提交网络是两件事。

Generated by gomarkdoc