triple_endpoint

package
v0.1.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: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttachTriplePoolASignature

func AttachTriplePoolASignature(state *tx.Transaction, signature []byte) (*tx.Transaction, error)

AttachTriplePoolASignature returns the candidate with only A's signature attached. It is the 005 transport form and never claims to be final.

func AttachTriplePoolServerSignature

func AttachTriplePoolServerSignature(state *tx.Transaction, signature []byte) (*tx.Transaction, error)

AttachTriplePoolServerSignature returns the candidate with only server's signature attached for the 007 transport form.

func BuildTripleFeePoolSpendTX

func BuildTripleFeePoolSpendTX(
	A_Tx *tx.Transaction,
	serverValue uint64,
	endHeight uint32,
	serverPublicKey *ec.PublicKey,
	aPrivateKey *ec.PrivateKey,
	bPublicKey *ec.PublicKey,
	isMain bool,
	feeRate uint64,
) (*tx.Transaction, *[]byte, uint64, error)

构建双端费用池花费交易 发起者 utxos, 服务器提供金额, 发起者私钥, 服务器地址 fee 是 server 提供,我只负责精确的金额

func BuildTriplePoolFinalState

func BuildTriplePoolFinalState(input TriplePoolStateInput) (*tx.Transaction, error)

func BuildTriplePoolInitialState

func BuildTriplePoolInitialState(input TriplePoolStateInput) (*tx.Transaction, error)

func BuildTriplePoolLock

func BuildTriplePoolLock(server, a, b *ec.PublicKey) (*script.Script, error)

func BuildTriplePoolOpeningState

func BuildTriplePoolOpeningState(input TriplePoolOpeningInput) (*tx.Transaction, error)

BuildTriplePoolOpeningState constructs the initial, empty-unlocking state directly from the funding outpoint. The returned transaction has exactly two value outputs and no unlocking script.

func BuildTriplePoolState

func BuildTriplePoolState(input TriplePoolStateInput) (*tx.Transaction, error)

func ClientATripleFeePoolSpendTXUpdateSign

func ClientATripleFeePoolSpendTXUpdateSign(
	tx *tx.Transaction,
	serverPublicKey *ec.PublicKey,
	aPrivateKey *ec.PrivateKey,
	bPublicKey *ec.PublicKey,
) (*[]byte, error)

双端费用池,分配资金, 客户端签名 client -> server 修改金额和版本号

func ClientBTripleFeePoolSpendTXUpdateSign

func ClientBTripleFeePoolSpendTXUpdateSign(
	tx *tx.Transaction,
	serverPublicKey *ec.PublicKey,
	aPublicKey *ec.PublicKey,
	bPrivateKey *ec.PrivateKey,
) (*[]byte, error)

双端费用池,分配资金, server 签名 client -> server 修改金额和版本号 Deprecated: use SignTriplePoolAsB for the explicit B/arbiter role.

func ClientTripleFeePoolSpendTXUpdateSign

func ClientTripleFeePoolSpendTXUpdateSign(
	tx *tx.Transaction,
	clientPrivateKey *ec.PrivateKey,
	serverPublicKey *ec.PublicKey,
	receiverPublicKey *ec.PublicKey,
) (*[]byte, error)

ClientTripleFeePoolSpendTXUpdateSign 三方费用池,客户端签名 用于 GetLatestTripleCostPoolHistory 函数中,由客户端对三方费用池进行签名

func ClientVerifyServerSig

func ClientVerifyServerSig(
	transactionObject *tx.Transaction,
	totalAmount uint64,
	serverPublicKey *ec.PublicKey,
	aPublicKey *ec.PublicKey,
	escrowPublicKey *ec.PublicKey,
	serverSignBytes *[]byte,
) (bool, error)

ClientVerifyServerSig 用于验证服务器在三方花费交易中的签名。

func MergeTripleFeePoolSigForSpendTx

func MergeTripleFeePoolSigForSpendTx(
	txHex string,
	aSignByte *[]byte,
	bSignByte *[]byte,
) (*tx.Transaction, error)

从创建花费脚本,客户端签名 Deprecated: use MergeTriplePoolServerA or MergeTriplePoolServerB so the CHECKMULTISIG role order is explicit.

func MergeTriplePoolServerA deprecated

func MergeTriplePoolServerA(txHex string, serverSig, aSig *[]byte) (*tx.Transaction, error)

MergeTriplePoolServerA fixes the CHECKMULTISIG order to server then A.

