coinselector

package
v0.0.0-...-5e6921c Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NTxVersionLen                   float64 = 4
	SegWitMarkerLenAndSegWitFlagLen float64 = 0.5
	NumInputsLen                    float64 = 1 // todo is a varInt

	TrOutpointTxidLen      float64 = 32
	TrOutpointVoutLen      float64 = 4
	TrOutpointSequenceLen  float64 = 4
	TrEmptyRedeemScriptLen float64 = 1
	TrInputOutpointLen     float64 = TrOutpointTxidLen + TrOutpointVoutLen + TrEmptyRedeemScriptLen + TrOutpointSequenceLen

	// TrWitnessDataLen already discounted by 0.25 complete length (varInt + actual data)
	TrWitnessDataLen float64 = 16.25

	OutputValueLen float64 = 8

	WitnessCountLen float64 = 1 // todo is a varInt

	NLockTimeLen float64 = 4

	ScriptPubKeyTaprootLen = 34
)

See here for explanation of vByte sizes https://bitcoinops.org/en/tools/calc-size/

Variables

This section is empty.

Functions

func NeededFeeAbsolutSats

func NeededFeeAbsolutSats(vByte float64, feeRate uint32) uint64

Types

type FeeRateCoinSelector

type FeeRateCoinSelector struct {
	OwnedUTXOs      src.UtxoCollection
	MinChangeAmount uint64
	Recipients      []*src.Recipient
}

FeeRateCoinSelector Custom CoinSelector implementation. Selects according to a given fee rate. Focused on taproot-only inputs. Needs the OwnedUTXOs to contain at least the Amount of the src.OwnedUTXO. The function will fail if not enough value could be added together. Other data in the OwnedUTXOs is preserved. At the moment it is always assumed that we receive a taproot input.

func NewFeeRateCoinSelector

func NewFeeRateCoinSelector(utxos src.UtxoCollection, minChangeAmount uint64, recipients []*src.Recipient) *FeeRateCoinSelector

func (*FeeRateCoinSelector) CoinSelect

func (s *FeeRateCoinSelector) CoinSelect(feeRate uint32) (src.UtxoCollection, uint64, error)

CoinSelect returns the utxos to select and the change amount in order to achieve the desired fee rate. NOTE: A change amount is always added. todo don't require a change amount and just increase fee if difference is below a certain threshold

Jump to

Keyboard shortcuts

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