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 dcrd 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
- Variables
- func CheckOutput(output *wire.TxOut, relayFeePerKb dcrutil.Amount) error
- func FeeForSerializeSize(relayFeePerKb dcrutil.Amount, txSerializeSize int) dcrutil.Amount
- func IsDustAmount(amount dcrutil.Amount, scriptSize int, relayFeePerKb dcrutil.Amount) bool
- func IsDustOutput(output *wire.TxOut, relayFeePerKb dcrutil.Amount) bool
- func IsValidPoolFeeRate(feeRate float64) error
- func StakePoolTicketFee(stakeDiff dcrutil.Amount, relayFee dcrutil.Amount, height int32, ...) dcrutil.Amount
Constants ¶
const DefaultRelayFeePerKb dcrutil.Amount = 1e5
DefaultRelayFeePerKb is the default minimum relay fee policy for a mempool.
Variables ¶
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 ¶
CheckOutput performs simple consensus and policy tests on a transaction output.
func FeeForSerializeSize ¶
FeeForSerializeSize calculates the required fee for a transaction of some arbitrary size given a mempool's relay fee policy.
func IsDustAmount ¶
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 ¶
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 ¶
IsValidPoolFeeRate tests to see if a pool fee is a valid percentage from 0.01% to 100.00%.
func StakePoolTicketFee ¶
func StakePoolTicketFee(stakeDiff dcrutil.Amount, relayFee dcrutil.Amount, height int32, poolFee float64, params *chaincfg.Params) dcrutil.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.