Documentation ¶
Index ¶
- Constants
- Variables
- func NewMnemonic(length int, language string) (string, error)
- func NewSeed(mnemonic, password, language string) ([]byte, error)
- func PathNumber(str string) uint32
- type Key
- func (k *Key) AddressBTC() (string, error)
- func (k *Key) AddressP2WPKH() (string, error)
- func (k *Key) AddressP2WPKHInP2SH() (string, error)
- func (k *Key) GetChildKey(opts ...Option) (*Key, error)
- func (k *Key) GetWallet(opts ...Option) (Wallet, error)
- func (k *Key) PrivateHex() string
- func (k *Key) PrivateWIF(compress bool) (string, error)
- func (k *Key) PublicHash() ([]byte, error)
- func (k *Key) PublicHex(compress bool) string
- type Option
- func Account(a uint32) Option
- func AddressIndex(a uint32) Option
- func Change(c uint32) Option
- func CoinType(c uint32) Option
- func Language(l string) Option
- func Mnemonic(m string) Option
- func Params(p *chaincfg.Params) Option
- func Password(p string) Option
- func Path(path string) Option
- func Purpose(p uint32) Option
- func Seed(s []byte) Option
- type Options
- type Wallet
Constants ¶
const ( English = "english" ChineseSimplified = "chinese_simplified" ChineseTraditional = "chinese_traditional" )
mnemonic language
const ( Zero uint32 = 0 ZeroQuote uint32 = 0x80000000 BTCToken uint32 = 0x10000000 ETHToken uint32 = 0x20000000 )
zero is deafult of uint32
const ( // https://github.com/satoshilabs/slips/blob/master/slip-0044.md#registered-coin-types BTC = ZeroQuote + 0 BTCTestnet = ZeroQuote + 1 LTC = ZeroQuote + 2 DOGE = ZeroQuote + 3 DASH = ZeroQuote + 5 ETH = ZeroQuote + 60 ETC = ZeroQuote + 61 BCH = ZeroQuote + 145 QTUM = ZeroQuote + 2301 TRON = ZeroQuote + 195 // btc token USDT = BTCToken + 1 // eth token IOST = ETHToken + 1 USDC = ETHToken + 2 )
wallet type from bip44
Variables ¶
var ( DefaultParams = &BTCParams // master key options DefaultPassword = "" DefaultLanguage = "" // child key options DefaultPurpose = ZeroQuote + 44 DefaultCoinType = BTC DefaultAccount = ZeroQuote DefaultChange = Zero DefaultAddressIndex = Zero )
default options
var ( BTCParams = chaincfg.MainNetParams BTCTestnetParams = chaincfg.TestNet3Params LTCParams = chaincfg.MainNetParams DOGEParams = chaincfg.MainNetParams DASHParams = chaincfg.MainNetParams BCHParams = chaincfg.MainNetParams QTUMParams = chaincfg.MainNetParams USDTParams = chaincfg.MainNetParams )
init net params
var (
ErrCoinTypeUnknow = errors.New("unknow coin type")
)
errors
Functions ¶
func NewMnemonic ¶
NewMnemonic creates a random mnemonic
Types ¶
type Key ¶
type Key struct { Opt *Options Extended *hdkeychain.ExtendedKey // for btc Private *btcec.PrivateKey Public *btcec.PublicKey // for eth PrivateECDSA *ecdsa.PrivateKey PublicECDSA *ecdsa.PublicKey }
Key struct
func (*Key) AddressBTC ¶
AddressBTC generate public key to btc style address
func (*Key) AddressP2WPKH ¶
AddressP2WPKH generate public key to p2wpkh style address
func (*Key) AddressP2WPKHInP2SH ¶
AddressP2WPKHInP2SH generate public key to p2wpkh nested within p2sh style address
func (*Key) GetChildKey ¶
GetChildKey return a key from master key params: Purpose, CoinType, Account, Change, AddressIndex, Path
func (*Key) GetWallet ¶
GetWallet return wallet from master key params: Purpose, CoinType, Account, Change, AddressIndex, Path
func (*Key) PrivateHex ¶
PrivateHex generate private key to string by hex
func (*Key) PrivateWIF ¶
PrivateWIF generate private key to string by wif
func (*Key) PublicHash ¶
PublicHash generate public key by hash160
type Option ¶
type Option func(*Options)
Option of key