keys

package
v0.0.0-...-27e5b0e Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2022 License: Apache-2.0 Imports: 15 Imported by: 8

Documentation

Index

Constants

View Source
const (
	AddrTypeP2pkhOrP2sh = "p2pkh-or-p2sh" // mainnet: [xpub, xprv], testnet: [tpub, tprv]
	AddrTypeP2wpkhP2sh  = "p2wpkh-p2sh"   // mainnet: [ypub, yprv], testnet: [upub, uprv]
	AddrTypeP2wshP2sh   = "p2wsh-p2sh"    // mainnet: [Ypub, Yprv], testnet: [Upub, Uprv]
	AddrTypeP2wpkh      = "p2wpkh"        // mainnet: [zpub, zprv], testnet: [vpub, vprv]
	AddrTypeP2wsh       = "p2wsh"         // mainnet: [Zpub, Zprv], testnet: [Vpub, Vprv]

	AddrTypeLegacy           = "legacy"            // same as AddrTypeP2pkhOrP2sh, xpub, xprv etc.
	AddrTypeP2sh             = "p2sh"              // same as AddrTypeP2wpkhP2sh, ypub, yprv etc.
	AddrTypeSegWitCompatible = "segwit-compatible" // same as AddrTypeP2wpkhP2sh, ypub, yprv etc.
	AddrTypeSegWitNative     = "segwit-native"     // same as AddrTypeP2wpkh, zpub, zprv etc.
	AddrTypeBech32           = "bech32"            // same as AddrTypeP2wpkh, zpub, zprv etc.
	AddrTypeBip32            = "bip32"             // same as AddrTypeLegacy xpub, xprv etc.
	AddrTypeBip44            = "bip44"             // same as AddrTypeLegacy xpub, xprv etc.
	AddrTypeBip49            = "bip49"             // same as AddrTypeSegWitCompatible ypub, yprv etc.
	AddrTypeBip84            = "bip84"             // same as AddrTypeSegWitNative zpub, zprv etc.
)

https://electrum.readthedocs.io/en/latest/xpub_version_bytes.html#specification

View Source
const (
	Ypub = "0295b43f"
	Yprv = "0295b005"
	Upub = "024289ef"
	Uprv = "024285b5"

	Zpub = "02aa7ed3"
	Zprv = "02aa7a99"
	Vpub = "02575483"
	Vprv = "02575048"
)

key versions

View Source
const (
	BigN = "/////////////////////rqu3OavSKA7v9JejNA2QUE="
	BigZ = "0"
)
View Source
const (
	NetworkTypeMainnet = "mainnet"
	NetworkTypeTestnet = "testnet"
)
View Source
const (
	KeyTypePub = "pub"
	KeyTypePrv = "prv"
)
View Source
const (
	KeyFormatB58 = "base58"
	KeyFormatHex = "hex"
)
View Source
const (
	CoinTypeBtc = "btc"
)

Variables

This section is empty.

Functions

func IsValidBase58String

func IsValidBase58String(input string) bool

IsValidBase58String checks if all chars in input string belong to valid base58 char set

func Prompt

func Prompt(w io.Writer) error

func Read

func Read(r io.Reader) (string, error)

func Validate

func Validate(keyString string) error

Types

type Config

type Config struct {
	Seed           []byte
	Network        string
	DerivationPath string
	AddrType       string
}

type Key

type Key struct {
	Seed           string `json:"seed,omitempty" yaml:"seed,omitempty"`
	XPrv           string `json:"xPrv,omitempty" yaml:"xPrv,omitempty"`
	XPub           string `json:"xPub,omitempty" yaml:"xPub,omitempty"`
	PubKeyHex      string `json:"pubKeyHex,omitempty" yaml:"pubKeyHex,omitempty"`
	PrvKeyWif      string `json:"prvKeyWif,omitempty" yaml:"prvKeyWif,omitempty"`
	Addr           string `json:"addr,omitempty" yaml:"addr,omitempty"`
	AddrType       string `json:"addrType,omitempty" yaml:"addrType,omitempty"`
	DerivationPath string `json:"derivationPath,omitempty" yaml:"derivationPath,omitempty"`
	CoinType       string `json:"coinType,omitempty" yaml:"coinType,omitempty"`
	Network        string `json:"network,omitempty" yaml:"network,omitempty"`
	// contains filtered or unexported fields
}

Key represents BIP32 key components that are presented to the user

func DecodeExtendedKey

func DecodeExtendedKey(keyString string) (*Key, error)

func DecodePrivateWifKey

func DecodePrivateWifKey(keyString string) (*Key, error)

func DecodePublicHex

func DecodePublicHex(keyString string) (*Key, error)

func Derive

func Derive(keyString string, derivationPath string) (*Key, error)

func New

func New(config *Config) (*Key, error)

New generates a new key pair with a seed. The derivation paths can be successive derivation indices such as m, 0, 0h etc. or can be provided as m/0/0h.

Jump to

Keyboard shortcuts

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