Documentation
¶
Index ¶
- Constants
- func BuildTwoPartyPoolLock(roles TwoPartyPoolRoles) (*script.Script, error)
- func BuildTwoPartyPoolOpeningState(fundingTxID []byte, poolOutputIndex uint32, poolAmount uint64, ...) (*tx.Transaction, error)
- func BuildTwoPartyPoolState(input StateInput) (*tx.Transaction, error)
- func MergeTwoPartyPoolBuyerSellerSignatures(state *tx.Transaction, poolAmount uint64, roles TwoPartyPoolRoles, ...) (*tx.Transaction, error)
- func SignTwoPartyPoolAsBuyer(state *tx.Transaction, poolAmount uint64, roles TwoPartyPoolRoles, ...) ([]byte, error)
- func SignTwoPartyPoolAsSeller(state *tx.Transaction, poolAmount uint64, roles TwoPartyPoolRoles, ...) ([]byte, error)
- func UpdateTwoPartyPoolState(input StateInput) (*tx.Transaction, error)
- func VerifyTwoPartyPoolBuyerSignature(state *tx.Transaction, poolAmount uint64, roles TwoPartyPoolRoles, ...) (bool, error)
- func VerifyTwoPartyPoolSellerSignature(state *tx.Transaction, poolAmount uint64, roles TwoPartyPoolRoles, ...) (bool, error)
- type FeeSatPerKB
- type FundingTxResult
- type StateInput
- type TwoPartyPoolRoles
Constants ¶
const ( Protocol = versioninfo.Protocol Version = versioninfo.ProtocolVersion )
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
}