Documentation
¶
Overview ¶
Package pool contains the protocol-independent 2-of-3 settlement primitives used by 002, 005, and 006. It validates role-ordered MultisigPool v4 bytes, tracks monotonic payment state, and exposes pure transaction construction, parsing, signing, and verification capabilities; it deliberately does not import BitFS quote or content types and performs no storage, network, or node side effects. All signing capability enters through the constrained protocol.Signer port; all time/height judgments arrive as explicit facts.
Index ¶
- Constants
- func Build2of3LockingScript(keys MultisigPoolPublicKeys) ([]byte, error)
- func BuildPoolLock(roles mp.ArbitratedPoolRoles) ([]byte, error)
- func CheckArbitrationRefundNotExpired(refundTemplateRaw []byte, facts protocol.Facts) error
- func EncodeFundingTransactionDelivery(delivery *FundingTransactionDelivery) ([]byte, error)
- func EncodeOpeningProof(proof *OpeningProof) ([]byte, error)
- func EncodePaymentUpdate(update *PaymentUpdate) ([]byte, error)
- func EncodeRefundPresignRequest(request *RefundPresignRequest) ([]byte, error)
- func EncodeRefundPresignResponse(response *RefundPresignResponse) ([]byte, error)
- func ParseCanonicalTransaction(raw []byte) (*tx.Transaction, error)
- func RefundTemplateLockTime(refundTemplateRaw []byte) (protocol.RefundLockTime, error)
- func RefundUsesBlockHeight(refundTx []byte) (bool, error)
- func ValidateArbitrationClaimStructure(poolOutputSatoshis uint64, poolOutputLockingScript, refundTemplateRaw []byte, ...) error
- func ValidateFundingTransactionDelivery(delivery *FundingTransactionDelivery) error
- func ValidateOpeningProof(proof *OpeningProof) error
- func ValidatePaymentUpdate(update *PaymentUpdate) error
- func ValidateRefundPresignRequest(request *RefundPresignRequest) error
- func ValidateRefundPresignResponse(response *RefundPresignResponse) error
- func VerifyRefundPresignRequestEvidence(request *RefundPresignRequest) error
- type ArbiterPoolAdapter
- type BuyerPoolAdapter
- type CloseInput
- type FundingTransactionDelivery
- type Hash32
- type MultisigPoolEngine
- func (engine *MultisigPoolEngine) BuildImmediateClose(input CloseInput) (*UnsignedPayment, error)
- func (engine *MultisigPoolEngine) BuildOpeningProof(request *RefundPresignRequest, sellerSignature, fundingTx []byte) (*OpeningProof, error)
- func (engine *MultisigPoolEngine) BuildPaymentUpdate(input PaymentUpdateInput) (*UnsignedPayment, error)
- func (engine *MultisigPoolEngine) BuildRefundSubmission(proof *OpeningProof) ([]byte, error)
- func (engine *MultisigPoolEngine) CheckPaymentCapacity(input PaymentUpdateInput) error
- func (engine *MultisigPoolEngine) FundingTxID(rawTx []byte) (Hash32, error)
- func (engine *MultisigPoolEngine) MergeArbitratedPoolSellerArbiterSignatures(unsigned *UnsignedPayment, sellerSignature, arbiterSignature []byte) (*SignedPayment, error)
- func (engine *MultisigPoolEngine) MergeBuyerSellerPayment(unsigned *UnsignedPayment, buyerSignature, sellerSignature []byte, ...) (*SignedPayment, error)
- func (engine *MultisigPoolEngine) MergeSellerArbiterPayment(unsigned *UnsignedPayment, sellerSignature, arbiterSignature []byte, ...) (*SignedPayment, error)
- func (engine *MultisigPoolEngine) ParseFinalPaymentState(rawTx []byte, proof *OpeningProof) (*PaymentState, error)
- func (engine *MultisigPoolEngine) ParseNonFinalPaymentState(rawTx []byte, proof *OpeningProof) (*PaymentState, error)
- func (engine *MultisigPoolEngine) ParsePaymentState(rawTx []byte, proof *OpeningProof) (*PaymentState, error)
- func (engine *MultisigPoolEngine) ParseUnsignedPayment(rawTx []byte, proof *OpeningProof) (*UnsignedPayment, error)
- func (engine *MultisigPoolEngine) PaymentStateMatchesUnsigned(state *PaymentState, unsigned *UnsignedPayment, proof *OpeningProof) error
- func (engine *MultisigPoolEngine) SignArbitrationArbiterPayment(ctx context.Context, unsigned *UnsignedPayment, signer protocol.Signer) ([]byte, error)
- func (engine *MultisigPoolEngine) SignArbitrationSellerPayment(ctx context.Context, unsigned *UnsignedPayment, signer protocol.Signer) ([]byte, error)
- func (engine *MultisigPoolEngine) TransactionID(rawTx []byte) (Hash32, error)
- func (engine *MultisigPoolEngine) VerifyAcceptedPayment(state *PaymentState, proof *OpeningProof) error
- func (engine *MultisigPoolEngine) VerifyArbiterPayment(unsigned *UnsignedPayment, sig []byte, proof *OpeningProof) error
- func (engine *MultisigPoolEngine) VerifyArbitratedPayment(state *PaymentState, proof *OpeningProof) error
- func (engine *MultisigPoolEngine) VerifyArbitrationArbiterPayment(unsigned *UnsignedPayment, signature []byte) error
- func (engine *MultisigPoolEngine) VerifyArbitrationSellerPayment(unsigned *UnsignedPayment, signature []byte) error
- func (engine *MultisigPoolEngine) VerifyBuyerPayment(unsigned *UnsignedPayment, sig []byte, proof *OpeningProof) error
- func (engine *MultisigPoolEngine) VerifyCompletedFinalPayment(payment *SignedPayment, proof *OpeningProof) error
- func (engine *MultisigPoolEngine) VerifyFinalPayment(state *PaymentState, proof *OpeningProof) error
- func (engine *MultisigPoolEngine) VerifyFundingTx(rawTx []byte, proof *OpeningProof) error
- func (engine *MultisigPoolEngine) VerifyOpening(proof *OpeningProof) error
- func (engine *MultisigPoolEngine) VerifyPoolParticipants(proof *OpeningProof, buyer, seller, arbiter []byte) error
- func (engine *MultisigPoolEngine) VerifyRefundExpiredAt(proof *OpeningProof, at time.Time, blockHeight uint32) error
- func (engine *MultisigPoolEngine) VerifyRefundNotExpiredAt(proof *OpeningProof, at time.Time, blockHeight uint32) error
- func (engine *MultisigPoolEngine) VerifySellerPayment(unsigned *UnsignedPayment, sig []byte, proof *OpeningProof) error
- func (engine *MultisigPoolEngine) VerifySellerRefundSignature(request *RefundPresignRequest, signature []byte) error
- type MultisigPoolEngineConfig
- type MultisigPoolPublicKeys
- type OpeningDetails
- type OpeningInput
- type OpeningProof
- type PaymentState
- type PaymentUpdate
- type PaymentUpdateInput
- type RefundPresignRequest
- type RefundPresignResponse
- type RefundTemplateTxID
- type SellerPoolAdapter
- func (adapter *SellerPoolAdapter) MergeBuyerSellerPayment(unsigned *UnsignedPayment, buyerSignature, sellerSignature []byte, ...) (*SignedPayment, error)
- func (adapter *SellerPoolAdapter) MergeSellerArbiterPayment(unsigned *UnsignedPayment, sellerSignature, arbiterSignature []byte, ...) (*SignedPayment, error)
- func (adapter *SellerPoolAdapter) SignImmediateClose(ctx context.Context, unsigned *UnsignedPayment, buyerSignature []byte, ...) (*SignedPayment, error)
- func (adapter *SellerPoolAdapter) SignSellerPayment(ctx context.Context, unsigned *UnsignedPayment, proof *OpeningProof) ([]byte, error)
- func (adapter *SellerPoolAdapter) SignSellerRefund(ctx context.Context, request *RefundPresignRequest) ([]byte, error)
- func (adapter *SellerPoolAdapter) VerifyBuyerPayment(unsigned *UnsignedPayment, sig []byte, proof *OpeningProof) error
- func (adapter *SellerPoolAdapter) VerifySellerPayment(unsigned *UnsignedPayment, sig []byte, proof *OpeningProof) error
- type SignedPayment
- type UnsignedPayment
- type VerifiedOpening
- func (v *VerifiedOpening) ArbiterPublicKey() []byte
- func (v *VerifiedOpening) BuyerPublicKey() []byte
- func (v *VerifiedOpening) FundingTransactionRaw() []byte
- func (v *VerifiedOpening) MatchesBuyer(publicKey []byte) bool
- func (v *VerifiedOpening) MatchesSeller(publicKey []byte) bool
- func (v *VerifiedOpening) Proof() *OpeningProof
- func (v *VerifiedOpening) RefundTemplateTxID() RefundTemplateTxID
- func (v *VerifiedOpening) SellerPublicKey() []byte
- type VerifiedPaymentState
- func (v *VerifiedPaymentState) ArbiterAmountSatoshis() protocol.Satoshis
- func (v *VerifiedPaymentState) BuyerAmountSatoshis() protocol.Satoshis
- func (v *VerifiedPaymentState) PaymentSequence() protocol.PaymentSequence
- func (v *VerifiedPaymentState) RawTx() []byte
- func (v *VerifiedPaymentState) RefundTemplateTxID() RefundTemplateTxID
- func (v *VerifiedPaymentState) SellerAmountSatoshis() protocol.Satoshis
- func (v *VerifiedPaymentState) State() *PaymentState
- type VerifiedSignedTransaction
- func (t *VerifiedSignedTransaction) PaymentSequence() protocol.PaymentSequence
- func (t *VerifiedSignedTransaction) RawTx() []byte
- func (t *VerifiedSignedTransaction) RefundTemplateTxID() RefundTemplateTxID
- func (t *VerifiedSignedTransaction) SellerAmountSatoshis() protocol.Satoshis
- func (t *VerifiedSignedTransaction) State() *PaymentState
Constants ¶
const PoolOutputIndex uint32 = 0
PoolOutputIndex 是 FundingTransactionRaw 中资金池输出的协议固定索引。 工作流只接受第 0 个输出作为资金池输出,因此无需在消息中重复传输。 对外协议版本只使用 protocol.WireVersion,本包不再定义任何平行版本常量。
Variables ¶
This section is empty.
Functions ¶
func Build2of3LockingScript ¶
func Build2of3LockingScript(keys MultisigPoolPublicKeys) ([]byte, error)
Build2of3LockingScript delegates construction of the 2-of-3 MultisigPool locking script using the explicit Buyer, Seller, and Arbiter public keys.
func BuildPoolLock ¶
func BuildPoolLock(roles mp.ArbitratedPoolRoles) ([]byte, error)
BuildPoolLock is the public role-explicit lock adapter. The v4 role object determines each participant's meaning by its Buyer, Seller, and Arbiter fields.
func CheckArbitrationRefundNotExpired ¶
CheckArbitrationRefundNotExpired applies the local nLockTime forward gate to the refund template using the caller's explicit facts: 只读取锁定类型对应的 那一份事实。It proves only that the template is not yet mature; it does not prove that the source output exists, is confirmed, or remains unspent.
func EncodeFundingTransactionDelivery ¶
func EncodeFundingTransactionDelivery(delivery *FundingTransactionDelivery) ([]byte, error)
EncodeFundingTransactionDelivery validates and encodes the Kind 4 funding-transaction delivery container with its RefundTemplateTxID correlation ID. It does not verify that the funding transaction spends the retained opening proof.
func EncodeOpeningProof ¶
func EncodeOpeningProof(proof *OpeningProof) ([]byte, error)
EncodeOpeningProof validates and encodes the complete opening proof. IDs, the fixed output index, amount, and locking script are deliberately omitted because they are derived from the transaction evidence and participant keys. The opening proof is application-local evidence, not one of the eleven wire kinds; its encoding carries no version or kind of its own.
func EncodePaymentUpdate ¶
func EncodePaymentUpdate(update *PaymentUpdate) ([]byte, error)
EncodePaymentUpdate validates and encodes the minimal Kind 7 payment authorization ID plus detached buyer payment transaction signature as its four-field deterministic CBOR container. The pool correlation ID and the unsigned state transaction are not transmitted: both sides rebuild the exact transaction locally from the opening proof, previous payment state, and the signed payment authorization referenced by the ID. It performs structural validation, not node acceptance or signature verification.
func EncodeRefundPresignRequest ¶
func EncodeRefundPresignRequest(request *RefundPresignRequest) ([]byte, error)
EncodeRefundPresignRequest validates and encodes the Kind 2 buyer refund-presign request: the canonical unsigned refund template raw bytes, role keys, fee rate, and detached buyer transaction signature. The funding outpoint, pool amount, and pool lock are derived canonically from refund_template_raw and the participant keys. The request does not duplicate the derived RefundTemplateTxID.
func EncodeRefundPresignResponse ¶
func EncodeRefundPresignResponse(response *RefundPresignResponse) ([]byte, error)
EncodeRefundPresignResponse validates and encodes the seller's Kind 3 refund signature response with the pool's RefundTemplateTxID correlation ID re-derived by the seller from the request.
func ParseCanonicalTransaction ¶
func ParseCanonicalTransaction(raw []byte) (*tx.Transaction, error)
ParseCanonicalTransaction parses a protocol transaction only when its raw bytes are the SDK's canonical serialization. Workflows use this before deriving outpoints, IDs, or signatures.
func RefundTemplateLockTime ¶
func RefundTemplateLockTime(refundTemplateRaw []byte) (protocol.RefundLockTime, error)
RefundTemplateLockTime 从退款模板原文提取强类型 nLockTime;模板字节必须 是 canonical 交易编码。
func RefundUsesBlockHeight ¶
RefundUsesBlockHeight deterministically classifies a refund locktime. It parses the supplied refund bytes and returns true for Bitcoin nLockTime values below the timestamp threshold; malformed bytes are rejected.
func ValidateArbitrationClaimStructure ¶
func ValidateArbitrationClaimStructure(poolOutputSatoshis uint64, poolOutputLockingScript, refundTemplateRaw []byte, paymentSequence uint32, sellerAmountAfterSatoshis uint64) error
ValidateArbitrationClaimStructure exposes the pure Claim-structure checks of the 007 candidate for callers that hold evidence but not yet a decided arbitration fee. It performs exactly the same source, role-script, refund template, sequence, and Seller-balance validation as the success builder, minus the positive-arbiter-amount requirement, so evidence validation never needs a placeholder fee.
func ValidateFundingTransactionDelivery ¶
func ValidateFundingTransactionDelivery(delivery *FundingTransactionDelivery) error
ValidateFundingTransactionDelivery requires a non-zero 32-byte RefundTemplateTxID and raw funding transaction bytes; it does not prove the bytes spend the opening.
func ValidateOpeningProof ¶
func ValidateOpeningProof(proof *OpeningProof) error
ValidateOpeningProof checks role keys and raw refund evidence. It is structural; VerifyOpening performs transaction and signature relationship checks.
func ValidatePaymentUpdate ¶
func ValidatePaymentUpdate(update *PaymentUpdate) error
ValidatePaymentUpdate checks the Kind 7 minimal envelope, 32-byte non-zero authorization ID, and presence of the detached buyer payment transaction signature. It does not parse transactions or establish that a node accepted anything; the referenced signed payment authorization and the rebuilt unsigned state transaction are verified by the receiving workflow.
func ValidateRefundPresignRequest ¶
func ValidateRefundPresignRequest(request *RefundPresignRequest) error
ValidateRefundPresignRequest checks the Kind 2 request required refund evidence, role keys, fee rate, and buyer transaction signature presence. It does not verify the refund transaction or either signature cryptographically.
func ValidateRefundPresignResponse ¶
func ValidateRefundPresignResponse(response *RefundPresignResponse) error
ValidateRefundPresignResponse requires a non-zero 32-byte RefundTemplateTxID and a seller refund transaction signature; matching them to a request is a workflow operation.
func VerifyRefundPresignRequestEvidence ¶
func VerifyRefundPresignRequestEvidence(request *RefundPresignRequest) error
VerifyRefundPresignRequestEvidence 完整验证 Kind 2 预签请求自身证据: 结构、角色、退款模板 canonical 重建与买方对模板的交易签名。恢复路径用它 保证 checkpoint 只能由真实证据重建。
Types ¶
type ArbiterPoolAdapter ¶
type ArbiterPoolAdapter struct {
*MultisigPoolEngine
// Signer 是仲裁方受约束签名能力。
Signer protocol.Signer
}
ArbiterPoolAdapter adapts the pool engine to arbiter workflow operations.
func NewArbiterPoolAdapter ¶
func NewArbiterPoolAdapter(engine *MultisigPoolEngine, signer protocol.Signer) *ArbiterPoolAdapter
NewArbiterPoolAdapter binds an engine to the arbiter signer used to sign the candidate state selected by the 007 workflow.
func (*ArbiterPoolAdapter) SignArbiterPayment ¶
func (adapter *ArbiterPoolAdapter) SignArbiterPayment(ctx context.Context, unsigned *UnsignedPayment, proof *OpeningProof) ([]byte, error)
SignArbiterPayment produces the arbiter's detached signature over an unsigned pool transaction.
type BuyerPoolAdapter ¶
type BuyerPoolAdapter struct {
*MultisigPoolEngine
// Signer 是买方受约束签名能力(软件私钥适配器或 HSM/KMS 远程服务)。
Signer protocol.Signer
}
BuyerPoolAdapter adapts the pool engine to buyer workflow operations. Signer is the caller-supplied constrained signing capability; SDK 固定构造 sighash digest,Signer 只执行密钥操作,私钥绝不进入任何 wire 报文、本地结果、日志或持久化结构。
func NewBuyerPoolAdapter ¶
func NewBuyerPoolAdapter(engine *MultisigPoolEngine, signer protocol.Signer) *BuyerPoolAdapter
NewBuyerPoolAdapter binds an engine to the buyer signer used for detached payment and refund signatures. It performs no signing at construction.
func (*BuyerPoolAdapter) BuildRefundPresignRequest ¶
func (adapter *BuyerPoolAdapter) BuildRefundPresignRequest(ctx context.Context, input OpeningInput) (*RefundPresignRequest, error)
BuildRefundPresignRequest constructs a RefundPresignRequest from the funding transaction and opening input using the adapter's bound buyer signer. It returns an error if funding output 0 does not use the configured pool lock or if the buyer key does not match the engine.
func (*BuyerPoolAdapter) SignBuyerPayment ¶
func (adapter *BuyerPoolAdapter) SignBuyerPayment(ctx context.Context, unsigned *UnsignedPayment, proof *OpeningProof) ([]byte, error)
SignBuyerPayment produces the buyer's detached signature over an unsigned pool transaction.
type CloseInput ¶
type CloseInput struct {
// Opening 是用于验证资金池身份和多签交易规则的开池证据。
Opening *OpeningProof
// Base 是调用方选定的基准付款状态;SDK 不声称它是数据库最新状态。
Base *PaymentState
// SellerAmountAfterSatoshis 是候选最终关闭状态中卖方的累计金额,单位为 satoshi。
SellerAmountAfterSatoshis uint64
}
CloseInput 提供立即关闭资金池、构造最终付款交易所需的开池证据、调用方 选定的基准状态和业务目标金额。Base 是否为业务最新状态、目标金额是否符合 订单或账本,由调用方决定;SDK 只验证协议编码与守恒边界。
func CloneCloseInput ¶
func CloneCloseInput(input CloseInput) CloseInput
CloneCloseInput returns an independent copy of CloseInput, including copies of mutable byte slices.
type FundingTransactionDelivery ¶
type FundingTransactionDelivery struct {
// RefundTemplateTxID 是费用池统一关联 ID,只能从买方已验证的 OpeningProof
// 派生,不得由调用方另行拼接。
RefundTemplateTxID RefundTemplateTxID
// FundingTransactionRaw 是买方资金交易的原始序列化字节,卖方据此验证交易 ID、输入和池输出。
FundingTransactionRaw []byte
}
FundingTransactionDelivery 携带买方在退款交易验证完成后公开的、已由买方签名的资金交易, 以及用于路由到对应费用池的统一关联 ID。
func CloneFundingTransactionDelivery ¶
func CloneFundingTransactionDelivery(delivery *FundingTransactionDelivery) *FundingTransactionDelivery
CloneFundingTransactionDelivery returns an independent copy of FundingTransactionDelivery, including copies of mutable byte slices.
func DecodeFundingTransactionDelivery ¶
func DecodeFundingTransactionDelivery(data []byte) (*FundingTransactionDelivery, error)
DecodeFundingTransactionDelivery decodes and canonicality-checks the Kind 4 funding delivery; SellerAcceptFundingTx performs the proof and node checks.
type Hash32 ¶
Hash32 是通用 32 字节哈希的仓库唯一真值(protocol.Hash32 的别名): 资金池域内表示资金交易 TxID 等协议身份标识。领域专属身份继续使用独立 命名类型(如 RefundTemplateTxID),不与通用哈希互换。
type MultisigPoolEngine ¶
type MultisigPoolEngine struct {
// contains filtered or unexported fields
}
MultisigPoolEngine is the adapter boundary to MultisigPool v4. It preserves Buyer/Seller/Arbiter role ordering while delegating scripts, fees, sighash, state construction, and signature ordering to that dependency. The engine holds no business state and performs no storage, network, or node I/O.
func NewMultisigPoolEngine ¶
func NewMultisigPoolEngine(config MultisigPoolEngineConfig) (*MultisigPoolEngine, error)
NewMultisigPoolEngine parses and validates three distinct role keys, preserving Buyer/Seller/Arbiter identity for every later transaction check. It returns an error for malformed or duplicate keys and performs no network or storage I/O.
func NewMultisigPoolEngineFromPoolLockingScript ¶
func NewMultisigPoolEngineFromPoolLockingScript(raw []byte) (*MultisigPoolEngine, error)
NewMultisigPoolEngineFromPoolLockingScript restores the role-aware engine from the exact source locking script supplied in an arbitration Claim.
func (*MultisigPoolEngine) BuildImmediateClose ¶
func (engine *MultisigPoolEngine) BuildImmediateClose(input CloseInput) (*UnsignedPayment, error)
BuildImmediateClose constructs the unsigned final close state from the accepted payment and CloseInput. The buyer obtains its detached signature separately through BuyerPoolAdapter before the seller adds its signature.
func (*MultisigPoolEngine) BuildOpeningProof ¶
func (engine *MultisigPoolEngine) BuildOpeningProof(request *RefundPresignRequest, sellerSignature, fundingTx []byte) (*OpeningProof, error)
BuildOpeningProof retains only the original opening evidence. fundingTx may be nil while the seller stores the presigned pending proof; all transaction identities and pool-output terms are derived when the proof is consumed.
func (*MultisigPoolEngine) BuildPaymentUpdate ¶
func (engine *MultisigPoolEngine) BuildPaymentUpdate(input PaymentUpdateInput) (*UnsignedPayment, error)
BuildPaymentUpdate constructs the next unsigned pool state transaction from the previous accepted payment and the requested amounts.
This is the protocol's normal payment transaction-construction core: buyer and seller call it with the same explicit local inputs (opening proof, previous state, target sequence, absolute seller amount) so both sides deterministically rebuild byte-identical unsigned transactions. The 007 path uses BuildArbitrationPaymentFromClaim in arbitration.go instead: it has no OpeningProof or previous state on the wire and reconstructs from the signed Claim's source context.
func (*MultisigPoolEngine) BuildRefundSubmission ¶
func (engine *MultisigPoolEngine) BuildRefundSubmission(proof *OpeningProof) ([]byte, error)
BuildRefundSubmission merges the buyer and seller refund signatures from the opening proof into a broadcast-ready transaction.
func (*MultisigPoolEngine) CheckPaymentCapacity ¶
func (engine *MultisigPoolEngine) CheckPaymentCapacity(input PaymentUpdateInput) error
CheckPaymentCapacity performs only deterministic arithmetic checks on a caller-supplied update. BuildPaymentUpdate first performs the complete proof-bound opening and previous-state verification, then calls this helper.
func (*MultisigPoolEngine) FundingTxID ¶
func (engine *MultisigPoolEngine) FundingTxID(rawTx []byte) (Hash32, error)
FundingTxID returns the 32-byte funding outpoint from the first input of a raw transaction.
func (*MultisigPoolEngine) MergeArbitratedPoolSellerArbiterSignatures ¶
func (engine *MultisigPoolEngine) MergeArbitratedPoolSellerArbiterSignatures(unsigned *UnsignedPayment, sellerSignature, arbiterSignature []byte) (*SignedPayment, error)
MergeArbitratedPoolSellerArbiterSignatures is the only merge path for the new 007 candidate. It verifies both detached signatures before delegating the canonical unlocking-script ordering to MultisigPool.
func (*MultisigPoolEngine) MergeBuyerSellerPayment ¶
func (engine *MultisigPoolEngine) MergeBuyerSellerPayment(unsigned *UnsignedPayment, buyerSignature, sellerSignature []byte, proof *OpeningProof) (*SignedPayment, error)
func (*MultisigPoolEngine) MergeSellerArbiterPayment ¶
func (engine *MultisigPoolEngine) MergeSellerArbiterPayment(unsigned *UnsignedPayment, sellerSignature, arbiterSignature []byte, proof *OpeningProof) (*SignedPayment, error)
func (*MultisigPoolEngine) ParseFinalPaymentState ¶
func (engine *MultisigPoolEngine) ParseFinalPaymentState(rawTx []byte, proof *OpeningProof) (*PaymentState, error)
ParseFinalPaymentState parses a fully signed pool transaction and verifies it is the final settlement (sequence == finalPoolSequence).
func (*MultisigPoolEngine) ParseNonFinalPaymentState ¶
func (engine *MultisigPoolEngine) ParseNonFinalPaymentState(rawTx []byte, proof *OpeningProof) (*PaymentState, error)
ParseNonFinalPaymentState parses a fully signed pool transaction and rejects the reserved final-close sequence before any backend can receive it.
func (*MultisigPoolEngine) ParsePaymentState ¶
func (engine *MultisigPoolEngine) ParsePaymentState(rawTx []byte, proof *OpeningProof) (*PaymentState, error)
ParsePaymentState parses a fully signed pool transaction into a PaymentState. Returns an error if the transaction has an empty unlocking script.
func (*MultisigPoolEngine) ParseUnsignedPayment ¶
func (engine *MultisigPoolEngine) ParseUnsignedPayment(rawTx []byte, proof *OpeningProof) (*UnsignedPayment, error)
ParseUnsignedPayment validates and parses an unsigned pool transaction against the opening proof's canonical state.
func (*MultisigPoolEngine) PaymentStateMatchesUnsigned ¶
func (engine *MultisigPoolEngine) PaymentStateMatchesUnsigned(state *PaymentState, unsigned *UnsignedPayment, proof *OpeningProof) error
PaymentStateMatchesUnsigned proves that a previously accepted signed state is the exact same unsigned candidate, including all canonical transaction bytes. It is used only for idempotent completion retries and never signs or submits anything.
func (*MultisigPoolEngine) SignArbitrationArbiterPayment ¶
func (engine *MultisigPoolEngine) SignArbitrationArbiterPayment(ctx context.Context, unsigned *UnsignedPayment, signer protocol.Signer) ([]byte, error)
SignArbitrationArbiterPayment signs an independently rebuilt arbitration candidate with the Arbiter role constrained Signer.
func (*MultisigPoolEngine) SignArbitrationSellerPayment ¶
func (engine *MultisigPoolEngine) SignArbitrationSellerPayment(ctx context.Context, unsigned *UnsignedPayment, signer protocol.Signer) ([]byte, error)
SignArbitrationSellerPayment signs an independently rebuilt arbitration candidate with the Seller role constrained Signer.
func (*MultisigPoolEngine) TransactionID ¶
func (engine *MultisigPoolEngine) TransactionID(rawTx []byte) (Hash32, error)
TransactionID computes the canonical transaction identifier from raw transaction bytes.
func (*MultisigPoolEngine) VerifyAcceptedPayment ¶
func (engine *MultisigPoolEngine) VerifyAcceptedPayment(state *PaymentState, proof *OpeningProof) error
VerifyAcceptedPayment checks the initial or previously accepted non-arbitrated payment state against the opening proof and its complete role signatures.
func (*MultisigPoolEngine) VerifyArbiterPayment ¶
func (engine *MultisigPoolEngine) VerifyArbiterPayment(unsigned *UnsignedPayment, sig []byte, proof *OpeningProof) error
VerifyArbiterPayment validates a detached arbiter signature over an unsigned cumulative state before the signature can leave the SDK.
func (*MultisigPoolEngine) VerifyArbitratedPayment ¶
func (engine *MultisigPoolEngine) VerifyArbitratedPayment(state *PaymentState, proof *OpeningProof) error
VerifyArbitratedPayment checks a final state carrying the seller and arbiter signatures required by the 007 arbitration path.
func (*MultisigPoolEngine) VerifyArbitrationArbiterPayment ¶
func (engine *MultisigPoolEngine) VerifyArbitrationArbiterPayment(unsigned *UnsignedPayment, signature []byte) error
VerifyArbitrationArbiterPayment verifies an Arbiter transaction signature over the exact independently rebuilt candidate.
func (*MultisigPoolEngine) VerifyArbitrationSellerPayment ¶
func (engine *MultisigPoolEngine) VerifyArbitrationSellerPayment(unsigned *UnsignedPayment, signature []byte) error
VerifyArbitrationSellerPayment verifies a Seller transaction signature over the exact independently rebuilt candidate.
func (*MultisigPoolEngine) VerifyBuyerPayment ¶
func (engine *MultisigPoolEngine) VerifyBuyerPayment(unsigned *UnsignedPayment, sig []byte, proof *OpeningProof) error
VerifyBuyerPayment checks the buyer role's detached signature over the exact unsigned 005 payment state and its canonical relation to the 002 opening proof. It does not merge signatures or submit the update.
func (*MultisigPoolEngine) VerifyCompletedFinalPayment ¶
func (engine *MultisigPoolEngine) VerifyCompletedFinalPayment(payment *SignedPayment, proof *OpeningProof) error
VerifyCompletedFinalPayment validates the merged SignedPayment and identifies whether its detached signatures form a valid final settlement state.
func (*MultisigPoolEngine) VerifyFinalPayment ¶
func (engine *MultisigPoolEngine) VerifyFinalPayment(state *PaymentState, proof *OpeningProof) error
VerifyFinalPayment checks a fully signed final transaction against the opening proof, final sequence, role signatures, outputs, and canonical transaction bytes.
func (*MultisigPoolEngine) VerifyFundingTx ¶
func (engine *MultisigPoolEngine) VerifyFundingTx(rawTx []byte, proof *OpeningProof) error
VerifyFundingTx parses the delivered 002 funding transaction and matches its txid, pool output index, satoshis, and role-ordered MultisigPool v4 locking script to proof. It is an evidence check only and does not submit the transaction.
func (*MultisigPoolEngine) VerifyOpening ¶
func (engine *MultisigPoolEngine) VerifyOpening(proof *OpeningProof) error
VerifyOpening validates a complete 002 OpeningProof against this engine's Buyer/Seller/Arbiter roles. It matches the proof to the funding output and unsigned refund state, then verifies the buyer and seller refund signatures; it performs no persistence or node submission.
func (*MultisigPoolEngine) VerifyPoolParticipants ¶
func (engine *MultisigPoolEngine) VerifyPoolParticipants(proof *OpeningProof, buyer, seller, arbiter []byte) error
VerifyPoolParticipants checks that the opening proof's buyer, seller, and arbiter keys match the supplied values.
func (*MultisigPoolEngine) VerifyRefundExpiredAt ¶
func (engine *MultisigPoolEngine) VerifyRefundExpiredAt(proof *OpeningProof, at time.Time, blockHeight uint32) error
VerifyRefundExpiredAt checks whether the refund transaction's nLockTime has been reached at the caller-supplied explicit facts: timestamp locks compare against at,height locks compare against blockHeight。SDK 不读取系统时钟, 也不查询节点。
func (*MultisigPoolEngine) VerifyRefundNotExpiredAt ¶
func (engine *MultisigPoolEngine) VerifyRefundNotExpiredAt(proof *OpeningProof, at time.Time, blockHeight uint32) error
VerifyRefundNotExpiredAt is the forward-operation gate. It is deliberately separate from VerifyRefundExpiredAt so content and payment workflows cannot accidentally continue after the refund path has become executable.
func (*MultisigPoolEngine) VerifySellerPayment ¶
func (engine *MultisigPoolEngine) VerifySellerPayment(unsigned *UnsignedPayment, sig []byte, proof *OpeningProof) error
VerifySellerPayment checks the seller role's detached signature over the exact unsigned 005 payment state and its canonical relation to the 002 opening proof. It does not merge signatures or submit the update.
func (*MultisigPoolEngine) VerifySellerRefundSignature ¶
func (engine *MultisigPoolEngine) VerifySellerRefundSignature(request *RefundPresignRequest, signature []byte) error
VerifySellerRefundSignature validates the 002 presigned refund state named by request, including its funding outpoint, role keys, buyer signature, and the supplied seller detached signature. It does not submit either transaction.
type MultisigPoolEngineConfig ¶
type MultisigPoolEngineConfig struct {
// BuyerPublicKey 是费用池第一角色的压缩公钥(33 字节);角色顺序固定
// [Buyer, Seller, Arbiter],不可互换。
BuyerPublicKey []byte
// SellerPublicKey 是费用池第二角色的压缩公钥(33 字节)。
SellerPublicKey []byte
// ArbiterPublicKey 是费用池第三角色(仲裁方)的压缩公钥(33 字节)。
ArbiterPublicKey []byte
}
MultisigPoolEngineConfig supplies compressed Buyer, Seller, and Arbiter public keys in role order. Refund expiry checks take the caller-provided time and block height explicitly per call; fee and transaction rules come from MultisigPool v4.
type MultisigPoolPublicKeys ¶
type MultisigPoolPublicKeys struct {
// BuyerPublicKey 是资金池输出锁定脚本中的第一个角色公钥(压缩 33 字节)。
BuyerPublicKey []byte
// SellerPublicKey 是资金池输出锁定脚本中的第二个角色公钥(压缩 33 字节)。
SellerPublicKey []byte
// ArbiterPublicKey 是资金池输出锁定脚本中的第三个角色公钥(压缩 33 字节)。
ArbiterPublicKey []byte
}
MultisigPoolPublicKeys identifies the three pool participants by settlement role. The explicit fields keep callers from relying on positional key ordering.
func ParseArbitratedPoolLockingScript ¶
func ParseArbitratedPoolLockingScript(raw []byte) (MultisigPoolPublicKeys, error)
ParseArbitratedPoolLockingScript accepts only the canonical OP_2 <Buyer> <Seller> <Arbiter> OP_3 OP_CHECKMULTISIG script. In particular, it does not normalize push encodings, sort keys, or infer roles from signatures.
type OpeningDetails ¶
type OpeningDetails struct {
// RefundTemplateTxID 是费用池统一关联 ID(按交易 TxID 算法从规范退款模板派生,
// 不是普通 SHA-256 文档 ID),路由 002–007 的全部报文。
RefundTemplateTxID RefundTemplateTxID
// FundingTxID 是资金交易的链上交易 ID(Hash32)。
FundingTxID Hash32
// PoolOutputSatoshis 是资金池输出的聪数;重建 candidate 时作为输入金额。
PoolOutputSatoshis uint64
// PoolLockingScript 是角色顺序固定 [Buyer, Seller, Arbiter] 的 2-of-3
// 锁定脚本字节(105 字节)。
PoolLockingScript []byte
// RefundLockTime 是从规范退款模板派生的 nLockTime 原始值,供 SDK 内部
// 协议操作和调用方审计使用。时间与高度都是显式事实:timestamp 锁定由
// Facts.Now 判断,height 锁定由 Facts.BlockHeight 判断;SDK 绝不读取时钟。
RefundLockTime uint32
}
OpeningDetails 是从 OpeningProof 原始证据即时计算出的只读视图。 它不属于协议消息,也不会被编码或持久化为 OpeningProof 的字段。
func DeriveOpeningDetails ¶
func DeriveOpeningDetails(proof *OpeningProof) (*OpeningDetails, error)
DeriveOpeningDetails derives transaction identities and pool-output terms from the proof's transaction bytes and participant keys. The returned view is ephemeral and is never part of the transmitted OpeningProof.
type OpeningInput ¶
type OpeningInput struct {
// FundingTransactionRaw 是买方资金交易的原始序列化字节;其第 0 个输出必须是资金池输出。
FundingTransactionRaw []byte
// ExpiryLockTime 是退款交易使用的到期锁定时间,具体解释遵循底层交易协议。
ExpiryLockTime uint32
// MinerFeeRateSatoshisPerKilobyte 是构造退款和付款交易时采用的矿工费率,单位为 satoshi/KB。
MinerFeeRateSatoshisPerKilobyte uint64
// SellerPublicKey 是卖方的压缩 secp256k1 公钥原始字节。
SellerPublicKey []byte
// ArbiterPublicKey 是仲裁方的压缩 secp256k1 公钥原始字节。
ArbiterPublicKey []byte
}
OpeningInput 仅包含构造资金池所需的通用输入数据。
该对象由买方使用,不携带卖方签名;它用于生成 RefundPresignRequest, 而不是直接表示已经完成的 OpeningProof。
func CloneOpeningInput ¶
func CloneOpeningInput(input OpeningInput) OpeningInput
CloneOpeningInput returns an independent copy of OpeningInput, including copies of mutable byte slices.
type OpeningProof ¶
type OpeningProof struct {
// RefundTemplateRaw 是预签名退款交易的原始序列化字节。
// 该交易构成资金池的关联 ID 源,并由买方和卖方共同提供退款签名。
RefundTemplateRaw []byte
// BuyerPublicKey 是买方的 33 字节压缩 secp256k1 公钥。
BuyerPublicKey []byte
// SellerPublicKey 是卖方的 33 字节压缩 secp256k1 公钥。
SellerPublicKey []byte
// ArbiterPublicKey 是仲裁方的 33 字节压缩 secp256k1 公钥。
ArbiterPublicKey []byte
// MinerFeeRateSatoshisPerKilobyte 是构造池内交易时采用的矿工费率,单位为 satoshi/KB。
MinerFeeRateSatoshisPerKilobyte uint64
// BuyerRefundTransactionSignature 是买方对预签名退款交易提供的 DER 签名原始字节。
BuyerRefundTransactionSignature []byte
// SellerRefundTransactionSignature 是卖方对同一预签名退款交易提供的 DER 签名原始字节。
SellerRefundTransactionSignature []byte
// FundingTransactionRaw 是买方资金交易的原始序列化字节。
// 它通常在退款证据验证完成后单独交付给卖方。
FundingTransactionRaw []byte
}
OpeningProof 保存买卖双方相互验证后、用于开立资金池的退款交易和资金交易证据。
该对象通常在卖方签署退款交易后形成,在买方交付资金交易原文后补全。 RefundTemplateRaw、FundingTransactionRaw 以及各类公钥和签名均为协议要求的原始字节,调用方 不应在持久化或传输前擅自重新编码。
func CloneOpeningProof ¶
func CloneOpeningProof(proof *OpeningProof) *OpeningProof
CloneOpeningProof returns an independent copy of OpeningProof, including copies of mutable byte slices.
func DecodeOpeningProof ¶
func DecodeOpeningProof(data []byte) (*OpeningProof, error)
DecodeOpeningProof decodes and canonicality-checks an opening proof, then performs field validation; VerifyOpening is still required for signatures and transaction relationships.
func (*OpeningProof) OpeningArbiterPublicKey ¶
func (proof *OpeningProof) OpeningArbiterPublicKey() []byte
func (*OpeningProof) OpeningBuyerPublicKey ¶
func (proof *OpeningProof) OpeningBuyerPublicKey() []byte
func (*OpeningProof) OpeningRefundTemplateTxID ¶
func (proof *OpeningProof) OpeningRefundTemplateTxID() []byte
func (*OpeningProof) OpeningSellerPublicKey ¶
func (proof *OpeningProof) OpeningSellerPublicKey() []byte
type PaymentState ¶
type PaymentState struct {
// RefundTemplateTxID 是该付款所属费用池的统一关联 ID,即未嵌入角色签名的
// 规范退款模板交易 ID,而非最终链上退款 txid。
RefundTemplateTxID RefundTemplateTxID
// RawTx 是签名完整的付款状态交易原始字节。
RawTx []byte
// PaymentSequence 是该状态在资金池付款链中的序号。
// 普通内容交付更新必须相对于上一状态恰好递增 1。
PaymentSequence uint32
// BuyerAmountSatoshis 是交易向买方分配的金额,单位为 satoshi。
BuyerAmountSatoshis uint64
// SellerAmountSatoshis 是交易向卖方分配的累计金额,单位为 satoshi。
SellerAmountSatoshis uint64
// ArbiterAmountSatoshis 是交易向仲裁方分配的绝对金额,单位为 satoshi。
// 普通 005 付款恒为零;007 仲裁状态交易必须为正数,且等于回执中的
// 仲裁费。两种场景下它都是本次交易的绝对分配额,不是增量。
ArbiterAmountSatoshis uint64
// PaymentAuthorizationID 是绑定该付款的 Kind 5 文档 typed ID。
PaymentAuthorizationID protocol.PaymentAuthorizationID
// BuyerTransactionSignature 是买方在该付款交易中的 DER 签名原始字节。
BuyerTransactionSignature []byte
// SellerTransactionSignature 是卖方在该付款交易中的 DER 签名原始字节。
SellerTransactionSignature []byte
// ArbiterTransactionSignature 是仲裁方在该付款交易中的 DER 签名原始字节。
ArbiterTransactionSignature []byte
// PoolOutputSatoshis 是创建该付款状态时引用的资金池输出金额,单位为 satoshi。
PoolOutputSatoshis uint64
// PoolLockingScript 是创建该付款状态时引用的资金池输出锁定脚本原始字节。
PoolLockingScript []byte
}
PaymentState 表示角色签名完整合并后的付款状态。
RawTx 必须是完整可验证的交易,不能是未签名交易,也不能是只有一个角色 签名的中间交易。若工作流需要跨 API 边界传递独立签名,可以保存在下面的 签名字段中,但这些字段不改变 RawTx 必须完整的约束。是否已被节点接受由 调用方根据自己的广播与对账结果决定,SDK 不做此声明。
func ClonePaymentState ¶
func ClonePaymentState(state *PaymentState) *PaymentState
ClonePaymentState returns an independent copy of PaymentState, including copies of mutable byte slices.
type PaymentUpdate ¶
type PaymentUpdate struct {
// PaymentAuthorizationID 是 payment_authorization_cbor 的 SHA-256 typed ID。
// 它是本次付款授权的应用查找键,不携带任何池身份或路由信息。
PaymentAuthorizationID protocol.PaymentAuthorizationID
// BuyerPaymentTransactionSignature 是买方针对双方本地确定性重建的未签名
// 状态交易的 DER 签名原始字节。该签名与交易原文分离传输,不能把它预先写回
// 重建交易,也不是对任何文档的普通消息签名。
BuyerPaymentTransactionSignature []byte
}
PaymentUpdate 是 Kind 7 PaymentUpdate 使用的最小付款凭证传输容器。
它只携带内容授权哈希和买方对确定性重建状态交易的签名;费用池 ID 与未签名 状态交易不再进入 wire。接收方先用 PaymentAuthorizationID 取回保存的精确 原始 003,再从 003、OpeningProof 和 previous PaymentState 在本地调用唯一的 BuildPaymentUpdate 重建同一笔未签名状态交易,验过买方签名后补签并合并。 授权哈希是内容寻址键,不可解码出池 ID、金额或交易字节。
func ClonePaymentUpdate ¶
func ClonePaymentUpdate(update *PaymentUpdate) *PaymentUpdate
ClonePaymentUpdate returns an independent copy of PaymentUpdate, including copies of mutable byte slices.
func DecodePaymentUpdate ¶
func DecodePaymentUpdate(data []byte) (*PaymentUpdate, error)
DecodePaymentUpdate decodes and canonicality-checks the Kind 7 four-element minimal container, then validates its field shape. Any other shape is rejected outright; it does not prove pool ownership or verify the buyer signature against a rebuilt transaction.
type PaymentUpdateInput ¶
type PaymentUpdateInput struct {
// Opening 是用于验证资金池身份、输出和参与方密钥的开池证据。
Opening *OpeningProof
// Previous 是上一笔已接受的付款状态;首次构造付款时可表示初始退款状态。
Previous *PaymentState
// PaymentSequence 是新付款状态的目标序号;普通内容交付更新必须为
// 上一序号恰好加 1,且不得使用保留的最终关闭序号。
PaymentSequence uint32
// SellerAmountAfterSatoshis 是新状态中卖方的累计金额,单位为 satoshi。
SellerAmountAfterSatoshis uint64
}
PaymentUpdateInput 提供构造下一笔累计付款状态所需的开池证据、上一状态和目标金额。
func ClonePaymentUpdateInput ¶
func ClonePaymentUpdateInput(input PaymentUpdateInput) PaymentUpdateInput
ClonePaymentUpdateInput returns an independent copy of PaymentUpdateInput, including copies of mutable byte slices.
type RefundPresignRequest ¶
type RefundPresignRequest struct {
// RefundTemplateRaw 是买方构造的预签名退款交易原始字节。
RefundTemplateRaw []byte
// BuyerPublicKey 是买方的压缩 secp256k1 公钥原始字节。
BuyerPublicKey []byte
// SellerPublicKey 是买方期望用于卖方签名校验的压缩 secp256k1 公钥。
SellerPublicKey []byte
// ArbiterPublicKey 是仲裁方的压缩 secp256k1 公钥原始字节。
ArbiterPublicKey []byte
// MinerFeeRateSatoshisPerKilobyte 是池内交易采用的矿工费率,单位为 satoshi/KB。
MinerFeeRateSatoshisPerKilobyte uint64
// BuyerRefundTransactionSignature 是买方已经附加到退款交易上的 DER 签名原始字节。
BuyerRefundTransactionSignature []byte
}
RefundPresignRequest 包含买方请求卖方预签退款交易时发送的开池条款和交易材料。
该请求由买方构造,卖方验证退款交易、资金池输出、公钥及费率后,使用 SellerPublicKey 对退款交易签名并返回 RefundPresignResponse。请求本身不包含 FundingTransactionRaw 原文;资金交易 ID 和固定输出索引直接从 RefundTemplateRaw 的 input 推导。
func CloneRefundPresignRequest ¶
func CloneRefundPresignRequest(request *RefundPresignRequest) *RefundPresignRequest
CloneRefundPresignRequest returns an independent copy of RefundPresignRequest, including copies of mutable byte slices.
func DecodeRefundPresignRequest ¶
func DecodeRefundPresignRequest(data []byte) (*RefundPresignRequest, error)
DecodeRefundPresignRequest decodes and canonicality-checks the Kind 2 request; cryptographic and funding-transaction acceptance remains the opening workflow's job.
type RefundPresignResponse ¶
type RefundPresignResponse struct {
// RefundTemplateTxID 是费用池统一关联 ID,由卖方从收到的 request 的
// 规范退款模板重新派生,不允许调用方任意填写。
RefundTemplateTxID RefundTemplateTxID
// SellerRefundTransactionSignature 是卖方对 RefundPresignRequest.RefundTemplateRaw 的签名原始字节。
SellerRefundTransactionSignature []byte
}
RefundPresignResponse 携带卖方对预签名退款交易的 DER 签名以及该请求的 统一关联 ID。
func CloneRefundPresignResponse ¶
func CloneRefundPresignResponse(response *RefundPresignResponse) *RefundPresignResponse
CloneRefundPresignResponse returns an independent copy of RefundPresignResponse, including copies of mutable byte slices.
func DecodeRefundPresignResponse ¶
func DecodeRefundPresignResponse(data []byte) (*RefundPresignResponse, error)
DecodeRefundPresignResponse decodes and canonicality-checks the Kind 3 seller response without deciding whether the signature matches a particular request.
type RefundTemplateTxID ¶
RefundTemplateTxID 是费用池的统一关联 ID:未嵌入角色签名的规范退款模板 交易的 TxID。它只标识资金池本身,不标识同一资金池内的某次关闭或付款尝试, 也不是最终广播退款交易的链上 txid。普通内容哈希继续使用各自的 Hash32, 不能把所有 32 字节值混成资金池关联 ID。
func DeriveRefundTemplateTxID ¶
func DeriveRefundTemplateTxID(proof *OpeningProof) (RefundTemplateTxID, error)
DeriveRefundTemplateTxID returns the stable pool correlation ID: the canonical transaction ID of the unsigned presigned refund template carried by the OpeningProof. Transaction identity is calculated by the fixed SDK transaction parser; applications do not supply a calculator. The merged, broadcastable refund transaction has a different on-chain txid; that final txid is a submission result and never replaces RefundTemplateTxID.
func DeriveRefundTemplateTxIDFromRequest ¶
func DeriveRefundTemplateTxIDFromRequest(request *RefundPresignRequest) (RefundTemplateTxID, error)
DeriveRefundTemplateTxIDFromRequest derives the same pool correlation ID directly from a 0201 RefundPresignRequest, before any OpeningProof exists. It shares the single canonical parse and TxID calculation with DeriveRefundTemplateTxID, so both entries return byte-identical values for the same RefundTemplateRaw.
type SellerPoolAdapter ¶
type SellerPoolAdapter struct {
*MultisigPoolEngine
// Signer 是卖方受约束签名能力。
Signer protocol.Signer
}
SellerPoolAdapter adapts the pool engine to seller workflow operations.
func NewSellerPoolAdapter ¶
func NewSellerPoolAdapter(engine *MultisigPoolEngine, signer protocol.Signer) *SellerPoolAdapter
NewSellerPoolAdapter binds an engine to the seller signer used for detached payment, refund, and arbitration-candidate signatures.
func (*SellerPoolAdapter) MergeBuyerSellerPayment ¶
func (adapter *SellerPoolAdapter) MergeBuyerSellerPayment(unsigned *UnsignedPayment, buyerSignature, sellerSignature []byte, proof *OpeningProof) (*SignedPayment, error)
MergeBuyerSellerPayment combines detached role signatures into the required fully signed payment transaction.
func (*SellerPoolAdapter) MergeSellerArbiterPayment ¶
func (adapter *SellerPoolAdapter) MergeSellerArbiterPayment(unsigned *UnsignedPayment, sellerSignature, arbiterSignature []byte, proof *OpeningProof) (*SignedPayment, error)
MergeSellerArbiterPayment combines detached role signatures into the required fully signed payment transaction.
func (*SellerPoolAdapter) SignImmediateClose ¶
func (adapter *SellerPoolAdapter) SignImmediateClose(ctx context.Context, unsigned *UnsignedPayment, buyerSignature []byte, proof *OpeningProof) (*SignedPayment, error)
SignImmediateClose signs the seller's portion of an immediate close and merges it with the buyer signature, returning the completed SignedPayment.
func (*SellerPoolAdapter) SignSellerPayment ¶
func (adapter *SellerPoolAdapter) SignSellerPayment(ctx context.Context, unsigned *UnsignedPayment, proof *OpeningProof) ([]byte, error)
SignSellerPayment produces the seller's detached signature over an unsigned pool transaction.
func (*SellerPoolAdapter) SignSellerRefund ¶
func (adapter *SellerPoolAdapter) SignSellerRefund(ctx context.Context, request *RefundPresignRequest) ([]byte, error)
SignSellerRefund produces the seller's detached signature over the presigned refund transaction described by request.
func (*SellerPoolAdapter) VerifyBuyerPayment ¶
func (adapter *SellerPoolAdapter) VerifyBuyerPayment(unsigned *UnsignedPayment, sig []byte, proof *OpeningProof) error
VerifyBuyerPayment checks the buyer role's detached signature over the exact unsigned 005 payment state, after validating its canonical outputs against the 002 opening proof. It does not merge the seller signature or submit the state.
func (*SellerPoolAdapter) VerifySellerPayment ¶
func (adapter *SellerPoolAdapter) VerifySellerPayment(unsigned *UnsignedPayment, sig []byte, proof *OpeningProof) error
VerifySellerPayment checks the seller role's detached signature over the exact unsigned 005 payment state and its canonical relation to the 002 opening proof. It does not merge the buyer signature or submit the update.
type SignedPayment ¶
type SignedPayment struct {
// State 保存付款金额、序号、资金池身份和交易签名等解析后的状态信息。
State PaymentState
// RawTx 保存与 State 对应的付款交易原始字节。
RawTx []byte
}
SignedPayment 包含一份付款状态及其对应的交易原始字节。
func CloneSignedPayment ¶
func CloneSignedPayment(payment *SignedPayment) *SignedPayment
CloneSignedPayment returns an independent copy of SignedPayment, including copies of mutable byte slices.
type UnsignedPayment ¶
type UnsignedPayment struct {
// RefundTemplateTxID 是该付款所属费用池的统一关联 ID,即未嵌入角色签名的
// 规范退款模板交易 ID。
RefundTemplateTxID RefundTemplateTxID
// RawTx 是未签名付款交易的原始字节,不得包含解锁脚本或交易签名。
RawTx []byte
// PaymentSequence 是待签名付款状态的序号。
PaymentSequence uint32
// BuyerAmountSatoshis 是交易向买方分配的金额,单位为 satoshi。
BuyerAmountSatoshis uint64
// SellerAmountSatoshis 是交易向卖方分配的累计金额,单位为 satoshi。
SellerAmountSatoshis uint64
// ArbiterAmountSatoshis 是交易向仲裁方分配的绝对金额,单位为 satoshi。
// 普通 005 付款恒为零;007 仲裁状态交易必须为正数,且等于调用方传入
// builder 的明确仲裁费。两种场景下它都是本次交易的绝对分配额,不是增量。
ArbiterAmountSatoshis uint64
// PoolOutputSatoshis 是该付款所引用的资金池输出金额,单位为 satoshi。
PoolOutputSatoshis uint64
// PoolLockingScript 是该付款所引用的资金池输出锁定脚本原始字节。
PoolLockingScript []byte
// contains filtered or unexported fields
}
UnsignedPayment 是单角色签名方法唯一接受的交易对象。
它只描述未签名交易及其可验证的状态元数据,不包含解锁脚本,也不包含 任何嵌入式签名;各角色应在此对象基础上独立生成签名。
func BuildArbitrationPaymentFromClaim ¶
func BuildArbitrationPaymentFromClaim(poolOutputSatoshis uint64, poolOutputLockingScript, refundTemplateRaw []byte, paymentSequence uint32, sellerAmountAfterSatoshis uint64, arbiterAmountSatoshis uint64) (*UnsignedPayment, error)
BuildArbitrationPaymentFromClaim is the sole 007 candidate builder over the fixed MultisigPool transaction rules. It accepts only source amount, source locking script, refund template bytes, target sequence, the absolute seller amount, and the explicit absolute arbiter fee. A successful 007 requires a positive arbiter amount; zero is never accepted here. Source metadata is added to the in-memory transaction solely for ForkID sighash calculation and is never serialized into RawTx.
type VerifiedOpening ¶
type VerifiedOpening struct {
// contains filtered or unexported fields
}
VerifiedOpening 是字段私有、访问器防御性复制的已验证开池证明:它证明退款 模板结构、角色脚本、买卖双方退款签名与(若已交付)资金交易关系全部正确。 它不拥有存储或网络行为;应用自行持久化 exact evidence 并负责广播边界。
func VerifyOpeningProof ¶
func VerifyOpeningProof(proof *OpeningProof) (*VerifiedOpening, error)
VerifyOpeningProof 对开池证据执行完整协议验证:退款模板 canonical 重建、 角色脚本、买卖双方退款签名与(若已交付)资金交易关系。伪造或篡改的 OpeningProof 无法得到 VerifiedOpening。角色归属绑定由调用方补充检查。
func (*VerifiedOpening) ArbiterPublicKey ¶
func (v *VerifiedOpening) ArbiterPublicKey() []byte
ArbiterPublicKey 返回仲裁方压缩公钥副本。
func (*VerifiedOpening) BuyerPublicKey ¶
func (v *VerifiedOpening) BuyerPublicKey() []byte
BuyerPublicKey 返回买方压缩公钥副本。
func (*VerifiedOpening) FundingTransactionRaw ¶
func (v *VerifiedOpening) FundingTransactionRaw() []byte
FundingTransactionRaw 返回已交付资金交易的原始字节副本;未交付时为空。
func (*VerifiedOpening) MatchesBuyer ¶
func (v *VerifiedOpening) MatchesBuyer(publicKey []byte) bool
MatchesBuyer 报告该开池证明是否属于指定买方压缩公钥。
func (*VerifiedOpening) MatchesSeller ¶
func (v *VerifiedOpening) MatchesSeller(publicKey []byte) bool
MatchesSeller 报告该开池证明是否属于指定卖方压缩公钥。
func (*VerifiedOpening) Proof ¶
func (v *VerifiedOpening) Proof() *OpeningProof
Proof 返回深拷贝的完整开池证据(含全部公钥、签名与交易原文)。
func (*VerifiedOpening) RefundTemplateTxID ¶
func (v *VerifiedOpening) RefundTemplateTxID() RefundTemplateTxID
RefundTemplateTxID 返回派生的费用池统一关联 ID。
func (*VerifiedOpening) SellerPublicKey ¶
func (v *VerifiedOpening) SellerPublicKey() []byte
SellerPublicKey 返回卖方压缩公钥副本。
type VerifiedPaymentState ¶
type VerifiedPaymentState struct {
// contains filtered or unexported fields
}
VerifiedPaymentState 是字段私有、访问器防御性复制的已验证付款状态: RawTx 必须是完整可验证交易;SDK 不声明节点接受或业务最新状态。
func VerifyPaymentState ¶
func VerifyPaymentState(state *PaymentState, proof *OpeningProof) (*VerifiedPaymentState, error)
VerifyPaymentState 验证一份已合并付款状态在给定 opening 下密码学完整: 依次尝试普通 Buyer+Seller 与仲裁 Seller+Arbiter 两条完整签名路径;两者都 失败即拒绝。伪造的 PaymentState 无法得到 VerifiedPaymentState。
func (*VerifiedPaymentState) ArbiterAmountSatoshis ¶
func (v *VerifiedPaymentState) ArbiterAmountSatoshis() protocol.Satoshis
ArbiterAmountSatoshis 返回仲裁方绝对分配额(绝对聪数);普通付款恒为零。
func (*VerifiedPaymentState) BuyerAmountSatoshis ¶
func (v *VerifiedPaymentState) BuyerAmountSatoshis() protocol.Satoshis
BuyerAmountSatoshis 返回买方分配金额(绝对聪数)。
func (*VerifiedPaymentState) PaymentSequence ¶
func (v *VerifiedPaymentState) PaymentSequence() protocol.PaymentSequence
PaymentSequence 返回该状态的付款序号。
func (*VerifiedPaymentState) RawTx ¶
func (v *VerifiedPaymentState) RawTx() []byte
RawTx 返回完整签名的付款状态交易原始字节副本。
func (*VerifiedPaymentState) RefundTemplateTxID ¶
func (v *VerifiedPaymentState) RefundTemplateTxID() RefundTemplateTxID
RefundTemplateTxID 返回所属费用池统一关联 ID。
func (*VerifiedPaymentState) SellerAmountSatoshis ¶
func (v *VerifiedPaymentState) SellerAmountSatoshis() protocol.Satoshis
SellerAmountSatoshis 返回卖方的绝对累计金额(绝对聪数)。
func (*VerifiedPaymentState) State ¶
func (v *VerifiedPaymentState) State() *PaymentState
State 返回深拷贝的付款状态(金额、序号、池身份与角色签名)。
type VerifiedSignedTransaction ¶
type VerifiedSignedTransaction struct {
// contains filtered or unexported fields
}
VerifiedSignedTransaction 是字段私有、访问器防御性复制的完整签名交易结果: 密码学签名已完成并经 SDK 自验/复核(Complete),但 SDK 绝不声称它已被节点 接受、已广播或已确认;广播与对账是应用的决定。
func CompleteArbitratedTransaction ¶
func CompleteArbitratedTransaction(unsigned *UnsignedPayment, sellerSignature, arbiterSignature []byte) (*VerifiedSignedTransaction, error)
CompleteArbitratedTransaction 是 007 收款合并的唯一原子入口:在 pool 内部 一次完成 Seller/Arbiter 双签名验证、canonical 合并与 Verified 构造。 它不依赖任何"调用前已验证"的顺序约定——双签名中任意一个无效都会整体失败, 不产生部分结果;成功返回的 VerifiedSignedTransaction 才代表密码学完整。
func VerifySignedTransaction ¶
func VerifySignedTransaction(rawTx []byte, proof *OpeningProof) (*VerifiedSignedTransaction, error)
VerifySignedTransaction 解析并完整验证一笔 opening 约束下的完整签名交易 (累计付款、立即关闭或到期退款提交):逐字节解析、池 outpoint/输出关系、 双方角色签名全部复核。伪造 raw bytes 无法得到 VerifiedSignedTransaction; 广播与否仍由应用决定。
func (*VerifiedSignedTransaction) PaymentSequence ¶
func (t *VerifiedSignedTransaction) PaymentSequence() protocol.PaymentSequence
PaymentSequence 返回状态序号;无状态元数据时返回 0。
func (*VerifiedSignedTransaction) RawTx ¶
func (t *VerifiedSignedTransaction) RawTx() []byte
RawTx 返回完整签名交易原始字节副本;仅供应用决定是否广播。
func (*VerifiedSignedTransaction) RefundTemplateTxID ¶
func (t *VerifiedSignedTransaction) RefundTemplateTxID() RefundTemplateTxID
RefundTemplateTxID 返回所属费用池统一关联 ID。
func (*VerifiedSignedTransaction) SellerAmountSatoshis ¶
func (t *VerifiedSignedTransaction) SellerAmountSatoshis() protocol.Satoshis
SellerAmountSatoshis 返回卖方累计金额(绝对聪数);无状态元数据时返回 0。
func (*VerifiedSignedTransaction) State ¶
func (t *VerifiedSignedTransaction) State() *PaymentState
State 返回解析后的状态元数据深拷贝;可能为 nil(例如纯退款提交场景由 调用方自行解析)。