Documentation ¶
Index ¶
- Constants
- func BlockConsumesOutpointWithAddresses(block *dcrutil.Block, addrs map[string]TxAction, c RawTransactionGetter, ...) map[string][]*dcrutil.Tx
- func BlockReceivesToAddresses(block *dcrutil.Block, addrs map[string]TxAction, params *chaincfg.Params) map[string][]*dcrutil.Tx
- func BuildStakeTree(blocks map[int64]*dcrutil.Block, netParams *chaincfg.Params, ...) (database.DB, []int64, error)
- func DetermineTxTypeString(msgTx *wire.MsgTx) string
- func FeeInfoBlock(block *dcrutil.Block) *dcrjson.FeeInfoBlock
- func FeeRateInfoBlock(block *dcrutil.Block) *dcrjson.FeeInfoBlock
- func GetDifficultyRatio(bits uint32, params *chaincfg.Params) float64
- func HashInSlice(h chainhash.Hash, list []chainhash.Hash) bool
- func IncludesStakeTx(txHash *chainhash.Hash, block *dcrutil.Block) (int, int8)
- func IncludesTx(txHash *chainhash.Hash, block *dcrutil.Block) (int, int8)
- func IsStakeTx(msgTx *wire.MsgTx) bool
- func MedianAmount(s []dcrutil.Amount) dcrutil.Amount
- func MedianCoin(s []float64) float64
- func MsgTxFromHex(txhex string) *wire.MsgTx
- func OutPointAddresses(outPoint *wire.OutPoint, c RawTransactionGetter, params *chaincfg.Params) ([]string, error)
- func OutPointAddressesFromString(txid string, index uint32, tree int8, c RawTransactionGetter, ...) ([]string, error)
- func RevokedTicketsInBlock(bl *dcrutil.Block) []chainhash.Hash
- func SSGenVoteBits(tx *wire.MsgTx) (uint16, error)
- func SSGenVoteChoices(tx *wire.MsgTx, params *chaincfg.Params) (BlockValidation, uint32, uint16, []*VoteChoice, error)
- func SSTXInBlock(block *dcrutil.Block) []*dcrutil.Tx
- func TicketTxnsInBlock(bl *dcrutil.Block) ([]chainhash.Hash, []*dcrutil.Tx)
- func TicketsInBlock(bl *dcrutil.Block) ([]chainhash.Hash, []*wire.MsgTx)
- func TicketsSpentInBlock(bl *dcrutil.Block) []chainhash.Hash
- func TotalVout(vouts []dcrjson.Vout) dcrutil.Amount
- func TxFee(msgTx *wire.MsgTx) dcrutil.Amount
- func TxFeeRate(msgTx *wire.MsgTx) (dcrutil.Amount, dcrutil.Amount)
- func TxhashInSlice(txs []*dcrutil.Tx, txHash *chainhash.Hash) *dcrutil.Tx
- func VoteBitsInBlock(block *dcrutil.Block) []blockchain.VoteVersionTuple
- func VoteVersion(pkScript []byte) uint32
- func VotesInBlock(bl *dcrutil.Block) []chainhash.Hash
- type BlockValidation
- type BlockWatchedTx
- type RawTransactionGetter
- type TxAction
- type VoteChoice
Constants ¶
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 required 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 *rpcclient.Client, poolRequiredHeight int64, DBName ...string) (database.DB, []int64, error)
BuildStakeTree returns a database with a stake tree
func DetermineTxTypeString ¶ added in v0.8.0
DetermineTxTypeString returns a string representing the transaction type given a wire.MsgTx struct
func FeeInfoBlock ¶ added in v0.3.2
func FeeInfoBlock(block *dcrutil.Block) *dcrjson.FeeInfoBlock
FeeInfoBlock computes ticket fee statistics for the tickets included in the specified block.
func FeeRateInfoBlock ¶ added in v0.3.2
func FeeRateInfoBlock(block *dcrutil.Block) *dcrjson.FeeInfoBlock
FeeRateInfoBlock computes ticket fee rate statistics for the tickets included in the specified block.
func GetDifficultyRatio ¶ added in v0.3.2
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 ¶
HashInSlice determines if a hash exists in a slice of hashes.
func IncludesStakeTx ¶
IncludesStakeTx checks if a block contains a stake transaction hash
func IncludesTx ¶
IncludesTx checks if a block contains a transaction hash
func MedianAmount ¶
MedianAmount gets the median Amount from a slice of Amounts
func MedianCoin ¶
MedianCoin gets the median DCR from a slice of float64s
func MsgTxFromHex ¶ added in v0.8.0
MsgTxFromHex returns a wire.MsgTx struct built from the transaction hex string
func OutPointAddresses ¶ added in v0.8.0
func OutPointAddresses(outPoint *wire.OutPoint, c RawTransactionGetter, params *chaincfg.Params) ([]string, error)
OutPointAddresses gets the addresses paid to by a transaction output.
func OutPointAddressesFromString ¶ added in v0.8.0
func OutPointAddressesFromString(txid string, index uint32, tree int8, c RawTransactionGetter, params *chaincfg.Params) ([]string, error)
OutPointAddressesFromString is the same as OutPointAddresses, but it takes the outpoint as the tx string, vout index, and tree.
func RevokedTicketsInBlock ¶
RevokedTicketsInBlock finds all the revoked tickets in the block.
func SSGenVoteBits ¶ added in v0.8.0
SSGenVoteBits returns the VoteBits of txOut[1] of a ssgen tx
func SSGenVoteChoices ¶ added in v0.8.0
func SSGenVoteChoices(tx *wire.MsgTx, params *chaincfg.Params) (BlockValidation, uint32, uint16, []*VoteChoice, error)
SSGenVoteChoices 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.
func SSTXInBlock ¶ added in v0.3.2
SSTXInBlock gets a slice containing all of the SSTX mined in a block
func TicketTxnsInBlock ¶ added in v0.8.1
TicketTxnsInBlock finds all the new tickets in the block.
func TicketsInBlock ¶
TicketsInBlock finds all the new tickets in the block.
func TicketsSpentInBlock ¶
TicketsSpentInBlock finds all the tickets spent in the block.
func TxFeeRate ¶ added in v0.8.0
TxFeeRate computes and returns the fee rate in DCR/KB for a given tx
func TxhashInSlice ¶
TxhashInSlice searches a slice of *dcrutil.Tx for a transaction with the hash txHash. If found, it returns the corresponding *Tx, otherwise nil.
func VoteBitsInBlock ¶ added in v0.8.0
func VoteBitsInBlock(block *dcrutil.Block) []blockchain.VoteVersionTuple
VoteBitsInBlock returns a list of vote bits for the votes in a block
func VoteVersion ¶ added in v1.0.0
Types ¶
type BlockValidation ¶ added in v0.8.0
type BlockValidation struct { // Hash is the hash of the block being targeted (in)validated Hash chainhash.Hash // Height is the height of the block Height int64 // Validity indicates the vote is to validate (true) or invalidate (false) // the block. Validity bool }
BlockValidation models the block validation indicated by an ssgen (vote) transaction.
func SSGenVoteBlockValid ¶ added in v0.8.0
func SSGenVoteBlockValid(msgTx *wire.MsgTx) (BlockValidation, uint16, error)
SSGenVoteBlockValid 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.
type BlockWatchedTx ¶
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 rpcclient.Client, and required by functions that would otherwise require a rpcclient.Client just for GetRawTransaction.
type TxAction ¶
type TxAction int32
TxAction is what is happening to the transaction (mined or inserted into mempool).
type VoteChoice ¶ added in v0.8.0
type VoteChoice struct { // Single unique word identifying the vote. ID string `json:"id"` // Longer description of what the vote is about. Description string `json:"description"` // Usable bits for this vote. Mask uint16 `json:"mask"` // VoteVersion and VoteIndex specify which vote item is referenced by this // VoteChoice (i.e. chaincfg.Params.Deployments[VoteVersion][VoteIndex]). VoteVersion uint32 `json:"vote_version"` VoteIndex int `json:"vote_index"` // ChoiceIdx indicates the corresponding element in the vote item's []Choice ChoiceIdx int `json:"choice_index"` // Choice is the selected choice for the specified vote item Choice *chaincfg.Choice `json:"choice"` }
VoteChoice 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].