triple_endpoint

package
v0.0.0-...-cdf5442 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildTripleFeePoolSpendTX

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

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

func BuildTripleFeePoolSpendTXWithProof

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

BuildTripleFeePoolSpendTXWithProof 构建三方费用池付款交易,并支持可选二进制付款证明。

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 修改金额和版本号

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)

从创建花费脚本,客户端签名

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 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)

服务器 回签

func SubBuildTripleFeePoolSpendTX

func SubBuildTripleFeePoolSpendTX(
	prevTxId string,
	serverValue uint64,

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

多签 to client,server 提供金额

func SubBuildTripleFeePoolSpendTXWithProof

func SubBuildTripleFeePoolSpendTXWithProof(
	prevTxId string,
	serverValue uint64,
	endHeight uint32,
	serverPublicKey *ec.PublicKey,
	aPrivateKey *ec.PrivateKey,
	bPublicKey *ec.PublicKey,
	isMain bool,
	feeRate float64,
	paymentProof []byte,
) (*tx.Transaction, uint64, error)

SubBuildTripleFeePoolSpendTXWithProof 构造三方费用池付款交易,并可追加付款证明 OP_RETURN。 当前三方实现仍然是 2-of-3 资金池,proof 只影响输出集合,不改变门限语义。

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 VerifySignature

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

VerifySignature 验证ClientB的签名是否正确

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 float64,
) (*BuildStep1Response, error)

p2pkh to 2t2多签, 不找零

Jump to

Keyboard shortcuts

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