tx_input

package
v0.0.0-...-cc9b5da Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterUnconfirmedHeuristic

func FilterUnconfirmedHeuristic[UTXO UtxoI](unspentOutputs []UTXO) []UTXO

func LegacyFeeFilter

func LegacyFeeFilter(chain *xc.ChainConfig, satsPerByte uint64, multiplier float64, maxGasPrice float64) uint64

Previously we would apply multiplier during estimation, rather than during tx-building/serialization. This should be removed with the legacy endpoints.

func MinFeePerByte

func MinFeePerByte(chain *xc.ChainConfig) uint64

Per chain min

Types

type Outpoint

type Outpoint struct {
	Hash  []byte `json:"hash"`
	Index uint32 `json:"index"`
}

A specific output from a transaction

func (*Outpoint) Equals

func (o *Outpoint) Equals(other *Outpoint) bool

type Output

type Output struct {
	Outpoint     `json:"outpoint"`
	Value        xc.AmountBlockchain `json:"value"`
	PubKeyScript []byte              `json:"pubkey_script"`
}

func FilterForMinUtxoSet

func FilterForMinUtxoSet(unspentOutputs []Output, targetAmount xc.AmountBlockchain, minUtxo int) []Output

1. sort unspentOutputs from lowest to highest 2. grab the minimum amount of UTXO needed to satify amount 3. tack on the smallest utxo's until `minUtxo` is reached. This ensures a small number of UTXO are used for transaction while also consolidating some smaller utxo into the transaction. Returns the total balance of the min utxo set. txInput.inputs are updated to the new set.

func NewOutputs

func NewOutputs[UTXO UtxoI](unspentOutputs []UTXO, addressScript []byte) []Output

type TxInput

type TxInput struct {
	xc.TxInputEnvelope
	UnspentOutputs  []Output            `json:"unspent_outputs"`
	FromPublicKey   []byte              `json:"from_pubkey"`
	GasPricePerByte xc.AmountBlockchain `json:"gas_price_per_byte"`
}

TxInput for Bitcoin

func NewTxInput

func NewTxInput() *TxInput

NewTxInput returns a new Bitcoin TxInput

func (*TxInput) GetDriver

func (input *TxInput) GetDriver() xc.Driver

func (*TxInput) GetGetPricePerByte

func (txInput *TxInput) GetGetPricePerByte() xc.AmountBlockchain

func (*TxInput) HasSameUtxoAs

func (txInput *TxInput) HasSameUtxoAs(other *TxInput) (*Outpoint, bool)

Indicate if another txInput has a same UTXO and returns the first one.

func (*TxInput) IndependentOf

func (input *TxInput) IndependentOf(other xc.TxInput) (independent bool)

func (*TxInput) SafeFromDoubleSend

func (input *TxInput) SafeFromDoubleSend(others ...xc.TxInput) (safe bool)

func (*TxInput) SetAmount

func (txInput *TxInput) SetAmount(amount xc.AmountBlockchain)

func (*TxInput) SetGasFeePriority

func (input *TxInput) SetGasFeePriority(other xc.GasFeePriority) error

func (*TxInput) SetPublicKey

func (txInput *TxInput) SetPublicKey(publicKeyBytes []byte) error

func (*TxInput) SetPublicKeyFromStr

func (txInput *TxInput) SetPublicKeyFromStr(publicKeyStr string) error

func (*TxInput) SumUtxo

func (txInput *TxInput) SumUtxo() *xc.AmountBlockchain

type UtxoI

type UtxoI interface {
	GetValue() uint64
	GetBlock() uint64
	GetTxHash() string
	GetIndex() uint32
}

Jump to

Keyboard shortcuts

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