Giter Site home page Giter Site logo

go-hdwallet's People

Contributors

miaolz123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

go-hdwallet's Issues

Incorrect address by mnemonic phrase (BTC)

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

Supporting Private/Public key

Hello. Is there a way to use already generated Private Key/Public Key to generate addresses, instead of use a mnemonic seed?

Sign ETH transactions

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

Installation failed.

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)

Outdated btcd/btcec dependency

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

Invalid private key generation

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/)

support multisig HD wallet

hello
how can i custom this package to support multisig for hd wallets.
i mean how can i make HDM wallets by this package

Issue with BTCTestnet

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

About wallet types

`
// 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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.