doge

package
v0.1.0-beta2 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ECPrivKeyLen            = 32 // bytes.
	ECPubKeyCompressedLen   = 33 // bytes: [x02/x03][32-X] 2=even 3=odd
	ECPubKeyUncompressedLen = 65 // bytes: [x04][32-X][32-Y]
)
View Source
const (
	SerializedBip32KeyLength = 4 + 1 + 4 + 4 + 32 + 33
)

Variables

This section is empty.

Functions

func Base58Decode

func Base58Decode(str string) ([]byte, error)

func Base58DecodeCheck

func Base58DecodeCheck(str string) ([]byte, error)

func Base58Encode

func Base58Encode(bytes []byte) string

func Base58EncodeCheck

func Base58EncodeCheck(bytes []byte) string

CAUTION: appends the Checksum to `bytes` if it has sufficient capacity (4 bytes)

func Base58VerifyChecksum

func Base58VerifyChecksum(bytes []byte, str string) error

func DecodeECPrivKeyWIF

func DecodeECPrivKeyWIF(str string, chain *ChainParams) (ec_priv_key ECPrivKey, out_chain *ChainParams, err error)

chain is optional, will auto-detect if nil.

func ECKeyIsValid

func ECKeyIsValid(pk ECPrivKey) bool

func EncodeBip32WIF

func EncodeBip32WIF(key *Bip32Key) (string, error)

func EncodeECPrivKeyUncompressedWIF

func EncodeECPrivKeyUncompressedWIF(key ECPrivKey, chain *ChainParams) string

func EncodeECPrivKeyWIF

func EncodeECPrivKeyWIF(key ECPrivKey, chain *ChainParams) string

func ExtractECPrivKeyFromBip32

func ExtractECPrivKeyFromBip32(ext_key_wif string) (ec_privkey_wif string, err error)

Given a Bip32 Extended Private Key WIF, extract the WIF-encoded EC Private Key.

func GenerateP2PKHFromECPrivKeyWIF

func GenerateP2PKHFromECPrivKeyWIF(ec_priv_key_wif string) (p2pkh string, err error)

func Hash160

func Hash160(bytes []byte) []byte

func HexDecode

func HexDecode(str string) ([]byte, error)

func HexEncode

func HexEncode(bytes []byte) string

func IsValidHex

func IsValidHex(hex string) bool

func PubKeyToP2PKH

func PubKeyToP2PKH(key ECPubKeyCompressed, chain *ChainParams) string

func RIPEMD160

func RIPEMD160(bytes []byte) []byte

func ScriptToP2SH

func ScriptToP2SH(redeemScript []byte, chain *ChainParams) string

func ValidateP2PKH

func ValidateP2PKH(address string, chain *ChainParams) bool

func ValidateP2SH

func ValidateP2SH(address string, chain *ChainParams) bool

Types

type Bip32Key

type Bip32Key struct {
	// contains filtered or unexported fields
}

https://en.bitcoin.it/wiki/BIP_0032

func DecodeBip32WIF

func DecodeBip32WIF(extendedKey string, chain *ChainParams) (*Bip32Key, error)

chain is optional, will auto-detect if nil.

func (*Bip32Key) Clear

func (key *Bip32Key) Clear()

func (*Bip32Key) GetECPrivKey

func (key *Bip32Key) GetECPrivKey() ([]byte, error)

func (*Bip32Key) GetECPubKey

func (key *Bip32Key) GetECPubKey() []byte

type ChainParams

type ChainParams struct {
	ChainName string

	Bip32_WIF_PrivKey_Prefix string
	Bip32_WIF_PubKey_Prefix  string
	// contains filtered or unexported fields
}
var BitcoinMainChain ChainParams = ChainParams{
	ChainName: "btc_main",

	Bip32_WIF_PrivKey_Prefix: "xxxx",
	Bip32_WIF_PubKey_Prefix:  "xxxx",
	// contains filtered or unexported fields
}
var DogeMainNetChain ChainParams = ChainParams{
	ChainName: "doge_main",

	Bip32_WIF_PrivKey_Prefix: "dgpv",
	Bip32_WIF_PubKey_Prefix:  "dgub",
	// contains filtered or unexported fields
}
var DogeRegTestChain ChainParams = ChainParams{
	ChainName: "doge_regtest",

	Bip32_WIF_PrivKey_Prefix: "tprv",
	Bip32_WIF_PubKey_Prefix:  "tpub",
	// contains filtered or unexported fields
}
var DogeTestNetChain ChainParams = ChainParams{
	ChainName: "doge_test",

	Bip32_WIF_PrivKey_Prefix: "tprv",
	Bip32_WIF_PubKey_Prefix:  "tpub",
	// contains filtered or unexported fields
}

func ChainFromBip32Version

func ChainFromBip32Version(version uint32, allowNonDoge bool) *ChainParams

func ChainFromKeyBits

func ChainFromKeyBits(keyType KeyBits) *ChainParams

func ChainFromTestNetFlag

func ChainFromTestNetFlag(isTestNet bool) *ChainParams

func ChainFromWIFPrefix

func ChainFromWIFPrefix(bytes []byte, allowNonDoge bool) *ChainParams

CAUTION: the result is a best-guess based on the 'version byte' in the decoded WIF data. Do not rely on the returned ChainParams alone for validation: it will fall back on DogeTestNetChain for unknown version bytes (so verify the version byte or bip32-prefix as well)

func ChainFromWIFString

func ChainFromWIFString(wif string) *ChainParams

CAUTION: the result is a best-guess based on the 'version byte' in the WIF string. Do not rely on the returned ChainParams alone for validation: it will fall back on DogeTestNetChain for unknown version bytes (so verify the version byte or bip32-prefix as well)

type ECPrivKey

type ECPrivKey = []byte // 32 bytes.

func GenerateECPrivKey

func GenerateECPrivKey() (ECPrivKey, error)

type ECPubKeyCompressed

type ECPubKeyCompressed = []byte // 33 bytes with 0x02 or 0x03 prefix.

func ECPubKeyFromECPrivKey

func ECPubKeyFromECPrivKey(pk ECPrivKey) ECPubKeyCompressed

type ECPubKeyUncompressed

type ECPubKeyUncompressed = []byte // 65 bytes with 0x04 prefix.

type Hash256

type Hash256 = []byte

func DoubleSha256

func DoubleSha256(bytes []byte) Hash256

func Sha256

func Sha256(bytes []byte) Hash256

type KeyBits

type KeyBits = int // keyECPriv,keyECPub,keyBip32Priv,keyBip32Pub,dogeMainNet,dogeTestNet

func KeyBitsForChain

func KeyBitsForChain(chain *ChainParams) KeyBits

Jump to

Keyboard shortcuts

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