Documentation ¶
Index ¶
- Constants
- Variables
- func NewMnemonic(length int) (string, error)
- func NewSeed(mnemonic, password, language string) ([]byte, error)
- func SetLanguage(language string)
- type Key
- func (k *Key) AddressBCH() (string, error)
- func (k *Key) AddressBTC() (string, error)
- func (k *Key) AddressP2PKH() (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 Purpose(p uint32) Option
- func Seed(s []byte) Option
- type Options
- type Wallet
Constants ¶
const ( English = "english" ChineseSimplified = "chinese_simplified" ChineseTraditional = "chinese_traditional" JAPANESE = "Japanese" ITALIAN = "Italian" KOREAN = "Korean" SPANISH = "Spanish" FRENCH = "French" )
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 BTC_TESTNET = ZeroQuote + 1 LTC = ZeroQuote + 2 DOGE = ZeroQuote + 3 DASH = ZeroQuote + 5 ETH = ZeroQuote + 60 ETC = ZeroQuote + 61 BCH = ZeroQuote + 145 QTUM = ZeroQuote + 2301 WICC = ZeroQuote + 99999 WICC_TESTNET = ZeroQuote + 999999 // btc token USDT = BTCToken + 1 // eth token IOST = ETHToken + 1 USDC = ETHToken + 2 )
wallet type from bip44
Variables ¶
var ( DefaultParams = &chaincfg.MainNetParams // master key options DefaultPassword = "" DefaultLanguage = "" // child key options DefaultPurpose = ZeroQuote + 44 DefaultCoinType = BTC DefaultAccount = ZeroQuote DefaultChange = Zero DefaultAddressIndex = Zero //BIP49 隔离见证 BIP49Purpose = ZeroQuote + 49 )
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 WICCParams = chaincfg.MainNetParams WICCTestnetParams = chaincfg.MainNetParams )
init net params
var (
ErrCoinTypeUnknow = errors.New("unknow coin type")
)
errors
Functions ¶
func NewMnemonic ¶
NewMnemonic creates a random mnemonic Return the English Mnemonic default
func SetLanguage ¶
func SetLanguage(language string)
Types ¶
type Key ¶
type Key struct { Extended *hdkeychain.ExtendedKey // for btc Private *btcec.PrivateKey Public *btcec.PublicKey // for eth PrivateECDSA *ecdsa.PrivateKey PublicECDSA *ecdsa.PublicKey //The flag for ETH Ledger Wallet Path: m/44'/60'/0'/0 IsLedger bool // contains filtered or unexported fields }
Key struct
func (*Key) AddressBCH ¶
AddressBCH generate public key to bch style address
func (*Key) AddressBTC ¶
AddressBTC generate public key to btc style address
func (*Key) AddressP2PKH ¶
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