Categorygithub.com/classzz/czzutil
modulepackage
0.0.0-20210331065242-323b27c6239d
Repository: https://github.com/classzz/czzutil.git
Documentation: pkg.go.dev

# README

czzutil

Build Status ISC License GoDoc

Package czzutil provides bitcoin cash-specific convenience functions and types. A comprehensive suite of tests is provided to ensure proper functionality. See test_coverage.txt for the gocov coverage report. Alternatively, if you are running a POSIX OS, you can run the cov_report.sh script for a real-time report.

This package was developed for czzd, an alternative full-node implementation of bitcoin cash Although it was primarily written for czzd, 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/classzz/czzutil

License

Package czzutil is licensed under the copyfree ISC License.

# Packages

Package base58 provides an API for working with modified base58 and Base58Check encodings.
Package bech32 provides a Go implementation of the bech32 format specified in BIP 173.
No description provided by the author
No description provided by the author
Package gcs provides an API for building and using a Golomb-coded set filter.
Package hdkeychain provides an API for bitcoin hierarchical deterministic extended keys (BIP0032).
No description provided by the author
No description provided by the author
Package txsort provides the transaction sorting according to BIP 69.

# 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.
DecodeCashAddress decodes a cashaddr string and returns the prefix and data element.
DecodeWIF creates a new WIF structure by decoding the string encoding of the import format.
Hash160 calculates the hash ripemd160(sha256(b)).
NewAddressPubKey returns a new AddressPubKey which represents a pay-to-pubkey address.
NewAddressPubKeyHash returns a new AddressPubKeyHash.
NewAddressScriptHash returns a new AddressScriptHash.
NewAddressScriptHashFromHash returns a new AddressScriptHash.
NewAmount creates an Amount from a floating point value representing some value in bitcoin.
NewBlock returns a new instance of a bitcoin block given an underlying wire.MsgBlock.
NewBlockFromBlockAndBytes returns a new instance of a bitcoin block given an underlying wire.MsgBlock and the serialized bytes for it.
NewBlockFromBytes returns a new instance of a bitcoin block given the serialized bytes.
NewBlockFromReader returns a new instance of a bitcoin block given a Reader to deserialize the block.
NewLegacyAddressPubKeyHash returns a new AddressPubKeyHash in the legacy format.
NewLegacyAddressScriptHash returns a new LegacyAddressScriptHash.
NewLegacyAddressScriptHashFromHash returns a new AddressScriptHash.
NewTLSCertPair returns a new PEM-encoded x.509 certificate pair based on a 521-bit ECDSA private key.
NewTx returns a new instance of a bitcoin transaction given an underlying wire.MsgTx.
NewTxFromBytes returns a new instance of a bitcoin transaction given the serialized bytes.
NewTxFromReader returns a new instance of a bitcoin 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.

# Constants

AddrTypePayToPubKeyHash is the numeric identifier for a cashaddr PayToPubkeyHash address.
AddrTypePayToScriptHash is the numeric identifier for a cashaddr PayToPubkeyHash address.
These constants define various units used when describing a bitcoin monetary amount.
These constants define various units used when describing a bitcoin monetary amount.
These constants define various units used when describing a bitcoin monetary amount.
These constants define various units used when describing a bitcoin monetary amount.
These constants define various units used when describing a bitcoin monetary amount.
These constants define various units used when describing a bitcoin monetary amount.
BlockHeightUnknown is the value returned for a block height that is unknown.
Charset is the base32 character set for the cashaddr.
MaxSatoshi is the maximum transaction amount allowed in satoshi.
PKFCompressed indicates the pay-to-pubkey address format is a compressed public key.
PKFHybrid indicates the pay-to-pubkey address format is a hybrid public key.
PKFUncompressed indicates the pay-to-pubkey address format is an uncompressed public key.
SatoshiPerBitcent is the number of satoshi in one bitcoin cent.
SatoshiPerBitcoin is the number of satoshi in one bitcoin (1 BTC).
TxIndexUnknown is the value returned for a transaction index that is unknown.

# Variables

CharsetRev is the cashaddr character set for decoding.
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.
ErrInvalidFormat describes an error where decoding failed due to invalid version.
ErrMalformedPrivateKey describes an error where a WIF-encoded private key cannot be decoded due to being improperly formatted.
ErrUnknownAddressType describes an error where an address can not decoded as a specific address type due to the string encoding begining with an identifier byte unknown to any standard or registered (via chaincfg.Register) network.

# Structs

AddressPubKey is an Address for a 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.
Block defines a bitcoin block that provides easier and more efficient manipulation of raw blocks.
LegacyAddressPubKeyHash is an Address for a pay-to-pubkey-hash (P2PKH) transaction in the legacy format.
LegacyAddressScriptHash is an Address for a pay-to-script-hash (P2SH) transaction in legacy format.
Tx defines a bitcoin 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

AddressType represents the type of address and is used when encoding the cashaddr.
Amount represents the base bitcoin monetary unit (colloquially referred to as a `Satoshi').
AmountUnit describes a method of converting an Amount to something other than the base unit of a bitcoin.
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.