two_party_pool

package
v4.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const FinalLockTime uint32 = 0xffffffff

FinalLockTime is the sequence-final locktime used by callers that close a state.

Variables

This section is empty.

Functions

func BuildTwoPartyPoolLock

func BuildTwoPartyPoolLock(roles TwoPartyPoolRoles) (*script.Script, error)

BuildTwoPartyPoolLock 构建固定为 [Buyer, Seller] 的 2-of-2 锁定脚本。

func BuildTwoPartyPoolOpeningState

func BuildTwoPartyPoolOpeningState(fundingTxID []byte, poolOutputIndex uint32, poolAmount uint64, roles TwoPartyPoolRoles, lockTime uint32, feeRate FeeSatPerKB) (*tx.Transaction, error)

BuildTwoPartyPoolOpeningState creates the first state with zero Seller amount.

func BuildTwoPartyPoolState

func BuildTwoPartyPoolState(input StateInput) (*tx.Transaction, error)

BuildTwoPartyPoolState 构建 output[0]=Buyer、output[1]=Seller 的状态交易。

func MergeTwoPartyPoolBuyerSellerSignatures

func MergeTwoPartyPoolBuyerSellerSignatures(state *tx.Transaction, poolAmount uint64, roles TwoPartyPoolRoles, buyerSignature, sellerSignature []byte) (*tx.Transaction, error)

MergeTwoPartyPoolBuyerSellerSignatures verifies then orders [Buyer, Seller].

func SignTwoPartyPoolAsBuyer

func SignTwoPartyPoolAsBuyer(state *tx.Transaction, poolAmount uint64, roles TwoPartyPoolRoles, key *ec.PrivateKey) ([]byte, error)

SignTwoPartyPoolAsBuyer signs an unsigned state with the Buyer key.

func SignTwoPartyPoolAsSeller

func SignTwoPartyPoolAsSeller(state *tx.Transaction, poolAmount uint64, roles TwoPartyPoolRoles, key *ec.PrivateKey) ([]byte, error)

SignTwoPartyPoolAsSeller signs an unsigned state with the Seller key.

func UpdateTwoPartyPoolState

func UpdateTwoPartyPoolState(input StateInput) (*tx.Transaction, error)

UpdateTwoPartyPoolState returns a new state with explicit amounts and sequence.

func VerifyTwoPartyPoolBuyerSignature

func VerifyTwoPartyPoolBuyerSignature(state *tx.Transaction, poolAmount uint64, roles TwoPartyPoolRoles, signature []byte) (bool, error)

func VerifyTwoPartyPoolSellerSignature

func VerifyTwoPartyPoolSellerSignature(state *tx.Transaction, poolAmount uint64, roles TwoPartyPoolRoles, signature []byte) (bool, error)

Types

type FeeSatPerKB

type FeeSatPerKB uint64

type FundingTxResult

type FundingTxResult struct {
	Tx              *tx.Transaction
	PoolAmount      uint64
	PoolOutputIndex uint32
	Fee             uint64
}

FundingTxResult 是建池交易及其资金池输出的显式结果。

func BuildTwoPartyPoolFundingTx

func BuildTwoPartyPoolFundingTx(
	utxos []libs.UTXO,
	poolAmount uint64,
	buyerPrivateKey *ec.PrivateKey,
	roles TwoPartyPoolRoles,
	isMain bool,
	feeRate float64,
) (*FundingTxResult, error)

BuildTwoPartyPoolFundingTx 只接受 Buyer 所有的 UTXO,并创建 [Buyer, Seller] 池。

type StateInput

type StateInput struct {
	Protocol      string
	Version       uint32
	PreviousRawTx []byte
	// PreviousSourceOutput 在标准 raw transaction 不包含源输出元数据时显式提供源输出。
	PreviousSourceOutput *tx.TransactionOutput
	Sequence             uint32
	LockTime             *uint32
	BuyerAmount          uint64
	SellerAmount         uint64
	PoolAmount           uint64
	Roles                TwoPartyPoolRoles
	FeeRate              FeeSatPerKB
	PaymentProof         []byte
}

type TwoPartyPoolRoles

type TwoPartyPoolRoles struct {
	Buyer  *ec.PublicKey
	Seller *ec.PublicKey
}

TwoPartyPoolRoles 固定承载 2-of-2 池的业务角色。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL