{"modulePath":"github.com/parallelcointeam/exploder","version":"v2.1.3+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package txhelpers\n\n## Constants\n\n```go\nconst (\n\n\t// DefaultStakeDbName is the default database name\n\tDefaultStakeDbName = \"ffldb_stake\"\n)\n```\n\n## Functions\n\n```go\nfunc BlockConsumesOutpointWithAddresses(block *dcrutil.Block, addrs map[string]TxAction,\n\tc RawTransactionGetter, params *chaincfg.Params) map[string][]*dcrutil.Tx\n```\nBlockConsumesOutpointWithAddresses 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 required to decode the script.\n\n```go\nfunc BlockReceivesToAddresses(block *dcrutil.Block, addrs map[string]TxAction,\n\tparams *chaincfg.Params) map[string][]*dcrutil.Tx\n```\nBlockReceivesToAddresses 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.\n\n```go\nfunc BuildStakeTree(blocks map[int64]*dcrutil.Block, netParams *chaincfg.Params,\n\tnodeClient *rpcclient.Client, poolRequiredHeight int64, DBName ...string) (database.DB, []int64, error)\n```\nBuildStakeTree returns a database with a stake tree\n\n```go\nfunc DetermineTxTypeString(msgTx *wire.MsgTx) string\n```\nDetermineTxTypeString returns a string representing the transaction type given a wire.MsgTx struct\n\n```go\nfunc FeeInfoBlock(block *dcrutil.Block) *dcrjson.FeeInfoBlock\n```\nFeeInfoBlock computes ticket fee statistics for the tickets included in the specified block.\n\n```go\nfunc FeeRateInfoBlock(block *dcrutil.Block) *dcrjson.FeeInfoBlock\n```\nFeeRateInfoBlock computes ticket fee rate statistics for the tickets included in the specified block.\n\n```go\nfunc FilterHashSlice(s []chainhash.Hash, doRemove func(h chainhash.Hash) bool) []chainhash.Hash\n```\nFilterHashSlice removes elements from the specified if the doRemove function evaluates to true for a given element. For example, given a slice of hashes called blackList that should be removed from the slice hashList:\n\n\thashList = FilterHashSlice(hashList, func(h chainhash.Hash) bool {\n\t return HashInSlice(h, blackList)\n\t})\n\n```go\nfunc GetDifficultyRatio(bits uint32, params *chaincfg.Params) float64\n```\nGetDifficultyRatio returns the proof-of-work difficulty as a multiple of the minimum difficulty using the passed bits field from the header of a block.\n\n```go\nfunc HashInSlice(h chainhash.Hash, list []chainhash.Hash) bool\n```\nHashInSlice determines if a hash exists in a slice of hashes.\n\n```go\nfunc IncludesStakeTx(txHash *chainhash.Hash, block *dcrutil.Block) (int, int8)\n```\nIncludesStakeTx checks if a block contains a stake transaction hash\n\n```go\nfunc IncludesTx(txHash *chainhash.Hash, block *dcrutil.Block) (int, int8)\n```\nIncludesTx checks if a block contains a transaction hash\n\n```go\nfunc IsStakeTx(msgTx *wire.MsgTx) bool\n```\nIsStakeTx indicates if the input MsgTx is a stake transaction.\n\n```go\nfunc MedianAmount(s []dcrutil.Amount) dcrutil.Amount\n```\nMedianAmount gets the median Amount from a slice of Amounts\n\n```go\nfunc MedianCoin(s []float64) float64\n```\nMedianCoin gets the median DCR from a slice of float64s\n\n```go\nfunc MsgTxFromHex(txhex string) (*wire.MsgTx, error)\n```\nMsgTxFromHex returns a wire.MsgTx struct built from the transaction hex string\n\n```go\nfunc OutPointAddresses(outPoint *wire.OutPoint, c RawTransactionGetter,\n\tparams *chaincfg.Params) ([]string, dcrutil.Amount, error)\n```\nOutPointAddresses gets the addresses paid to by a transaction output.\n\n```go\nfunc OutPointAddressesFromString(txid string, index uint32, tree int8,\n\tc RawTransactionGetter, params *chaincfg.Params) ([]string, error)\n```\nOutPointAddressesFromString is the same as OutPointAddresses, but it takes the outpoint as the tx string, vout index, and tree.\n\n```go\nfunc RevokedTicketsInBlock(bl *dcrutil.Block) []chainhash.Hash\n```\nRevokedTicketsInBlock finds all the revoked tickets in the block.\n\n```go\nfunc RewardsAtBlock(blockIdx int64, votes uint16, p *chaincfg.Params) (work, stake, tax int64)\n```\nRewardsAtBlock computes the PoW, PoS (per vote), and project fund subsidies at for the specified block index, assuming a certain number of votes.\n\n```go\nfunc SSGenVoteBits(tx *wire.MsgTx) (uint16, error)\n```\nSSGenVoteBits returns the VoteBits of txOut\\[1] of a ssgen tx\n\n```go\nfunc SSGenVoteChoices(tx *wire.MsgTx, params *chaincfg.Params) (BlockValidation, uint32, uint16, []*VoteChoice, error)\n```\nSSGenVoteChoices gets a ssgen's vote choices (block validity and any agendas). The vote's stake version, to which the vote choices correspond, and vote bits are also returned. Note that \\[]\\*VoteChoice may be an empty slice if there are no consensus deployments for the transaction's vote version. The error value may be non-nil if the tx is not a valid ssgen.\n\n```go\nfunc SSTXInBlock(block *dcrutil.Block) []*dcrutil.Tx\n```\nSSTXInBlock gets a slice containing all of the SSTX mined in a block\n\n```go\nfunc TicketTxnsInBlock(bl *dcrutil.Block) ([]chainhash.Hash, []*dcrutil.Tx)\n```\nTicketTxnsInBlock finds all the new tickets in the block.\n\n```go\nfunc TicketsInBlock(bl *dcrutil.Block) ([]chainhash.Hash, []*wire.MsgTx)\n```\nTicketsInBlock finds all the new tickets in the block.\n\n```go\nfunc TicketsSpentInBlock(bl *dcrutil.Block) []chainhash.Hash\n```\nTicketsSpentInBlock finds all the tickets spent in the block.\n\n```go\nfunc TotalOutFromMsgTx(msgTx *wire.MsgTx) dcrutil.Amount\n```\nTotalOutFromMsgTx computes the total value out of a MsgTx\n\n```go\nfunc TotalVout(vouts []dcrjson.Vout) dcrutil.Amount\n```\nTotalVout computes the total value of a slice of dcrjson.Vout\n\n```go\nfunc TxConsumesOutpointWithAddress(msgTx *wire.MsgTx, addr string,\n\tc VerboseTransactionGetter, params *chaincfg.Params) (prevOuts []PrevOut, prevTxs []*TxWithBlockData)\n```\nTxConsumesOutpointWithAddress checks a transaction for inputs that spend an outpoint paying to the given address. Returned are the identified input indexes and the corresponding previous outpoints determined.\n\n```go\nfunc TxFee(msgTx *wire.MsgTx) dcrutil.Amount\n```\nTxFee computes and returns the fee for a given tx\n\n```go\nfunc TxFeeRate(msgTx *wire.MsgTx) (dcrutil.Amount, dcrutil.Amount)\n```\nTxFeeRate computes and returns the fee rate in DCR/KB for a given tx\n\n```go\nfunc TxInvolvesAddress(msgTx *wire.MsgTx, addr string, c VerboseTransactionGetter,\n\tparams *chaincfg.Params) (outpoints []*wire.OutPoint,\n\tprevOuts []PrevOut, prevTxs []*TxWithBlockData)\n```\nTxInvolvesAddress checks the inputs and outputs of a transaction for involvement of the given address.\n\n```go\nfunc TxPaysToAddress(msgTx *wire.MsgTx, addr string,\n\tparams *chaincfg.Params) (outpoints []*wire.OutPoint)\n```\nTxPaysToAddress returns a slice of outpoints of a transaction which pay to specified address.\n\n```go\nfunc TxTree(msgTx *wire.MsgTx) int8\n```\nTxTree returns for a wire.MsgTx either wire.TxTreeStake or wire.TxTreeRegular depending on the type of transaction.\n\n```go\nfunc TxhashInSlice(txs []*dcrutil.Tx, txHash *chainhash.Hash) *dcrutil.Tx\n```\nTxhashInSlice searches a slice of \\*dcrutil.Tx for a transaction with the hash txHash. If found, it returns the corresponding \\*Tx, otherwise nil.\n\n```go\nfunc UltimateSubsidy(params *chaincfg.Params) int64\n```\nUltimateSubsidy computes the total subsidy over the entire subsidy distribution period of the network.\n\n```go\nfunc VoteBitsInBlock(block *dcrutil.Block) []stake.VoteVersionTuple\n```\nVoteBitsInBlock returns a list of vote bits for the votes in a block\n\n```go\nfunc VoteVersion(pkScript []byte) uint32\n```\nVoteVersion extracts the vote version from the input pubkey script.\n\n```go\nfunc VotesInBlock(bl *dcrutil.Block) []chainhash.Hash\n```\nVotesInBlock finds all the votes in the block.\n\n## Types\n\n```go\ntype AddressOutpoints struct {\n\tAddress   string\n\tOutpoints []*wire.OutPoint\n\tPrevOuts  []PrevOut\n\tTxnsStore map[chainhash.Hash]*TxWithBlockData\n}\n```\nAddressOutpoints collects spendable and spent transactions outpoints paying to a certain address. The transactions referenced by the outpoints are stored for quick access.\n\n```go\nfunc NewAddressOutpoints(address string) *AddressOutpoints\n```\nNewAddressOutpoints creates a new AddressOutpoints, initializing the transaction store/cache, and setting the address string.\n\n```go\nfunc (a *AddressOutpoints) Merge(ao *AddressOutpoints)\n```\nMerge concatenates the outpoints of two AddressOutpoints, and merges the transactions.\n\n```go\nfunc (a *AddressOutpoints) Update(Txns []*TxWithBlockData,\n\tOutpoints []*wire.OutPoint, PrevOutpoint []PrevOut)\n```\nUpdate appends the provided outpoints, and merges the transactions.\n\n```go\ntype BlockValidation struct {\n\t// Hash is the hash of the block being targeted (in)validated\n\tHash chainhash.Hash\n\n\t// Height is the height of the block\n\tHeight int64\n\n\t// Validity indicates the vote is to validate (true) or invalidate (false)\n\t// the block.\n\tValidity bool\n}\n```\nBlockValidation models the block validation indicated by an ssgen (vote) transaction.\n\n```go\nfunc SSGenVoteBlockValid(msgTx *wire.MsgTx) (BlockValidation, uint16, error)\n```\nSSGenVoteBlockValid determines if a vote transaction is voting yes or no to a block, and returns the votebits in case the caller wants to check agenda votes. The error return may be ignored if the input transaction is known to be a valid ssgen (vote), otherwise it should be checked.\n\n```go\ntype BlockWatchedTx struct {\n\tBlockHeight   int64\n\tTxsForAddress map[string][]*dcrutil.Tx\n}\n```\nBlockWatchedTx contains, for a certain block, the transactions for certain watched addresses\n\n```go\ntype PrevOut struct {\n\tTxSpending       chainhash.Hash\n\tInputIndex       int\n\tPreviousOutpoint *wire.OutPoint\n}\n```\nPrevOut contains a transaction input's previous outpoint, the Hash of the spending (following) transaction, and input index in the transaction.\n\n```go\ntype RawTransactionGetter interface {\n\tGetRawTransaction(txHash *chainhash.Hash) (*dcrutil.Tx, error)\n}\n```\nRawTransactionGetter is an interface satisfied by rpcclient.Client, and required by functions that would otherwise require a rpcclient.Client just for GetRawTransaction.\n\n```go\ntype TxAction int32\n```\nTxAction is what is happening to the transaction (mined or inserted into mempool).\n\n```go\nconst (\n\tTxMined TxAction = 1 \u003c\u003c iota\n\tTxInserted\n)\n```\nValid values for TxAction\n\n```go\ntype TxWithBlockData struct {\n\tTx          *wire.MsgTx\n\tBlockHeight int64\n\tBlockHash   string\n\tMemPoolTime int64\n}\n```\nTxWithBlockData contains a MsgTx and the block hash and height in which it was mined and Time it entered MemPool.\n\n```go\nfunc (t *TxWithBlockData) Confirmed() bool\n```\nConfirmed indicates if the transaction is confirmed (mined).\n\n```go\nfunc (t *TxWithBlockData) Hash() chainhash.Hash\n```\nHash returns the chainhash.Hash of the transaction.\n\n```go\ntype VerboseTransactionGetter interface {\n\tGetRawTransactionVerbose(txHash *chainhash.Hash) (*dcrjson.TxRawResult, error)\n}\n```\nVerboseTransactionGetter is an interface satisfied by rpcclient.Client, and required by functions that would otherwise require a rpcclient.Client just for GetRawTransactionVerbose.\n\n```go\ntype VoteChoice struct {\n\t// Single unique word identifying the vote.\n\tID string `json:\"id\"`\n\n\t// Longer description of what the vote is about.\n\tDescription string `json:\"description\"`\n\n\t// Usable bits for this vote.\n\tMask uint16 `json:\"mask\"`\n\n\t// VoteVersion and VoteIndex specify which vote item is referenced by this\n\t// VoteChoice (i.e. chaincfg.Params.Deployments[VoteVersion][VoteIndex]).\n\tVoteVersion uint32 `json:\"vote_version\"`\n\tVoteIndex   int    `json:\"vote_index\"`\n\n\t// ChoiceIdx indicates the corresponding element in the vote item's []Choice\n\tChoiceIdx int `json:\"choice_index\"`\n\n\t// Choice is the selected choice for the specified vote item\n\tChoice *chaincfg.Choice `json:\"choice\"`\n}\n```\nVoteChoice represents the choice made by a vote transaction on a single vote item in an agenda. The ID, Description, and Mask fields describe the vote item for which the choice is being made. Those are the initial fields in chaincfg.Params.Deployments\\[VoteVersion]\\[VoteIndex].\n\n","path":"github.com/parallelcointeam/exploder/txhelpers","name":"txhelpers","synopsis":"","isRedistributable":true}
