Skip to main content

seller

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

Index​

func CompleteArbitratedPayment​

func CompleteArbitratedPayment(ctx context.Context, facts protocol.Facts, input CompleteArbitratedPaymentInput, signer protocol.Signer) ([]byte, error)

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

func CompleteClose​

func CompleteClose(ctx context.Context, facts protocol.Facts, input CompleteCloseInput, signer protocol.Signer) ([]byte, error)

CompleteClose 校验买方关闭 candidate 结构与角色签名后补签并合并完整交易。 它不读取任何卖方数据库金额,也不判断 candidate 是否匹配业务目标;返回的 完整交易原文是否广播由应用决定。

func CompleteCloseArtifact​

func CompleteCloseArtifact(ctx context.Context, facts protocol.Facts, input CompleteCloseArtifactInput, signer protocol.Signer) (wire.Artifact, error)

CompleteCloseArtifact 严格解析 Kind 12 并核对池关联 ID,验证买方交易签名后 补签,返回包含双方签名完整交易的 exact Kind 13 Artifact;它不广播交易。

func CreateQuote​

func CreateQuote(ctx context.Context, facts protocol.Facts, signer protocol.Signer, draft QuoteDraft) (wire.Artifact, *content.FileQuoteTerms, error)

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

func PrepareArbitration​

func PrepareArbitration(ctx context.Context, facts protocol.Facts, input PrepareArbitrationInput, signer protocol.Signer) (wire.Artifact, protocol.ArbitrationClaimID, error)

PrepareArbitration 验证本地开池、买方授权与本方已发交付后,签署紧凑 Claim 证据并返回 exact Kind 8 与独立计算的 Claim ID。它不构造也不预测仲裁方响应; 应用保存 Claim ID 以便路由 Kind 9 回执。

type CompleteArbitratedPaymentInput​

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

type CompleteArbitratedPaymentInput 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 CompleteCloseArtifactInput​

CompleteCloseArtifactInput 携带 exact Kind 12 买方请求与卖方本地池证据。

type CompleteCloseArtifactInput struct {
// Pool 是用于验证费用池归属与签署权限的普通证据包。
Pool SellerPoolEvidence
// RequestRaw 是买方发送的 exact Kind 12 关池请求。
RequestRaw []byte
}

type CompleteCloseInput​

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

type CompleteCloseInput struct {
// Pool 是当前池普通证据包。
Pool SellerPoolEvidence
// UnsignedRaw 是买方准备好的未签名关闭 candidate 原文。
UnsignedRaw []byte
// BuyerSignature 是买方对该 candidate 的 detached 交易签名。
BuyerSignature []byte
}

type CompletePaymentInput​

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

type CompletePaymentInput struct {
// Pool 是当前池普通证据包。
Pool SellerPoolEvidence
// Delivery 是生成本批次 exact Kind 6 时保存的交付证据包;SDK 会用它交叉
// 核对授权 ID 与本方已发交付逐字节一致,而不是只信任传入的 Kind 5。
Delivery SellerDeliveryEvidence
// RequestRaw 是按 Kind 7 携带的授权 ID 取回的 exact 已签 Kind 5;必须与
// Delivery.RawKind5 逐字节相等。
RequestRaw []byte
// UpdateRaw 是对端发来的 exact Kind 7 bytes。
UpdateRaw []byte
}

type DeliveryInput​

DeliveryInput 携带构造一次内容交付所需的全部普通输入。授权哈希绝不重复 提供:它们只来自买方 exact Kind 5。

type DeliveryInput struct {
// QuoteRaw 是本池对应的 exact Kind 1 报价字节。
QuoteRaw []byte
// Pool 是当前池普通证据包。
Pool SellerPoolEvidence
// RequestRaw 是买方发来的 exact Kind 5 bytes。
RequestRaw []byte
// ContentPayloads 是原始 payload 批次,顺序与授权哈希一一对应。
ContentPayloads [][]byte
// Seed 在批次包含任何块时提供 seed 原文;纯 seed 批次可空。
Seed []byte
}

type DeliveryRequestSummary​

DeliveryRequestSummary 是已通过 Kind 5、报价、开池、签名、时序与当前池状态 预检的摘要。它不证明 payload 可用、属于 seed 或与授权价格相符;签署 Kind 6 前仍必须调用 PrepareDelivery 完成全量内容验收。

type DeliveryRequestSummary struct {
// PaymentAuthorizationID 是 SHA-256(exact payment_authorization_cbor),用于
// 关联本次授权;它不同于目标付款状态序号 PaymentSequence。
PaymentAuthorizationID protocol.PaymentAuthorizationID
// FileQuoteTermsID 是该授权所引用的 exact 报价条款 ID。
FileQuoteTermsID protocol.FileQuoteTermsID
// RefundTemplateTxID 是该授权绑定的费用池 ID。
RefundTemplateTxID pool.RefundTemplateTxID
// PaymentSequence 是目标付款状态序号,必须等于当前状态序号加一。
PaymentSequence protocol.PaymentSequence
// SellerAmountAfterSatoshis 是交付后卖方的绝对累计金额,单位 satoshi。
SellerAmountAfterSatoshis protocol.Satoshis
// DeliveryDeadlineUnixSeconds 是授权签入的交付截止时间(UTC Unix 秒)。
DeliveryDeadlineUnixSeconds content.UnixSeconds
// ContentHashes 是授权签入的有序内容哈希副本,按此顺序读取和传入 payload。
ContentHashes [][]byte
}

func InspectDeliveryRequest​

func InspectDeliveryRequest(facts protocol.Facts, input InspectDeliveryRequestInput) (*DeliveryRequestSummary, error)

