# README
dcrutil
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
$ go get -u github.com/decred/dcrd/dcrutil
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.
DecodeAddress decodes the string encoding of an address and returns the Address if addr is a valid encoding for a known address type.
DecodeWIF creates a new WIF structure by decoding the string encoding of the import format.
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'.
NewAddressEdwardsPubKey returns a new AddressEdwardsPubKey which represents a pay-to-pubkey address, using an Ed25519 pubkey.
NewAddressPubKey returns a new Address.
NewAddressPubKeyHash returns a new AddressPubKeyHash.
NewAddressScriptHash returns a new AddressScriptHash.
NewAddressScriptHashFromHash returns a new AddressScriptHash.
NewAddressSecpPubKey returns a new AddressSecpPubKey which represents a pay-to-pubkey address, using a secp256k1 pubkey.
NewAddressSecpPubKeyCompressed creates a new address using a compressed public key.
NewAddressSecSchnorrPubKey returns a new AddressSecpPubKey which represents a pay-to-pubkey address, using a secp256k1 pubkey.
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'.
# 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.
PKFCompressed indicates the pay-to-pubkey address format is a compressed public key.
PKFUncompressed indicates the pay-to-pubkey address format is an uncompressed public key.
TxIndexUnknown is the value returned for a transaction index that is unknown.
# Variables
ErrAddressCollision describes an error where an address can not be uniquely determined as either a pay-to-pubkey-hash or pay-to-script-hash address since the leading identifier is used for describing both address kinds, but for different networks.
ErrChecksumMismatch describes an error where decoding failed due to a bad checksum.
ErrInvalidPubKeyFormat indicates that a serialized pubkey is unusable as it is neither in the uncompressed or compressed format.
ErrMalformedPrivateKey describes an error where a WIF-encoded private key cannot be decoded due to being improperly formatted.
ErrMissingDefaultNet describes an error in DecodeAddress that attempts to decode an address without defining which network to decode for.
ErrUnknownAddressType describes an error where an address can not decoded as a specific address type due to the string encoding beginning with an identifier byte unknown to any standard or registered (via chaincfg.Register) network.
# Structs
AddressEdwardsPubKey is an Address for an Ed25519 pay-to-pubkey transaction.
AddressPubKeyHash is an Address for a pay-to-pubkey-hash (P2PKH) transaction.
AddressScriptHash is an Address for a pay-to-script-hash (P2SH) transaction.
AddressSecpPubKey is an Address for a secp256k1 pay-to-pubkey transaction.
AddressSecSchnorrPubKey is an Address for a secp256k1 pay-to-pubkey transaction.
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
Address is an interface type for any type of destination a transaction output may spend to.
# 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.
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.
PubKeyFormat describes what format to use for a pay-to-pubkey address.