foxnut / go-hdwallet Goto Github PK
View Code? Open in Web Editor NEWA multi-cryptocurrency HD wallet implementated by Golang.
License: MIT License
A multi-cryptocurrency HD wallet implementated by Golang.
License: MIT License
Hi @miaolz123 . First I want to thank for this great code. Can you tell me , can I create and sign transactions offline? Thanks!
Hi, i'm try to generate address pool by mnemonic phrase (which i check with TrustWallet) and i got wrong address:
import (
"fmt"
"github.com/foxnut/go-hdwallet"
)
func main() {
mnemonic := "build twice play danger limit faculty weird coil target immune zero reform"
k, _ := hdwallet.NewKey(hdwallet.Mnemonic(mnemonic))
w, _ := k.GetWallet(hdwallet.CoinType(hdwallet.BTC))
addr1, _ := w.GetKey().AddressP2WPKH()
//expected bc1q99pp52svzq4fqkl6p4c7zjywmafqydgw0g7a2y
fmt.Println(addr1)
//actual bc1qqsjukgskejs6n80dkdkvk5pnlfsfj0fux9a99r
}
Installing with -u
option is not working, this is deps:
github.com/btcsuite/btcd v0.20.1-beta // indirect
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f // indirect
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d // indirect
github.com/cpacia/bchutil v0.0.0-20181003130114-b126f6a35b6c // indirect
github.com/ethereum/go-ethereum v1.9.13 // indirect
github.com/foxnut/go-hdwallet v0.0.0-20200602072018-8db9c730e77c // indirect
github.com/tyler-smith/go-bip39 v1.0.2 // indirect
golang.org/x/crypto v0.0.0-20200427165652-729f1e841bcc // indirect
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd // indirect
Hello. Is there a way to use already generated Private Key/Public Key to generate addresses, instead of use a mnemonic seed?
master, err := hdwallet.NewKey(
hdwallet.Mnemonic(cfg.Mnemonic),
hdwallet.Params(&chaincfg.Params{}),
)
if err != nil {
log.Fatal("initialize master wallet private key: ", err)
}
evmWallet, err := master.GetWallet(hdwallet.CoinType(hdwallet.ETH))
if err != nil {
log.Fatal("initialize ETH wallet: ", err)
}
...
signedTx, err := types.SignTx(blockchainTx, types.LatestSignerForChainID(chainID), evmWallet.GetKey().PrivateECDSA)
i got error with that code: private key curve is not secp256k1
Im getting an error when installing on MacBook:
robert@Roberts-MacBook-Air gocourse % sudo go get -v -u github.com/foxnut/go-hdwallet
github.com/foxnut/go-hdwallet (download)
github.com/btcsuite/btcd (download)
github.com/btcsuite/btclog (download)
github.com/btcsuite/btcutil (download)
get "golang.org/x/crypto/ripemd160": found meta tag get.metaImport{Prefix:"golang.org/x/crypto", VCS:"git", RepoRoot:"https://go.googlesource.com/crypto"} at //golang.org/x/crypto/ripemd160?go-get=1
get "golang.org/x/crypto/ripemd160": verifying non-authoritative meta tag
golang.org/x/crypto (download)
github.com/cpacia/bchutil (download)
github.com/ethereum/go-ethereum (download)
get "golang.org/x/crypto/sha3": found meta tag get.metaImport{Prefix:"golang.org/x/crypto", VCS:"git", RepoRoot:"https://go.googlesource.com/crypto"} at //golang.org/x/crypto/sha3?go-get=1
get "golang.org/x/crypto/sha3": verifying non-authoritative meta tag
github.com/tyler-smith/go-bip39 (download)
get "golang.org/x/crypto/pbkdf2": found meta tag get.metaImport{Prefix:"golang.org/x/crypto", VCS:"git", RepoRoot:"https://go.googlesource.com/crypto"} at //golang.org/x/crypto/pbkdf2?go-get=1
get "golang.org/x/crypto/pbkdf2": verifying non-authoritative meta tag
github.com/foxnut/go-hdwallet
github.com/foxnut/go-hdwallet
../src/github.com/foxnut/go-hdwallet/key.go:96:27: extended.Child undefined (type *hdkeychain.ExtendedKey has no field or method Child)
Due to outdated dependecies, it fails to install the main go-hdwallet
repositry. The cause of this issue stems from github.com/btcsuite/btcd/btcec/
which doesn't exists anymore. This repository is now updated and can be installed using $ go install -u -v github.com/btcsuite/btcd/btcec/v2
At the current stage this repository is not usable since, it doesn't even compile.
If you would like, I can open a pull request addressing these issues
mnemonic := "real town addict extend shoot name disagree vital turn live can tip"
master, err := hdwallet.NewKey(hdwallet.Mnemonic(mnemonic))
wallet, _ = master.GetWallet(hdwallet.CoinType(hdwallet.ETH))
pk, _ = wallet.PrivateKey()
got c64f0b3e510d03adef3f057d1814bdc8a7f904caafa6928550fc10670dcff031
wanted c29cd818232f40614691a58c9afcbd5518b539cb135d73b1d9e26d5f5f5dcbbe (https://iancoleman.io/bip39/)
hello
how can i custom this package to support multisig for hd wallets.
i mean how can i make HDM wallets by this package
Following the example in readme,
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)
}
wallet, _ := master.GetWallet(hdwallet.CoinType(hdwallet.BTCTestnet), hdwallet.AddressIndex(0))
address, _ := wallet.GetAddress()
addressP2WPKH, _ := wallet.GetKey().AddressP2WPKH()
addressP2WPKHInP2SH, _ := wallet.GetKey().AddressP2WPKHInP2SH()
fmt.Println("BTC: ", address, addressP2WPKH, addressP2WPKHInP2SH)
}
outputs
BTC: mz5otQWaaPmWEydGw9gjfaHxSKhHX6Fgj5 tb1qew503ut4u9xpe6gu0md2ymfa4nzx5s4uw7zm4v 2MzibkYjFqqAu9TYtK3SraqQTo226vrLD6L
but it seems wrong, as creating a BTCTestnet transaction (TX ID: 0ae7c88251d0a8bed462141fc1d4605370367069ccb27b77b970c51e1103f68d
) doesn't show up in wallet generated with the previous mnemonic seed
`
// zero is deafult of uint32
const (
Zero uint32 = 0
ZeroQuote uint32 = 0x80000000
BTCToken uint32 = 0x10000000
ETHToken uint32 = 0x20000000
)
// wallet type from bip44
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
// btc token
USDT = BTCToken + 1
// eth token
IOST = ETHToken + 1
USDC = ETHToken + 2
)
`
I can find coint wallet types in this link
https://github.com/satoshilabs/slips/blob/master/slip-0044.md#registered-coin-types
But I can not find USDT IOST USDC wallet type in the link above. Where do I find it?
Thank for great code
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.