Deprecated: use MergeTriplePoolServerAWithRoles. Without the role keys and source amount this compatibility helper can only enforce signature shape, not which pool slot produced each signature.

func MergeTriplePoolServerAWithRoles

func MergeTriplePoolServerAWithRoles(txHex string, serverSig, aSig *[]byte, server, a, b *ec.PublicKey, poolAmount uint64) (*tx.Transaction, error)

MergeTriplePoolServerAWithRoles verifies both signatures against the same unsigned transaction before assembling the canonical server+A unlocking script. The source output is restored from the explicit pool description so a raw transaction cannot silently validate against a different pool.

func MergeTriplePoolServerB deprecated

func MergeTriplePoolServerB(txHex string, serverSig, bSig *[]byte) (*tx.Transaction, error)

MergeTriplePoolServerB fixes the CHECKMULTISIG order to server then B.

Deprecated: use MergeTriplePoolServerBWithRoles. Without the role keys and source amount this compatibility helper can only enforce signature shape, not which pool slot produced each signature.

func MergeTriplePoolServerBWithRoles

func MergeTriplePoolServerBWithRoles(txHex string, serverSig, bSig *[]byte, server, a, b *ec.PublicKey, poolAmount uint64) (*tx.Transaction, error)

MergeTriplePoolServerBWithRoles is the role-checked server+B counterpart used by arbitration submissions.

func ServerTripleFeePoolSpendTXUpdateSign

func ServerTripleFeePoolSpendTXUpdateSign(
	tx *tx.Transaction,
	serverPrivateKey *ec.PrivateKey,
	aPublicKey *ec.PublicKey,
	bPublicKey *ec.PublicKey,
) (*[]byte, error)

ServerTripleFeePoolSpendTXUpdateSign signs an update as server (the seller).

func ServerVerifyClientASig

func ServerVerifyClientASig(
	transactionObject *tx.Transaction,
	totalAmount uint64,
	serverPublicKey *ec.PublicKey,
	aPublicKey *ec.PublicKey,
	escrowPublicKey *ec.PublicKey,
	aSignBytes *[]byte,
) (bool, error)

ServerVerifyClientASig 用于验证 A 方在三方花费交易中的签名。

func ServerVerifyClientBSig

func ServerVerifyClientBSig(
	transactionObject *tx.Transaction,
	totalAmount uint64,
	serverPublicKey *ec.PublicKey,
	aPublicKey *ec.PublicKey,
	escrowPublicKey *ec.PublicKey,
	bSignBytes *[]byte,
) (bool, error)

ServerVerifyClientBSig 用于验证托管方(B 方)在三方花费交易中的签名。

func SignTriplePoolAsA

func SignTriplePoolAsA(state *tx.Transaction, a *ec.PrivateKey, server, b *ec.PublicKey) (*[]byte, error)

func SignTriplePoolAsB

func SignTriplePoolAsB(state *tx.Transaction, b *ec.PrivateKey, server, a *ec.PublicKey) (*[]byte, error)

func SignTriplePoolAsServer

func SignTriplePoolAsServer(state *tx.Transaction, server *ec.PrivateKey, a, b *ec.PublicKey) (*[]byte, error)

func SpendTXTripleFeePoolASign

func SpendTXTripleFeePoolASign(
	B_Tx *tx.Transaction,
	targetAmount uint64,
	serverPublicKey *ec.PublicKey,
	aPrivKey *ec.PrivateKey,
	bPublicKey *ec.PublicKey,
) (*[]byte, error)

func SpendTXTripleFeePoolBSign

func SpendTXTripleFeePoolBSign(
	transactionObject *tx.Transaction,
	targetAmount uint64,
	serverPublicKey *ec.PublicKey,
	aPublicKey *ec.PublicKey,
	bPrivateKey *ec.PrivateKey,
) (*[]byte, error)

服务器 回签 Deprecated: use SignTriplePoolAsB for the explicit B/arbiter role.

func SubBuildTripleFeePoolSpendTX

func SubBuildTripleFeePoolSpendTX(
	prevTxId string,
	serverValue uint64,

	endHeight uint32,
	serverPublicKey *ec.PublicKey,
	aPrivateKey *ec.PrivateKey,
	bPublicKey *ec.PublicKey,
	isMain bool,
	feeRate uint64,
) (*tx.Transaction, uint64, error)

SubBuildTripleFeePoolSpendTX builds a two-output state transaction. The fixed role order is server (seller), A (buyer), B (arbiter).

