txhelpers

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2017 License: ISC Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// DefaultStakeDbName is the default database name
	DefaultStakeDbName = "ffldb_stake"
)

Variables

This section is empty.

Functions

func BlockConsumesOutpointWithAddresses

func BlockConsumesOutpointWithAddresses(block *dcrutil.Block, addrs map[string]TxAction,
	c RawTransactionGetter, params *chaincfg.Params) map[string][]*dcrutil.Tx

BlockConsumesOutpointWithAddresses checks the specified block to see if it includes transactions that spend from outputs created using any of the addresses in addrs. The TxAction for each address is not important, but it would logically be TxMined. Both regular and stake transactions are checked. The RPC client is used to get the PreviousOutPoint for each TxIn of each transaction in the block, from which the address is obtained from the PkScript of that output. chaincfg Params is requried to decode the script.

func BlockReceivesToAddresses

func BlockReceivesToAddresses(block *dcrutil.Block, addrs map[string]TxAction,
	params *chaincfg.Params) map[string][]*dcrutil.Tx

BlockReceivesToAddresses checks a block for transactions paying to the specified addresses, and creates a map of addresses to a slice of dcrutil.Tx involving the address.

func BuildStakeTree

func BuildStakeTree(blocks map[int64]*dcrutil.Block, netParams *chaincfg.Params,
	nodeClient *dcrrpcclient.Client, poolRequiredHeight int64, DBName ...string) (database.DB, []int64, error)

func FeeInfoBlock added in v0.3.2

func FeeInfoBlock(block *dcrutil.Block, c RawTransactionGetter) *dcrjson.FeeInfoBlock

FeeInfoBlock computes ticket fee statistics for the tickets included in the specified block. The RPC client is used to fetch raw transaction details need to compute the fee for each sstx.

func FeeRateInfoBlock added in v0.3.2

func FeeRateInfoBlock(block *dcrutil.Block, c RawTransactionGetter) *dcrjson.FeeInfoBlock

FeeRateInfoBlock computes ticket fee rate statistics for the tickets included in the specified block. The RPC client is used to fetch raw transaction details need to compute the fee rate for each sstx.

func GetDifficultyRatio added in v0.3.2

func GetDifficultyRatio(bits uint32, params *chaincfg.Params) float64

GetDifficultyRatio returns the proof-of-work difficulty as a multiple of the minimum difficulty using the passed bits field from the header of a block.

func HashInSlice

func HashInSlice(h chainhash.Hash, list []chainhash.Hash) bool

HashInSlice determines if a hash exists in a slice of hashes.

func IncludesStakeTx

func IncludesStakeTx(txHash *chainhash.Hash, block *dcrutil.Block) (int, int8)

IncludesStakeTx checks if a block contains a stake transaction hash

func IncludesTx

func IncludesTx(txHash *chainhash.Hash, block *dcrutil.Block) (int, int8)

IncludesTx checks if a block contains a transaction hash

func MedianAmount

func MedianAmount(s []dcrutil.Amount) dcrutil.Amount

MedianAmount gets the median Amount from a slice of Amounts

func MedianCoin

func MedianCoin(s []float64) float64

MedianCoin gets the median DCR from a slice of float64s

func RevokedTicketsInBlock

func RevokedTicketsInBlock(bl *dcrutil.Block) []chainhash.Hash

RevokedTicketsInBlock finds all the revoked tickets in the block.

func SSTXInBlock added in v0.3.2

func SSTXInBlock(block *dcrutil.Block, c RawTransactionGetter) []*dcrutil.Tx

SSTXInBlock gets a slice containing all of the SSTX mined in a block

func TicketsInBlock

func TicketsInBlock(bl *dcrutil.Block) []chainhash.Hash

TicketsInBlock finds all the new tickets in the block.

func TicketsSpentInBlock

func TicketsSpentInBlock(bl *dcrutil.Block) []chainhash.Hash

TicketsSpentInBlock finds all the tickets spent in the block.

func TxhashInSlice

func TxhashInSlice(txs []*dcrutil.Tx, txHash *chainhash.Hash) *dcrutil.Tx

TxhashInSlice searches a slice of *dcrutil.Tx for a transaction with the hash txHash. If found, it returns the corresponding *Tx, otherwise nil.

func VotesInBlock

func VotesInBlock(bl *dcrutil.Block) []chainhash.Hash

VotesInBlock finds all the votes in the block.

Types

type BlockWatchedTx

type BlockWatchedTx struct {
	BlockHeight   int64
	TxsForAddress map[string][]*dcrutil.Tx
}

BlockWatchedTx contains, for a certain block, the transactions for certain watched addresses

type RawTransactionGetter added in v0.3.2

type RawTransactionGetter interface {
	GetRawTransaction(txHash *chainhash.Hash) (*dcrutil.Tx, error)
}

RawTransactionGetter is an interface satisfied by dcrrpcclient.Client, and required by functions that would otherwise require a dcrrpcclient.Client just for GetRawTransaction.

type TxAction

type TxAction int32

TxAction is what is happening to the transaction (mined or inserted into mempool).

const (
	TxMined TxAction = 1 << iota
	TxInserted
)

Valid values for TxAction

Jump to

Keyboard shortcuts

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