buyer

由 doc2go 直接从当前 Go 源码与 doc comments 生成。

package buyer

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

Package buyer implements the buyer-side BitFS v3 workflow.

A Workflow verifies and stores seller quotes, coordinates pool opening, creates signed content requests, verifies deliveries, and produces cumulative payment updates. Wallet, storage, content, transaction, and node capabilities remain application-owned and are supplied through WorkflowConfig.

Index

Types

type ContentRequestInput

type ContentRequestInput struct {
	QuoteTermsHash        bitfs.Hash32
	Pool                  pool.Reference
	SelectedArbiterPubKey []byte
	Content               bitfs.ContentRef
	ContentSize           uint64
	DeliveryDeadline      bitfs.UnixSeconds
}

type ContentSink

type ContentSink interface {
	SaveVerifiedContent(context.Context, bitfs.Hash32, []byte) error
}

type QuoteStore

type QuoteStore interface {
	SaveQuote(context.Context, *bitfs.SignedFileQuote) error
	LoadQuote(context.Context, bitfs.Hash32) (*bitfs.SignedFileQuote, error)
}

type SeedSource

type SeedSource interface {
	LoadSeed(context.Context, bitfs.Hash32) ([]byte, error)
}

SeedSource supplies a previously verified seed so block requests can be checked against the seed's committed block-hash list.

type Workflow

type Workflow struct {
	// contains filtered or unexported fields
}
func NewWorkflow
func NewWorkflow(config WorkflowConfig) (*Workflow, error)
func (*Workflow) AcceptDelivery
func (workflow *Workflow) AcceptDelivery(ctx context.Context, request *bitfs.SignedContentRequest, delivery *bitfs.SignedContentDelivery) (*pool.PaymentUpdate, error)
func (*Workflow) AcceptQuote
func (workflow *Workflow) AcceptQuote(ctx context.Context, quote *bitfs.SignedFileQuote) (*bitfs.FileQuoteTerms, error)
func (*Workflow) AcceptRefundPresign
func (workflow *Workflow) AcceptRefundPresign(ctx context.Context, request *pool.RefundPresignRequest, response *pool.RefundPresignResponse, fundingTx []byte) (*pool.Reference, error)

AcceptRefundPresign verifies and durably records the complete pool proof, then records RefundTx as the initial accepted payment state (sequence 2, seller amount 0). The caller may reveal fundingTx only after this method succeeds, matching the 002 message ordering.

func (*Workflow) BuildFundingTxDelivery
func (workflow *Workflow) BuildFundingTxDelivery(fundingTx []byte) (*pool.FundingTxDelivery, error)
func (*Workflow) BuildImmediateClose
func (workflow *Workflow) BuildImmediateClose(ctx context.Context, input pool.CloseInput) (*pool.UnsignedPayment, []byte, error)
func (*Workflow) PreparePoolOpening
func (workflow *Workflow) PreparePoolOpening(ctx context.Context, input pool.OpeningInput) (*pool.RefundPresignRequest, error)

PreparePoolOpening asks the transaction engine to build the generic 002 refund evidence. FundingTx remains caller-owned and is not submitted here.

func (*Workflow) RefundAfterExpiry
func (workflow *Workflow) RefundAfterExpiry(ctx context.Context, spendTxID pool.Hash32) (pool.Hash32, error)

RefundAfterExpiry verifies expiry, assembles the separately stored opening signatures into a broadcastable refund, and submits it. If a higher accepted cumulative state exists, the non-final node remains authoritative and this method refuses to bypass it.

func (*Workflow) RequestContent
func (workflow *Workflow) RequestContent(ctx context.Context, input ContentRequestInput) (*bitfs.SignedContentRequest, error)
func (*Workflow) SubmitImmediateClose
func (workflow *Workflow) SubmitImmediateClose(ctx context.Context, close *pool.SignedPayment) (pool.Hash32, error)

type WorkflowConfig

type WorkflowConfig struct {
	Signer            pool.Signer
	QuoteVerifier     bitfs.QuoteTermsSignatureVerifier
	SignatureVerifier bitfs.ContentTermsSignatureVerifier
	Clock             func() time.Time
	Quotes            QuoteStore
	Pools             pool.PoolStore
	Opening           pool.BuyerPoolOpeningHooks
	Participants      pool.ParticipantVerifier
	Node              pool.NonFinalPoolNode
	Transactions      pool.BuyerPoolPort
	ContentSink       ContentSink
	SeedSource        SeedSource
}