func TripleFeePoolLoadTx

func TripleFeePoolLoadTx(
	txHex string,
	locktime *uint32,
	sequenceNumber uint32,
	serverAmount uint64,
	serverPublicKey *ec.PublicKey,
	aPublicKey *ec.PublicKey,
	bPublicKey *ec.PublicKey,
	targetAmount uint64,
) (*transaction.Transaction, error)

合成两个签名

func TripleFeePoolSpentScript

func TripleFeePoolSpentScript(
	serverPublicKey *ec.PublicKey,
	aPublicKey *ec.PublicKey,
	bPublicKey *ec.PublicKey,
) (*script.Script, error)

构建双端费用池的花费脚本

func TriplePoolFeeSat

func TriplePoolFeeSat(serializedSize int, rate FeeSatPerKB) (uint64, error)

func VerifySignature

func VerifySignature(
	tx *tx.Transaction,
	inputIndex uint32,
	publicKey *ec.PublicKey,
	SignByte *[]byte,
) (bool, error)

VerifySignature 验证ClientB的签名是否正确

func VerifyTriplePoolASignature

func VerifyTriplePoolASignature(state *tx.Transaction, a *ec.PublicKey, server, b *ec.PublicKey, signature *[]byte) (bool, error)

VerifyTriplePoolASignature verifies an A/buyer signature.

func VerifyTriplePoolBSignature

func VerifyTriplePoolBSignature(state *tx.Transaction, b *ec.PublicKey, server, a *ec.PublicKey, signature *[]byte) (bool, error)

VerifyTriplePoolBSignature verifies a B/arbiter signature.

func VerifyTriplePoolServerSignature

func VerifyTriplePoolServerSignature(state *tx.Transaction, server *ec.PublicKey, a, b *ec.PublicKey, signature *[]byte) (bool, error)

VerifyTriplePoolServerSignature verifies the server signature against the same unsigned state and configured server slot.

func VerifyTriplePoolState

func VerifyTriplePoolState(state *tx.Transaction, server, a, b *ec.PublicKey, poolAmount, sellerAmount uint64) error

VerifyTriplePoolState checks the fixed role mapping, two-value-output layout, empty unlocking script, and non-negative value conservation.

func VerifyTriplePoolStateWithFee

func VerifyTriplePoolStateWithFee(state *tx.Transaction, server, a, b *ec.PublicKey, poolAmount, sellerAmount uint64, rate FeeSatPerKB) error

VerifyTriplePoolStateWithFee additionally proves that the buyer output was derived from the canonical integer fee policy for this exact state shape. The fee probe uses the same deterministic fake unlocking script as the builders, while the caller's transaction remains untouched.

Types

type BuildStep1Response

type BuildStep1Response struct {
	Tx     *tx.Transaction
	Amount uint64
	Index  int
}
type BuildTripleFeePoolBaseTxResponse struct {
	Tx     *tx.Transaction
	Amount uint64
	Index  int
}

func BuildTripleFeePoolBaseTx

func BuildTripleFeePoolBaseTx(
	clientUtxo *[]libs.UTXO,

	serverPublicKey *ec.PublicKey,
	aPrivateKey *ec.PrivateKey,
	bPublicKey *ec.PublicKey,
	isMain bool,
	feeRate uint64,
) (*BuildStep1Response, error)

p2pkh to 2t2多签, 不找零

type FeeSatPerKB

type FeeSatPerKB uint64

FeeSatPerKB is the integer fee unit used by every triple-pool state.

type TriplePoolOpeningInput

type TriplePoolOpeningInput struct {
	FundingTxID     []byte
	PoolOutputIndex uint32
	PoolAmount      uint64
	LockTime        uint32
	Server          *ec.PublicKey
	A               *ec.PublicKey
	B               *ec.PublicKey
	FeeRate         FeeSatPerKB
}

TriplePoolOpeningInput describes the one pool output that funds the first state. It keeps funding-transaction parsing and the initial two-output state template inside MultisigPool.

type TriplePoolStateInput

type TriplePoolStateInput struct {
	PreviousRawTx []byte
	Sequence      uint32
	LockTime      *uint32
	SellerAmount  uint64
	PoolAmount    uint64
	Server        *ec.PublicKey
	A             *ec.PublicKey
	B             *ec.PublicKey
	FeeRate       FeeSatPerKB
}

Jump to

Keyboard shortcuts

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