Categorygithub.com/decred/dcrd/dcrutil/v4
modulepackage
4.0.2
Repository: https://github.com/decred/dcrd.git
Documentation: pkg.go.dev

# README

dcrutil

Build Status ISC License Doc

Package dcrutil provides decred-specific convenience functions and types. A comprehensive suite of tests is provided to ensure proper functionality.

This package was developed for dcrd, a full-node implementation of Decred which is under active development by Company 0. Although it was primarily written for dcrd, this package has intentionally been designed so it can be used as a standalone package for any projects needing the functionality provided.

Installation and Updating

This package is part of the github.com/decred/dcrd/dcrutil/v4 module. Use the standard go tooling for working with modules to incorporate it.

License

Package dcrutil is licensed under the copyfree ISC License.

# Packages

Package txsort provides stable transaction sorting.

# Functions

AppDataDir returns an operating system specific directory to be used for storing application data for an application.
DecodeWIF creates a new WIF structure by decoding the string encoding of the import format which is required to be for the provided network.
GenerateBoolArray16 generates a BoolArray16 from a uint16 containing flags.
Hash160 calculates the hash ripemd160(hash256(b)).
IsFlagSet16 returns true/false for a flag at flag field 'flag'.
NewAmount creates an Amount from a floating point value representing some value in the currency.
NewBlock returns a new instance of a block given an underlying wire.MsgBlock.
NewBlockDeepCopy deep copies an entire block down to the wire components and returns the new block based off of this copy.
NewBlockDeepCopyCoinbase returns a new instance of a block given an underlying wire.MsgBlock, but makes a deep copy of the coinbase transaction since it's sometimes mutable.
NewBlockFromBlockAndBytes returns a new instance of a block given an underlying wire.MsgBlock and the serialized bytes for it.
NewBlockFromBytes returns a new instance of a block given the serialized bytes.
NewBlockFromReader returns a new instance of a block given a Reader to deserialize the block.
NewTx returns a new instance of a transaction given an underlying wire.MsgTx.
NewTxDeep returns a new instance of a transaction given an underlying wire.MsgTx.
NewTxDeepTxIns is used to deep copy a transaction, maintaining the old pointers to the TxOuts while replacing the old pointers to the TxIns with deep copies.
NewTxFromBytes returns a new instance of a transaction given the serialized bytes.
NewTxFromReader returns a new instance of a transaction given a Reader to deserialize the transaction.
NewWIF creates a new WIF structure to export an address and its private key as a string encoded in the Wallet Import Format.
SetFlag16 sets a bit flag at flag position 'flag' to bool 'b'.
VerifyMessage verifies that signature is a valid signature of message and was created using the secp256k1 private key for address.

# Constants

These constants define various units used when describing a coin monetary amount.
These constants define various units used when describing a coin monetary amount.
These constants define various units used when describing a coin monetary amount.
These constants define various units used when describing a coin monetary amount.
These constants define various units used when describing a coin monetary amount.
These constants define various units used when describing a coin monetary amount.
AtomsPerCent is the number of atomic units in one coin cent.
AtomsPerCoin is the number of atomic units in one coin.
BlockHeightUnknown is the value returned for a block height that is unknown.
Describes whether TxTreeRegular is valid.
Flag fields for uint16.
Flag fields for uint16.
Flag fields for uint16.
Flag fields for uint16.
Flag fields for uint16.
Flag fields for uint16.
Flag fields for uint16.
Flag fields for uint16.
Flag fields for uint16.
Flag fields for uint16.
Flag fields for uint16.
Flag fields for uint16.
Flag fields for uint16.
Flag fields for uint16.
Flag fields for uint16.
Flag fields for uint16.
MaxAmount is the maximum transaction amount allowed in atoms.
TxIndexUnknown is the value returned for a transaction index that is unknown.

# Variables

ErrChecksumMismatch describes an error where decoding failed due to a bad checksum.
ErrMalformedPrivateKey describes an error where a WIF-encoded private key cannot be decoded due to being improperly formatted.

# Structs

Block defines a cryptocurrency block that provides easier and more efficient manipulation of raw blocks.
Tx defines a transaction that provides easier and more efficient manipulation of raw transactions.
WIF contains the individual components described by the Wallet Import Format (WIF).

# Interfaces

AddressParams defines an interface that is used to provide the parameters required when encoding and decoding addresses.

# Type aliases

Amount represents the base coin monetary unit (colloquially referred to as an `Atom').
AmountSorter implements sort.Interface to allow a slice of Amounts to be sorted.
AmountUnit describes a method of converting an Amount to something other than the base unit of a coin.
BoolArray16 is a bool array that is generated from a uint16 containing flags.
ErrWrongWIFNetwork describes an error in which the provided WIF is not for the expected network.
Flags16 is the type for 2 bytes of flags; not really used except in the declaration below.
OutOfRangeError describes an error due to accessing an element that is out of range.