txsizes

package
v0.0.0-...-51a2c09 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2021 License: ISC Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RedeemP2PKHSigScriptSize is the worst case (largest) serialize size
	// of a transaction input script that redeems a compressed P2PKH output.
	// It is calculated as:
	//
	//   - OP_DATA_73
	//   - 72 bytes DER signature + 1 byte sighash
	//   - OP_DATA_33
	//   - 33 bytes serialized compressed pubkey
	RedeemP2PKHSigScriptSize    = 1 + 73 + 1 + 33
	RedeemP2PKHAltSigScriptSize = 3 + 751 + 3 + 897 + 1

	// P2PKHPkScriptSize is the size of a transaction output script that
	// pays to a compressed pubkey hash.  It is calculated as:
	//
	//   - OP_DUP
	//   - OP_HASH160
	//   - OP_DATA_20
	//   - 20 bytes pubkey hash
	//   - OP_EQUALVERIFY
	//   - OP_CHECKSIG
	P2PKHPkScriptSize = 1 + 1 + 1 + 20 + 1 + 1

	P2PKHAltScriptSize = 1 + 1 + 1 + 20 + 1 + 1 + 1

	P2PKBlissPKScriptSize = 1 + 1 + 1 + 897 + 1 + 1

	// RedeemP2PKHInputSize is the worst case (largest) serialize size of a
	// transaction input redeeming a compressed P2PKH output.  It is
	// calculated as:
	//
	//   - 32 bytes previous tx
	//   - 4 bytes output index
	//   - 1 byte tree
	//   - 8 bytes amount
	//   - 4 bytes block height
	//   - 4 bytes block index
	//   - 1 byte compact int encoding value 107
	//   - 107 bytes signature script
	//   - 4 bytes sequence
	RedeemP2PKHInputSize = 32 + 4 + 1 + 8 + 4 + 4 + 1 + RedeemP2PKHSigScriptSize + 4

	RedeemP2PKHAltInputSize = 32 + 4 + 1 + 8 + 4 + 4 + 3 + RedeemP2PKHAltSigScriptSize + 4

	// P2PKHOutputSize is the serialize size of a transaction output with a
	// P2PKH output script.  It is calculated as:
	//
	//   - 8 bytes output value
	//   - 2 bytes version
	//   - 1 byte compact int encoding value 25
	//   - 25 bytes P2PKH output script
	P2PKHOutputSize = 8 + 2 + 1 + P2PKHPkScriptSize

	P2PKHAltOutputSize = 8 + 2 + 1 + P2PKHAltScriptSize
)

Worst case script and input/output size estimates.

Variables

This section is empty.

Functions

func EstimateSerializeSizeByAccount

func EstimateSerializeSizeByAccount(inputCount int, txOuts []*wire.TxOut, addChangeOutput bool, accType uint8) (int, error)

EstimateSerializeSizeByAccount returns a worst case serialize size estimate for a signed transaction that spends inputCount number of compressed P2PKH outputs and contains each transaction output from txOuts. The estimated size is incremented for an additional P2PKH change output if addChangeOutput is true. Mainly rely on the account to estimate the size

func EstimateSerializeSizeByInputStripts

func EstimateSerializeSizeByInputStripts(inputScripts [][]byte, txOuts []*wire.TxOut, addChangeOutput bool, params *chaincfg.Params, sdb txscript.ScriptDB) (int, error)

EstimateSerializeSize returns a worst case serialize size estimate for a signed transaction that spends input Scripts and contains each transaction output from txOuts. The estimated size is incremented for an additional P2PKH change output if addChangeOutput is true.

Types

This section is empty.

Jump to

Keyboard shortcuts

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