InspectDeliveryRequest 严格解析并预检买方 exact Kind 5,返回授权 ID、目标付款 序号和有序内容哈希,使应用能在读取内容仓库前完成协议门禁。预检验证报价、开池、 买家签名、截止时间、当前付款状态与容量;它不读取内容、不签名、不生成 Kind 6。 调用方读取 payload 后仍须把同一请求和当前池证据传给 PrepareDelivery,由其验证 payload 哈希、seed/block 归属、长度与价格后再签署交付。

type InspectDeliveryRequestInput​

InspectDeliveryRequestInput 携带预检一次 exact Kind 5 所需的原始证据。 它不要求 payload;调用方可先用返回清单读取内容仓库,再调用 PrepareDelivery。

type InspectDeliveryRequestInput struct {
// QuoteRaw 是与费用池绑定的 exact Kind 1 报价字节。
QuoteRaw []byte
// Pool 是包含开池证明与当前链上付款状态的卖方证据。
Pool SellerPoolEvidence
// RequestRaw 是买方签署的 exact Kind 5 付款授权字节。
RequestRaw []byte
}

type PrepareArbitrationInput​

PrepareArbitrationInput 携带构造 exact Kind 8 所需的本地普通证据。

type PrepareArbitrationInput struct {
// Pool 是当前池普通证据包。
Pool SellerPoolEvidence
// RequestRaw 是被托管批次的 exact 已签 Kind 5。
RequestRaw []byte
// DeliveryRaw 是本方发出的 exact Kind 6 bytes。
DeliveryRaw []byte
}

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
// MaxBlocksPerBatch 是卖方声明的每批最大 Block 数(1..64),无隐式默认值。
MaxBlocksPerBatch uint64
}

type SellerDeliveryEvidence​

SellerDeliveryEvidence 是卖方交付阶段的普通证据包:exact Kind 1 报价、 买方 exact Kind 5 授权与卖方自己发出的 exact Kind 6 交付。CompletePayment 与 PrepareArbitration 需要原样回传其中的授权与交付证据。

type SellerDeliveryEvidence struct {
// RawKind1 是卖方签署的 exact Kind 1 报价字节。
RawKind1 []byte
// RawKind5 是买方签署的 exact Kind 5 付款授权字节。
RawKind5 []byte
// RawKind6 是卖方发出的 exact Kind 6 内容交付字节(含 payload attachment)。
RawKind6 []byte
}

func PrepareDelivery​

func PrepareDelivery(ctx context.Context, facts protocol.Facts, input DeliveryInput, signer protocol.Signer) (wire.Artifact, SellerDeliveryEvidence, error)

PrepareDelivery 完成 quote/opening/时序/序号/容量/价格/payload 全量校验后 签署 Kind 6,返回待发送 exact Kind 6 与普通证据包。Send 之前应用必须先 持久化 payload 与本证据包。

type SellerOpeningEvidence​

SellerOpeningEvidence 是卖方预签阶段的普通证据包:保存买方 exact Kind 2 请求与卖方自己发出的 exact Kind 3 响应。应用先持久化它再发送 Kind 3; VerifyFunding 需要原样回传。

type SellerOpeningEvidence struct {
// RawKind2 是买方发来的 exact Kind 2 预签请求字节。
RawKind2 []byte
// RawKind3 是卖方发出的 exact Kind 3 预签响应字节(含卖方退款签名)。
RawKind3 []byte
}

func PreparePresign​

func PreparePresign(ctx context.Context, rawKind2 []byte, signer protocol.Signer) (wire.Artifact, SellerOpeningEvidence, error)

PreparePresign 顺序固定:解析 exact Kind 2 → 角色/模板/费率验证 → 买方 退款签名验证 → 才调用 Signer。金额从退款模板推导,不接收调用方金额。 返回待发送 exact Kind 3 与必须先持久化的普通证据包;相同的重复请求只会 得到等价的新鲜计算结果——SDK 不存储、不重放。

type SellerPoolEvidence​

SellerPoolEvidence 是卖方视角的资金池普通证据包:完整开池证明加当前链上 付款状态原文。省略 LatestPaymentRawTx 表示池仍处于初始退款状态,SDK 会从 opening 重建初始状态;提供时 SDK 逐字节解析并全量重验它,绝不信任调用方 声明的序号或金额。

type SellerPoolEvidence struct {
// Opening 是含资金交易原文的完整开池证明(普通数据,可深拷贝)。
Opening *pool.OpeningProof
// FundingTransactionRaw 是资金交易原文的副本;必须与 Opening 内部一致。
FundingTransactionRaw []byte
// LatestPaymentRawTx 是链上取得的最新完整付款交易原文;省略(nil/空)
// 表示初始退款状态。不得填写未上链的本地候选。
LatestPaymentRawTx []byte
}

func CompletePayment​

func CompletePayment(ctx context.Context, facts protocol.Facts, input CompletePaymentInput, signer protocol.Signer) ([]byte, SellerPoolEvidence, error)

CompletePayment 从输入重建池状态:验证 exact Kind 7 的授权 ID 与本批 only exact Kind 5 一致、序号恰好 +1、金额不倒退、容量足够,验过买方签名后 补签并合并完整交易。返回完整交易原文与付款后的普通证据包;是否广播由 应用决定,SDK 不声称节点接受。

func VerifyFunding​

func VerifyFunding(rawKind4 []byte, opening SellerOpeningEvidence) ([]byte, SellerPoolEvidence, error)

VerifyFunding 用预签证据包验收 exact Kind 4:重建完整开池证明,验证资金 交易 output[0] 金额/脚本与退款模板重建一致,并解析初始链上付款状态。 返回资金交易原文(由应用自行广播)与必须在广播决策前持久化的普通证据包; 调用方不需要也不应该提供自己的池状态。

Generated by gomarkdoc