bchutil

package
v0.14.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2022 License: GPL-3.0, MIT Imports: 2 Imported by: 0

README

bchutil

Bitcoin Cash Utilities

Contains the bitcoin cash signing algorithm and some protocol configuration. This package removes the need to use a fork of btcd when working with Bitcoin Cash.

Documentation

Index

Constants

View Source
const CHARSET string = "qpzry9x8gf2tvdw0s3jn54khce6mua7l"

*

  • The cashaddr character set for encoding.

Variables

View Source
var (
	// ErrChecksumMismatch describes an error where decoding failed due
	// to a bad checksum.
	ErrChecksumMismatch = errors.New("checksum mismatch")

	Prefix = "bitcoincash"
)
View Source
var CHARSET_REV = [128]int8{}/* 128 elements not displayed */

*

  • The cashaddr character set for decoding.

Functions

func Cat

func Cat(x, y data) data

*

  • Concatenate two byte arrays.

func CheckEncodeCashAddress

func CheckEncodeCashAddress(input []byte, prefix string, t AddressType) string

func CreateChecksum

func CreateChecksum(prefix string, payload data) data

*

  • Create a checksum.

func DecodeCashAddress

func DecodeCashAddress(str string) (string, data, error)

*

  • Decode a cashaddr string.

func Encode

func Encode(prefix string, payload data) string

*

  • Encode a cashaddr string.

func ExpandPrefix

func ExpandPrefix(prefix string) data

*

  • Expand the address prefix for the checksum computation.

func LowerCase

func LowerCase(c byte) byte

*

  • Convert to lower case. *
  • Assume the input is a character.

func PolyMod

func PolyMod(v data) uint64

*

  • This function will compute what 8 5-bit values to XOR into the last 8 input
  • values, in order to make the checksum 0. These 8 values are packed together
  • in a single 40-bit integer. The higher bits correspond to earlier values.

func VerifyAddress added in v0.13.16

func VerifyAddress(addr string) error

DecodeAddress decodes the string encoding of an address and returns the Address if addr is a valid encoding for a known address type.

The bitcoin cash network the address is associated with is extracted if possible.

func VerifyChecksum

func VerifyChecksum(prefix string, payload data) bool

*

  • Verify a checksum.

Types

type AddressType

type AddressType int
const (
	P2PKH AddressType = 0
	P2SH  AddressType = 1
)

func CheckDecodeCashAddress

func CheckDecodeCashAddress(input string) (result []byte, prefix string, t AddressType, err error)

CheckDecode decodes a string that was encoded with CheckEncode and verifies the checksum.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL