Documentation ¶
Index ¶
- Constants
- func Base58Decode(str string) ([]byte, error)
- func Base58DecodeCheck(str string) ([]byte, error)
- func Base58Encode(bytes []byte) string
- func Base58EncodeCheck(bytes []byte) string
- func Base58VerifyChecksum(bytes []byte, str string) error
- func DecodeECPrivKeyWIF(str string, chain *ChainParams) (ec_priv_key ECPrivKey, out_chain *ChainParams, err error)
- func ECKeyIsValid(pk ECPrivKey) bool
- func EncodeBip32WIF(key *Bip32Key) (string, error)
- func EncodeECPrivKeyUncompressedWIF(key ECPrivKey, chain *ChainParams) string
- func EncodeECPrivKeyWIF(key ECPrivKey, chain *ChainParams) string
- func ExtractECPrivKeyFromBip32(ext_key_wif string) (ec_privkey_wif string, err error)
- func GenerateP2PKHFromECPrivKeyWIF(ec_priv_key_wif string) (p2pkh string, err error)
- func Hash160(bytes []byte) []byte
- func HexDecode(str string) ([]byte, error)
- func HexEncode(bytes []byte) string
- func IsValidHex(hex string) bool
- func PubKeyToP2PKH(key ECPubKeyCompressed, chain *ChainParams) string
- func RIPEMD160(bytes []byte) []byte
- func ScriptToP2SH(redeemScript []byte, chain *ChainParams) string
- func ValidateP2PKH(address string, chain *ChainParams) bool
- func ValidateP2SH(address string, chain *ChainParams) bool
- type Bip32Key
- type ChainParams
- func ChainFromBip32Version(version uint32, allowNonDoge bool) *ChainParams
- func ChainFromKeyBits(keyType KeyBits) *ChainParams
- func ChainFromTestNetFlag(isTestNet bool) *ChainParams
- func ChainFromWIFPrefix(bytes []byte, allowNonDoge bool) *ChainParams
- func ChainFromWIFString(wif string) *ChainParams
- type ECPrivKey
- type ECPubKeyCompressed
- type ECPubKeyUncompressed
- type Hash256
- type KeyBits
Constants ¶
const ( ECPrivKeyLen = 32 // bytes. ECPubKeyCompressedLen = 33 // bytes: [x02/x03][32-X] 2=even 3=odd ECPubKeyUncompressedLen = 65 // bytes: [x04][32-X][32-Y] )
const (
SerializedBip32KeyLength = 4 + 1 + 4 + 4 + 32 + 33
)
Variables ¶
This section is empty.
Functions ¶
func Base58Decode ¶
func Base58DecodeCheck ¶
func Base58Encode ¶
func Base58EncodeCheck ¶
CAUTION: appends the Checksum to `bytes` if it has sufficient capacity (4 bytes)
func Base58VerifyChecksum ¶
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 EncodeBip32WIF ¶
func EncodeECPrivKeyUncompressedWIF ¶
func EncodeECPrivKeyUncompressedWIF(key ECPrivKey, chain *ChainParams) string
func EncodeECPrivKeyWIF ¶
func EncodeECPrivKeyWIF(key ECPrivKey, chain *ChainParams) string
func ExtractECPrivKeyFromBip32 ¶
Given a Bip32 Extended Private Key WIF, extract the WIF-encoded EC Private Key.
func IsValidHex ¶
func PubKeyToP2PKH ¶
func PubKeyToP2PKH(key ECPubKeyCompressed, chain *ChainParams) string
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) GetECPrivKey ¶
func (*Bip32Key) GetECPubKey ¶
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 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 KeyBits ¶
type KeyBits = int // keyECPriv,keyECPub,keyBip32Priv,keyBip32Pub,dogeMainNet,dogeTestNet
func KeyBitsForChain ¶
func KeyBitsForChain(chain *ChainParams) KeyBits