txrules

package
v0.0.0-...-9e8562e Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2019 License: ISC Imports: 10 Imported by: 0

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 ucd 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 ucutil.Amount = 1e4

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

Variables

This section is empty.

Functions

func CheckOutput

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

CheckOutput performs simple consensus and policy tests on a transaction output. Returns with errors.Invalid if output violates consensus rules, and errors.Policy if the output violates a non-consensus policy.

func FeeForSerializeSize

func FeeForSerializeSize(relayFeePerKb ucutil.Amount, txSerializeSize int) ucutil.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 ucutil.Amount, scriptSize int, relayFeePerKb ucutil.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 ucutil.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 PaysHighFees

func PaysHighFees(totalInput ucutil.Amount, tx *wire.MsgTx, changeInedx int) 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 ucutil.Amount, relayFee ucutil.Amount,
	height int32, poolFee float64, params *chaincfg.Params) ucutil.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.

func ValidPoolFeeRate

func ValidPoolFeeRate(feeRate float64) bool

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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