transaction

package
v0.0.0-...-97bfcef Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTxVersion   = 2
	DefaultSequenceNum = 0xfffffffd

	MaxStandardTxWeight = 4000000 / 10
	WitnessScaleFactor  = 4
)
View Source
const SellerSignatureIndex = 2

Variables

This section is empty.

Functions

func AddrToPkScript

func AddrToPkScript(addr string, network *chaincfg.Params) ([]byte, error)

func CalcFee

func CalcFee(ins []*TxInput, outs []*TxOutput, sellerPsbt string, feeRate int64, network *chaincfg.Params) (int64, error)

func CalcFeeForBatchBuy

func CalcFeeForBatchBuy(ins []*TxInput, outs []*TxOutput, sellerPSBTList []string, feeRate int64, network *chaincfg.Params) (int64, error)

func CalcFeeForBatchBuyWithMPC

func CalcFeeForBatchBuyWithMPC(ins []*TxInput, outs []*TxOutput, sellerPSBTList []string, feeRate int64, network *chaincfg.Params, ops ...string) (int64, error)

func CalcInputSigHashForUnsignedPSBT

func CalcInputSigHashForUnsignedPSBT(updater *psbt.Updater, i int, packet *psbt.Packet, prevOutFetcher *txscript.MultiPrevOutFetcher, hashType txscript.SigHashType, publicKey string) (string, error)

func CheckDuplicateOfUpdater

func CheckDuplicateOfUpdater(updater *psbt.Updater, index int)

func ExtractTxFromSignedPSBT

func ExtractTxFromSignedPSBT(psbtHex string) (string, error)

func GenerateBatchBuyingTx

func GenerateBatchBuyingTx(ins []*TxInput, outs []*TxOutput, sellerPSBTList []string, network *chaincfg.Params) (string, error)

func GenerateBatchBuyingTxPsbt

func GenerateBatchBuyingTxPsbt(ins []*TxInput, outs []*TxOutput, sellerPSBTList []string, network *chaincfg.Params) (string, string, error)

func GenerateSignedBuyingTx

func GenerateSignedBuyingTx(ins []*TxInput, outs []*TxOutput, sellerPsbt string, network *chaincfg.Params) (string, error)

func GenerateSignedListingPSBTBase64

func GenerateSignedListingPSBTBase64(in *TxInput, out *TxOutput, network *chaincfg.Params) (string, error)

func GenerateUnsignedPSBTHex

func GenerateUnsignedPSBTHex(ins []*TxInput, outs []*TxOutput, network *chaincfg.Params) (string, error)

func GetPsbtFromString

func GetPsbtFromString(psbtStr string) (*psbt.Packet, error)

func GetRandomHash

func GetRandomHash() (string, error)

func GetTransactionWeight

func GetTransactionWeight(tx *btcutil.Tx) int64

GetTransactionWeight computes the value of the weight metric for a given transaction. Currently the weight metric is simply the sum of the transactions's serialized size without any witness data scaled proportionally by the WitnessScaleFactor, and the transaction's serialized size including any witness data.

func GetTxHex

func GetTxHex(tx *wire.MsgTx) (string, error)

func GetTxVirtualSize

func GetTxVirtualSize(tx *btcutil.Tx) int64

GetTxVirtualSize computes the virtual size of a given transaction. A transaction's virtual size is based off its weight, creating a discount for any witness data it contains, proportional to the current blockchain.WitnessScaleFactor value.

func IsHexString

func IsHexString(s string) bool

func PayToPubKeyHashScript

func PayToPubKeyHashScript(pubKeyHash []byte) ([]byte, error)

func PayToWitnessPubKeyHashScript

func PayToWitnessPubKeyHashScript(pubKeyHash []byte) ([]byte, error)

func SignPsbtWithKeyPathAndScriptPath

func SignPsbtWithKeyPathAndScriptPath(psbtHex string, privKey string, network *chaincfg.Params, option *SignPsbtOption) (string, error)

func SignRawPSBTTransaction

func SignRawPSBTTransaction(psbtHex string, privKey string) (string, error)

Types

type GenerateMPCPSbtTxRes

type GenerateMPCPSbtTxRes struct {
	Psbt         string   `json:"psbt"`
	PsbtTx       string   `json:"psbtTx"`
	SignHashList []string `json:"signHashList"`
}

func GenerateMPCSignedBuyingTx

func GenerateMPCSignedBuyingTx(psbtBase64 string, signatures []string, pubKey string, batchSize int) (*GenerateMPCPSbtTxRes, error)

func GenerateMPCSignedListingPSBT

func GenerateMPCSignedListingPSBT(psbtBase64 string, signature string, pubKey string) (*GenerateMPCPSbtTxRes, error)

func GenerateMPCSignedPSBT

func GenerateMPCSignedPSBT(psbtStr string, pubKeyHex string, signatureList []string) (*GenerateMPCPSbtTxRes, error)

func GenerateMPCUnsignedBuyingPSBT

func GenerateMPCUnsignedBuyingPSBT(ins []*TxInput, outs []*TxOutput, sellerPSBTList []string, network *chaincfg.Params) (*GenerateMPCPSbtTxRes, error)

func GenerateMPCUnsignedListingPSBT

func GenerateMPCUnsignedListingPSBT(in *TxInput, out *TxOutput, network *chaincfg.Params) (*GenerateMPCPSbtTxRes, error)

func GenerateMPCUnsignedPSBT

func GenerateMPCUnsignedPSBT(psbtStr string, pubKeyHex string) (*GenerateMPCPSbtTxRes, error)

type SignPsbtOption

type SignPsbtOption struct {
	AutoFinalized bool           `json:"autoFinalized"`
	ToSignInputs  []*ToSignInput `json:"toSignInputs"`
}

type ToSignInput

type ToSignInput struct {
	Index              int    `json:"index"`
	Address            string `json:"address"`
	PublicKey          string `json:"publicKey"`
	SigHashTypes       []int  `json:"sighashTypes"`
	DisableTweakSigner bool   `json:"disableTweakSigner"`
}

type TxInput

type TxInput struct {
	TxId              string
	VOut              uint32
	Sequence          uint32
	Amount            int64
	Address           string
	PrivateKey        string
	NonWitnessUtxo    string
	MasterFingerprint uint32
	DerivationPath    string
	PublicKey         string
}

type TxOutput

type TxOutput struct {
	Address           string
	Amount            int64
	IsChange          bool
	MasterFingerprint uint32
	DerivationPath    string
	PublicKey         string
}

Jump to

Keyboard shortcuts

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