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) AddressBCH() (string, error)
- func (k *Key) AddressBNB(network string) (string, error)
- func (k *Key) AddressBTC() (string, error)
- func (k *Key) AddressFIL(network string) (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) PrivateHexSOL() 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 TRX = ZeroQuote + 195 BNB = ZeroQuote + 714 FIL = ZeroQuote + 461 SOL = ZeroQuote + 501 BSC = ZeroQuote + 9006 //币安智能链 // btc token USDT = BTCToken + 1 // eth token IOST = ETHToken + 1 USDC = ETHToken + 2 )
wallet type from bip44
const ( MAINNET = "mainnet" TESTNET = "testnet" )
network
Variables ¶
var ( DefaultParams = &BTCParams // master key options DefaultPassword = "" DefaultLanguage = "english" // 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 // for solana PublicKey common.PublicKey PrivateKey ed25519.PrivateKey }
Key struct
func (*Key) AddressBCH ¶
AddressBCH generate public key to bch style address
func (*Key) AddressBNB ¶
AddressBNB 生成bnb地址 network mainnet主网地址 testnet测试网地址
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) PrivateHexSOL ¶
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
Source Files ¶
- enum.go
- errors.go
- key.go
- mnemonic.go
- option.go
- params.go
- wallet.go
- wallet_bch.go
- wallet_bnb.go
- wallet_bsc.go
- wallet_btc.go
- wallet_btc_testnet.go
- wallet_dash.go
- wallet_doge.go
- wallet_etc.go
- wallet_eth.go
- wallet_fil.go
- wallet_iost.go
- wallet_ltc.go
- wallet_qtum.go
- wallet_sol.go
- wallet_trx.go
- wallet_usdc.go
- wallet_usdt.go