seller
import "github.com/bsv8/go-bitfs/seller"
Package seller implements the seller-side BitFS v3 workflow.
A Workflow creates signed quotes, coordinates pool opening, validates content requests, delivers signed content, advances cumulative payments, and prepares arbitration evidence. Wallet, storage, content, transaction, and node capabilities remain application-owned and are supplied through WorkflowConfig. A seller typically creates a 001 quote, completes 002, serves validated 003 requests with 004 deliveries, accepts 005 payments, and builds 007 evidence only when the buyer-authorized state requires arbitration.
Index
- type ContentSource
- type QuoteStore
- type Workflow
- func NewWorkflow(config WorkflowConfig) (*Workflow, error)
- func (workflow *Workflow) AcceptPayment(ctx context.Context, update *pool.PaymentUpdate) (*pool.PaymentState, error)
- func (workflow *Workflow) AcceptPoolFunding(ctx context.Context, delivery *pool.FundingTxDelivery) (*pool.OpeningProof, error)
- func (workflow *Workflow) BuildArbitrationRequest(context.Context, *pool.OpeningProof, *pool.PaymentUpdate) (*arbitration.ArbitrationRequest, error)
- func (workflow *Workflow) BuildArbitrationRequestFromAuthorization(ctx context.Context, proof *pool.OpeningProof, authorization *bitfs.SignedContentRequest, latest *pool.PaymentState) (*arbitration.ArbitrationRequest, error)
- func (workflow *Workflow) CreateQuote(ctx context.Context, draft bitfs.FileQuoteTerms, recommendedFilename string) (*bitfs.SignedFileQuote, error)
- func (workflow *Workflow) DeliverRequestedContent(ctx context.Context, request *bitfs.SignedContentRequest) (delivery *bitfs.SignedContentDelivery, err error)
- func (workflow *Workflow) PresignPoolOpening(ctx context.Context, request *pool.RefundPresignRequest) (*pool.RefundPresignResponse, error)
- func (workflow *Workflow) SignImmediateClose(ctx context.Context, unsigned *pool.UnsignedPayment, buyerSig []byte, _ pool.Signer) (*pool.SignedPayment, error)
- func (workflow *Workflow) SubmitArbitratedPayment(ctx context.Context, request *arbitration.ArbitrationRequest, response *arbitration.ArbitrationResponse) (*pool.PaymentState, error)
- type WorkflowConfig
type ContentSource
ContentSource reads seed or block bytes selected by a validated content request.
type ContentSource interface {
LoadContent(context.Context, bitfs.Hash32) ([]byte, error)
}
type QuoteStore
QuoteStore stores seller-signed 001 quote credentials addressed by canonical terms hash so later 003 requests can be independently verified.
type QuoteStore interface {
SaveQuote(context.Context, *bitfs.SignedFileQuote) error
LoadQuote(context.Context, bitfs.Hash32) (*bitfs.SignedFileQuote, error)
}
type Workflow
Workflow implements the seller side of 001–007. It creates quotes, completes pool opening, serializes content delivery, verifies buyer payments, and prepares or submits arbiter-authorized states through injected ports.
type Workflow struct {
// contains filtered or unexported fields
}
func NewWorkflow
func NewWorkflow(config WorkflowConfig) (*Workflow, error)
NewWorkflow validates all mandatory seller dependencies and returns a workflow. A nil Clock is replaced by time.Now; missing signing, storage, content, transaction, participant, or node ports are rejected before any side effect.
func (*Workflow) AcceptPayment
func (workflow *Workflow) AcceptPayment(ctx context.Context, update *pool.PaymentUpdate) (*pool.PaymentState, error)
AcceptPayment verifies the buyer's 005 update against the accepted pool state, adds the seller signature, submits the exact transaction, and advances stored state only after the node confirms the expected transaction and sequence.
func (*Workflow) AcceptPoolFunding
func (workflow *Workflow) AcceptPoolFunding(ctx context.Context, delivery *pool.FundingTxDelivery) (*pool.OpeningProof, error)
AcceptPoolFunding verifies the delivered funding transaction, completes the opening proof, and records the initial accepted refund state.
func (*Workflow) BuildArbitrationRequest
func (workflow *Workflow) BuildArbitrationRequest(context.Context, *pool.OpeningProof, *pool.PaymentUpdate) (*arbitration.ArbitrationRequest, error)
BuildArbitrationRequest is intentionally disabled: arbitration must be built from the signed 003 authorization, never from a buyer payment wrapper.
func (*Workflow) BuildArbitrationRequestFromAuthorization
func (workflow *Workflow) BuildArbitrationRequestFromAuthorization(ctx context.Context, proof *pool.OpeningProof, authorization *bitfs.SignedContentRequest, latest *pool.PaymentState) (*arbitration.ArbitrationRequest, error)
BuildArbitrationRequestFromAuthorization packages the retained opening proof, signed 003 authorization, latest payment state, and seller signature into the 007 evidence request. It never constructs a replacement candidate transaction.
func (*Workflow) CreateQuote
func (workflow *Workflow) CreateQuote(ctx context.Context, draft bitfs.FileQuoteTerms, recommendedFilename string) (*bitfs.SignedFileQuote, error)
CreateQuote signs deterministic 001 quote terms with the seller key, persists the complete credential by its terms hash, and returns an owned copy. The recommended filename is display metadata and is not part of the signature.
func (*Workflow) DeliverRequestedContent
func (workflow *Workflow) DeliverRequestedContent(ctx context.Context, request *bitfs.SignedContentRequest) (delivery *bitfs.SignedContentDelivery, err error)
DeliverRequestedContent verifies the buyer's 003 request and its quote, reads the requested seed or block from ContentSource, and signs a 004 delivery. A pending-request lease prevents concurrent deliveries for the same pool.
func (*Workflow) PresignPoolOpening
func (workflow *Workflow) PresignPoolOpening(ctx context.Context, request *pool.RefundPresignRequest) (*pool.RefundPresignResponse, error)
PresignPoolOpening prepares and records the presigned pool-opening evidence.
func (*Workflow) SignImmediateClose
func (workflow *Workflow) SignImmediateClose(ctx context.Context, unsigned *pool.UnsignedPayment, buyerSig []byte, _ pool.Signer) (*pool.SignedPayment, error)
SignImmediateClose complements the buyer's final close signature. It does not submit or alter pool state; the buyer decides when to call SubmitFinal.
func (*Workflow) SubmitArbitratedPayment
func (workflow *Workflow) SubmitArbitratedPayment(ctx context.Context, request *arbitration.ArbitrationRequest, response *arbitration.ArbitrationResponse) (*pool.PaymentState, error)
SubmitArbitratedPayment verifies the 007 response hashes and arbiter signature, merges the seller and arbiter signatures over the authorized unsigned state, submits that exact transaction, and persists it only after node acceptance.
type WorkflowConfig
WorkflowConfig supplies every seller dependency: signing and verification, quote/pool/pending stores, content source, opening and transaction ports, participant checks, node submission, and an optional test Clock.
type WorkflowConfig struct {
Signer pool.Signer
SignatureVerifier bitfs.ContentTermsSignatureVerifier
QuoteVerifier bitfs.QuoteTermsSignatureVerifier
Clock func() time.Time
Quotes QuoteStore
Pools pool.PoolStore
OpeningHooks pool.SellerPoolOpeningHooks
Pending pool.PendingRequestStore
Content ContentSource
Transactions pool.SellerPoolPort
Participants pool.ParticipantVerifier
Node pool.NonFinalPoolNode
}
Generated by gomarkdoc