modulepackage
0.0.0-20191010034122-e75effadd3a0
Repository: https://github.com/go-chain/go-hdwallet.git
Documentation: pkg.go.dev
# README
go-hdwallet
A multi-cryptocurrency HD wallet implementated by golang.
supported coins
- BTC
- LTC
- DOGE
- DASH
- ETH
- ETC
- BCH
- QTUM
- USDT
- IOST
- USDC
install
go get -v -u github.com/foxnut/go-hdwallet
example
package main
import (
"fmt"
"github.com/foxnut/go-hdwallet"
)
var (
mnemonic = "range sheriff try enroll deer over ten level bring display stamp recycle"
)
func main() {
master, err := hdwallet.NewKey(
hdwallet.Mnemonic(mnemonic),
)
if err != nil {
panic(err)
}
// BTC: 1AwEPfoojHnKrhgt1vfuZAhrvPrmz7Rh4
wallet, _ := master.GetWallet(hdwallet.CoinType(hdwallet.BTC), hdwallet.AddressIndex(1))
address, _ := wallet.GetAddress()
addressP2WPKH, _ := wallet.GetKey().AddressP2WPKH()
addressP2WPKHInP2SH, _ := wallet.GetKey().AddressP2WPKHInP2SH()
fmt.Println("BTC: ", address, addressP2WPKH, addressP2WPKHInP2SH)
// BCH: 1CSBT18sjcCwLCpmnnyN5iqLc46Qx7CC91
wallet, _ = master.GetWallet(hdwallet.CoinType(hdwallet.BCH))
address, _ = wallet.GetAddress()
addressBCH, _ := wallet.GetKey().AddressBCH()
fmt.Println("BCH: ", address, addressBCH)
// LTC: LLCaMFT8AKjDTvz1Ju8JoyYXxuug4PZZmS
wallet, _ = master.GetWallet(hdwallet.CoinType(hdwallet.LTC))
address, _ = wallet.GetAddress()
fmt.Println("LTC: ", address)
// DOGE: DHLA3rJcCjG2tQwvnmoJzD5Ej7dBTQqhHK
wallet, _ = master.GetWallet(hdwallet.CoinType(hdwallet.DOGE))
address, _ = wallet.GetAddress()
fmt.Println("DOGE:", address)
// ETH: 0x37039021cBA199663cBCb8e86bB63576991A28C1
wallet, _ = master.GetWallet(hdwallet.CoinType(hdwallet.ETH))
address, _ = wallet.GetAddress()
fmt.Println("ETH: ", address)
// ETC: 0x480C69E014C7f018dAbF17A98273e90f0b0680cf
wallet, _ = master.GetWallet(hdwallet.CoinType(hdwallet.ETC))
address, _ = wallet.GetAddress()
fmt.Println("ETC: ", address)
}
# Functions
Account set to options.
AddressIndex set to options.
Change set to options.
CoinType set to options.
No description provided by the author
No description provided by the author
异或方法.
Language set to options.
Mnemonic set to options.
NewKey creates a master key params: [Mnemonic], [Password], [Language], [Seed].
NewMnemonic creates a random mnemonic.
NewSeed creates a hashed seed.
Params set to options.
Password set to options.
Purpose set to options.
Seed set to options.
sha256之后hash160.
chainid转换.
# Constants
wallet type from bip44.
https://github.com/satoshilabs/slips/blob/master/slip-0044.md#registered-coin-types.
zero is deafult of uint32.
mnemonic language.
mnemonic language.
wallet type from bip44.
wallet type from bip44.
mnemonic language.
wallet type from bip44.
wallet type from bip44.
wallet type from bip44.
zero is deafult of uint32.
wallet type from bip44.
wallet type from bip44.
wallet type from bip44.
wallet type from bip44.
my add.
eth tokenIOST = ETHToken + 1 //remove.
btc token.
wallet type from bip44.
wallet type from bip44.
wallet type from bip44.
zero is deafult of uint32.
zero is deafult of uint32.
# Variables
init net params.
init net params.
init net params.
default options.
default options.
default options.
default options.
default options.
default options.
master key options.
child key options.
init net params.
errors.
init net params.
No description provided by the author
No description provided by the author
No description provided by the author
init net params.
init net params.
init net params.
No description provided by the author
init net params.
# Interfaces
Wallet interface.
# Type aliases
Option of key.