txrules

package
v0.0.0-...-516309f Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2022 License: ISC Imports: 11 Imported by: 2

Documentation

Overview

Package txrules provides functions that are help establish whether or not a transaction abides by non-consensus rules for things like the daemon and stake pool.

Dust and Fee Per KB Calculation

Please refer to mempool.go in exccd for more information about the importance of these function.

Pool Fees

The pool fee is calculated from the percentage given according to the following formula:

       ps(v+z)
f = --------------
         s+v

where f = absolute pool fee as an amount
      p = proportion (e.g. 0.5000 = 50.00%)
      s = subsidy (adjusted two difficulty periods into the future)
      v = price of the ticket
      z = the ticket fees

This can be derived from the known relation that
ps = (f * (v+z)/(v+s)) obtained from the knowledge
that the outputs of the vote are the amounts
of the stake ticket plus subsidy (v+s) scaled by
the proportional input of the stake pool fee
f/(v+z).

f is then adjusted for the fact that at least one subsidy reduction is likely to occur before it can vote on a block.

Index

Constants

View Source
const DefaultRelayFeePerKb exccutil.Amount = 1e5

DefaultRelayFeePerKb is the default minimum relay fee policy for a mempool.

Variables

View Source
var (
	ErrAmountNegative   = errors.New("transaction output amount is negative")
	ErrAmountExceedsMax = errors.New("transaction output amount exceeds maximum value")
	ErrOutputIsDust     = errors.New("transaction output is dust")
)

Transaction rule violations

Functions

func CheckOutput

func CheckOutput(output *wire.TxOut, relayFeePerKb exccutil.Amount) error

CheckOutput performs simple consensus and policy tests on a transaction output.

func FeeForSerializeSize

func FeeForSerializeSize(relayFeePerKb exccutil.Amount, txSerializeSize int) exccutil.Amount

FeeForSerializeSize calculates the required fee for a transaction of some arbitrary size given a mempool's relay fee policy.

func IsDustAmount

func IsDustAmount(amount exccutil.Amount, scriptSize int, relayFeePerKb exccutil.Amount) bool

IsDustAmount determines whether a transaction output value and script length would cause the output to be considered dust. Transactions with dust outputs are not standard and are rejected by mempools with default policies.

func IsDustOutput

func IsDustOutput(output *wire.TxOut, relayFeePerKb exccutil.Amount) bool

IsDustOutput determines whether a transaction output is considered dust. Transactions with dust outputs are not standard and are rejected by mempools with default policies.

func IsValidPoolFeeRate

func IsValidPoolFeeRate(feeRate float64) error

IsValidPoolFeeRate tests to see if a pool fee is a valid percentage from 0.01% to 100.00%.

func PaysHighFees

func PaysHighFees(totalInput exccutil.Amount, tx *wire.MsgTx) bool

PaysHighFees checks whether the signed transaction pays insanely high fees. Transactons are defined to have a high fee if they have pay a fee rate that is 1000 time higher than the default fee.

func StakePoolTicketFee

func StakePoolTicketFee(stakeDiff exccutil.Amount, relayFee exccutil.Amount,
	height int32, poolFee float64, params *chaincfg.Params) exccutil.Amount

StakePoolTicketFee determines the stake pool ticket fee for a given ticket from the passed percentage. Pool fee as a percentage is truncated from 0.01% to 100.00%. This all must be done with integers, so bear with the big.Int usage below.

See the included doc.go of this package for more information about the calculation of this fee.

Types

This section is empty.

Jump to

Keyboard shortcuts

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