GithubHelp home page GithubHelp logo

miguelmota / go-ethereum-hdwallet Goto Github PK

View Code? Open in Web Editor NEW
472.0 8.0 247.0 3.69 MB

Ethereum HD Wallet derivations in Go (golang)

Home Page: https://github.com/miguelmota/go-ethereum-hdwallet

License: MIT License

Makefile 2.45% Go 97.55%
ethereum hdwallet wallet blockchain bip32 bip39 bip44 bip38 golang mnemonic

go-ethereum-hdwallet's Introduction


logo


go-ethereum-hdwallet

Ethereum HD Wallet derivations from [mnemonic] seed in Go (golang). Implements the go-ethereum accounts.Wallet interface.

License Build Status Go Report Card GoDoc PRs Welcome

Install

go get -u github.com/miguelmota/go-ethereum-hdwallet

Documenation

https://godoc.org/github.com/miguelmota/go-ethereum-hdwallet

Getting started

package main

import (
	"fmt"
	"log"

	"github.com/miguelmota/go-ethereum-hdwallet"
)

func main() {
	mnemonic := "tag volcano eight thank tide danger coast health above argue embrace heavy"
	wallet, err := hdwallet.NewFromMnemonic(mnemonic)
	if err != nil {
		log.Fatal(err)
	}

	path := hdwallet.MustParseDerivationPath("m/44'/60'/0'/0/0")
	account, err := wallet.Derive(path, false)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(account.Address.Hex()) // 0xC49926C4124cEe1cbA0Ea94Ea31a6c12318df947

	path = hdwallet.MustParseDerivationPath("m/44'/60'/0'/0/1")
	account, err = wallet.Derive(path, false)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(account.Address.Hex()) // 0x8230645aC28A4EdD1b0B53E7Cd8019744E9dD559
}

Signing transaction

package main

import (
	"log"
	"math/big"

	"github.com/davecgh/go-spew/spew"
	"github.com/ethereum/go-ethereum/common"
	"github.com/ethereum/go-ethereum/core/types"
	"github.com/miguelmota/go-ethereum-hdwallet"
)

func main() {
	mnemonic := "tag volcano eight thank tide danger coast health above argue embrace heavy"
	wallet, err := hdwallet.NewFromMnemonic(mnemonic)
	if err != nil {
		log.Fatal(err)
	}

	path := hdwallet.MustParseDerivationPath("m/44'/60'/0'/0/0")
	account, err := wallet.Derive(path, true)
	if err != nil {
		log.Fatal(err)
	}

	nonce := uint64(0)
	value := big.NewInt(1000000000000000000)
	toAddress := common.HexToAddress("0x0")
	gasLimit := uint64(21000)
	gasPrice := big.NewInt(21000000000)
	var data []byte

	tx := types.NewTransaction(nonce, toAddress, value, gasLimit, gasPrice, data)
	signedTx, err := wallet.SignTx(account, tx, nil)
	if err != nil {
		log.Fatal(err)
	}

	spew.Dump(signedTx)
}

CLI

go install github.com/miguelmota/go-ethereum-hdwallet/cmd/geth-hdwallet@latest
$ geth-hdwallet -mnemonic "tag volcano eight thank tide danger coast health above argue embrace heavy" -path "m/44'/60'/0'/0/0"

public address: 0xC49926C4124cEe1cbA0Ea94Ea31a6c12318df947
private key: 63e21d10fd50155dbba0e7d3f7431a400b84b4c2ac1ee38872f82448fe3ecfb9

Test

make test

Contributing

Pull requests are welcome!

For contributions please create a new branch and submit a pull request for review.

License

Released under the MIT license.

© Miguel Mota

go-ethereum-hdwallet's People

Contributors

cypherhat avatar ggwpez avatar miguelmota avatar pnowosie avatar ryanleecode avatar teghnet avatar witoff 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  avatar  avatar

go-ethereum-hdwallet's Issues

not enough arguments in call to signedTx.AsMessage

Hi,

When I run go get -u ./... in my project, I go the following error:

../../go/pkg/mod/github.com/miguelmota/[email protected]/hdwallet.go:254:32: not enough arguments in call to signedTx.AsMessage
	have (types.EIP155Signer)
	want (types.Signer, *big.Int)
../../go/pkg/mod/github.com/miguelmota/[email protected]/hdwallet.go:289:32: not enough arguments in call to signedTx.AsMessage
	have (types.HomesteadSigner)
	want (types.Signer, *big.Int)

is there any reason for my package that I got the error?

BTC private key to address and balance check

I just stumbled on these your GitHub repo I was looking for a program that will help me convert my compressed Bitcoin private key to address and check the balance. Could you please help me update or create a python program that will help me convert my compressed private key to address and check the balance. The reason I needed this was to scan through a massive private key txt file and see if I can find my missing 6 characters private key. Please help me if I recover the wallet I will donate some BTC to you. Thanks

installation mac os. issue

Im getting an error while installing:

robert@Roberts-MacBook-Air gocourse % go get -u github.com/miguelmota/go-ethereum-hdwallet
github.com/miguelmota/go-ethereum-hdwallet
../src/github.com/miguelmota/go-ethereum-hdwallet/hdwallet.go:494:17: key.Child undefined (type *hdkeychain.ExtendedKey has no field or method Child)

Wallet is not an accounts.Wallet anymore

After my last MR (#13) was merged, i noticed that Wallet does not fulfill the accounts.Wallet interface from geth anymore.
This was not indented but slipped under the radar.

I will prepare another MR to fix it. The baseFee is not even used for signing but to verify the signature, which can also be done without it.
So my next MR (#16) will effectively revert #13, get rid of the AsMessage function by using Sender instead and add a type assertion.

Sorry for the inconvenience 🙏

duplicate symbol (macos)

some linker issue under MacOS

$ go run example.go 
# command-line-arguments
/usr/local/Cellar/go/1.10.1/libexec/pkg/tool/darwin_amd64/link: running clang failed: exit status 1
duplicate symbol _secp256k1GoPanicError in:

Unable to depend on this package because it uses btcec from btcd

In my go.mod, I depend on github.com/btcsuite/btcd v0.23.4. Perhaps this is a problem?

$ go mod tidy
go: finding module for package github.com/miguelmota/go-ethereum-hdwallet
go: found github.com/miguelmota/go-ethereum-hdwallet in github.com/miguelmota/go-ethereum-hdwallet v0.1.2
go: finding module for package github.com/btcsuite/btcd/btcec
go: github.com/dove-foundation/dove/bird/inttest tested by
        github.com/dove-foundation/dove/bird/inttest.test imports
        github.com/miguelmota/go-ethereum-hdwallet imports
        github.com/btcsuite/btcutil/hdkeychain imports
        github.com/btcsuite/btcd/btcec: module github.com/btcsuite/btcd@latest found (v0.23.4), but does not contain package github.com/btcsuite/btcd/btcec

question: Is FixIssue172 implementation opposite?

Hi, thanks for your library. I had a question regarding the FixIssue172 implementation

Here:

if w.fixIssue172 && key.IsAffectedByIssue172() {
key, err = key.Derive(n)
} else {
key, err = key.DeriveNonStandard(n)
}

You check whether the key was affected by the issue (and whether the user set the fix issue flag) and then use the standard derivation. Forgive me if I misunderstood this, but according to
// IMPORTANT: if you were previously using the Child method, this method is incompatible.
// The Child method had a BIP-32 standard compatibility issue. You have to check whether
// any hardened derivations in your derivation path are affected by this issue, via the
// IsAffectedByIssue172 method and migrate the wallet if so. This method does conform
// to the standard. If you need the old behavior, use DeriveNonStandard.
you would need to use the old behavior (DeriveNonStandard) in case it was affected by this issue. And use Derive for fresh/non-affected wallets.

As it is now you use the DeriveNonStandard by default, which is deprecated according to

// Deprecated: This is a non-standard derivation that is affected by issue #172.
// 1-of-256 hardened derivations will be wrong. See note in the Derive method
// and IsAffectedByIssue172.

Again, forgive me if I am missing something

Diffrent Privatekey

This is my mnemonic:foot virtual paddle notice elbow lock analyst electric broom tell wheel office
I found hdwallet derived diffrent privatekey use path "m/44'/2'/0'/0/0" with java version and other standard wallet

go.mod parse error, module name unmatch

why the module name is defined as module github.com/immutability-io/go-ethereum-hdwallet in your go.mod ? I think it should be module github.com/miguelmota/go-ethereum-hdwallet

Allow mnemonic with password

Hello @miguelmota

I think this awesome library will benefit having optional password in seed calculation.
This is smth I need in my code anyway, so I could open a PR here as well if you would like.

I'm thinking of extending this function:

func NewSeedFromMnemonic(mnemonic string) ([]byte, error) {

e.g. to keep backward compatibility

func NewSeedFromMnemonic(mnemonic string, passOpt ...string) ([]byte, error) {
	if mnemonic == "" {
		return nil, errors.New("mnemonic is required")
	}

	var password = ""
	if len(passOpt) > 0 {
		password = passOpt[0]
	}

	return bip39.NewSeedWithErrorChecking(mnemonic, password)
}

What do you think?

too many dependencies

github.com/btcsuite/btcd/chaincfg
like go btc implementation
it cause a huge binary after compile , could it apply a prune dependencies to the slightest ?

Support for EIP155 signer

I love this package, but I want to use it to sign token transfers as well. Which, as I understand it means that I have to us: types.SignTx(tx, types.NewEIP155Signer(chainID), privateKey). I can PR this package, but I am unsure how you would want this implemented. THis is less than DRY, but my thought is:

// SignTxEIP155 implements accounts.Wallet, which allows the account to sign an ERC-20 transaction.
func (w *Wallet) SignTxEIP155(account accounts.Account, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) {
	w.stateLock.RLock() // Comms have own mutex, this is for the state fields
	defer w.stateLock.RUnlock()

	// Make sure the requested account is contained within
	path, ok := w.paths[account.Address]
	if !ok {
		return nil, accounts.ErrUnknownAccount
	}

	privateKey, err := w.derivePrivateKey(path)
	if err != nil {
		return nil, err
	}

	// Sign the transaction and verify the sender to avoid hardware fault surprises
	signedTx, err := types.SignTx(tx, types.NewEIP155Signer(chainID), privateKey)
	if err != nil {
		return nil, err
	}

	msg, err := signedTx.AsMessage(types.NewEIP155Signer(chainID))
	if err != nil {
		return nil, err
	}

	sender := msg.From()
	if sender != account.Address {
		return nil, fmt.Errorf("signer mismatch: expected %s, got %s", account.Address.Hex(), sender.Hex())
	}

	return signedTx, nil
}

Thoughts?

In ropsten, doesnt allow to send the sendRawTX

Returns

{"jsonrpc":"2.0","id":2,"error":{"code":-32000,"message":"invalid sender"}}
curl --data '{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":["0xe4808504e3b2920082520894cee1854e7c2df037c9a499915161f7c4fd37f89d8080808080"],"id":2}' -H "Content-Type: application/json" -X POST http://IPHERE

Multiple definition failure

Messes up my other functions with go-ethereum, had to remove reference to this package to sort out, Any thought on how to fix this ?

I am using go-ethereum for few other functions, The moment i remove this solves the issue.

C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000004.o: In function `secp256k1GoPanicIllegal':
/tmp/go-build/_cgo_export.c:22: multiple definition of `secp256k1GoPanicIllegal'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000000.o:/tmp/go-build/_cgo_export.c:22: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000004.o: In function `secp256k1GoPanicError':
/tmp/go-build/_cgo_export.c:39: multiple definition of `secp256k1GoPanicError'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000000.o:/tmp/go-build/_cgo_export.c:39: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_context_create':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:58: multiple definition of `secp256k1_context_create'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:58: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_context_clone':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:83: multiple definition of `secp256k1_context_clone'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:83: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_context_destroy':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:92: multiple definition of `secp256k1_context_destroy'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:92: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_context_set_illegal_callback':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:103: multiple definition of `secp256k1_context_set_illegal_callback'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:103: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_context_set_error_callback':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:111: multiple definition of `secp256k1_context_set_error_callback'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:111: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_ec_pubkey_parse':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:150: multiple definition of `secp256k1_ec_pubkey_parse'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:150: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_ec_pubkey_serialize':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:165: multiple definition of `secp256k1_ec_pubkey_serialize'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:165: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_ecdsa_signature_parse_der':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:212: multiple definition of `secp256k1_ecdsa_signature_parse_der'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:212: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_ecdsa_signature_parse_compact':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:228: multiple definition of `secp256k1_ecdsa_signature_parse_compact'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:228: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_ecdsa_signature_serialize_der':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:249: multiple definition of `secp256k1_ecdsa_signature_serialize_der'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:249: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_ecdsa_signature_serialize_compact':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:261: multiple definition of `secp256k1_ecdsa_signature_serialize_compact'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:261: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_ecdsa_signature_normalize':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:274: multiple definition of `secp256k1_ecdsa_signature_normalize'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:274: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_ecdsa_verify':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:293: multiple definition of `secp256k1_ecdsa_verify'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:293: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_ecdsa_sign':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:345: multiple definition of `secp256k1_ecdsa_sign'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:345: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_ec_seckey_verify':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:391: multiple definition of `secp256k1_ec_seckey_verify'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:391: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_ec_pubkey_create':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:404: multiple definition of `secp256k1_ec_pubkey_create'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:404: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_ec_privkey_tweak_add':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:427: multiple definition of `secp256k1_ec_privkey_tweak_add'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:427: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_ec_pubkey_tweak_add':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:450: multiple definition of `secp256k1_ec_pubkey_tweak_add'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:450: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_ec_privkey_tweak_mul':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:474: multiple definition of `secp256k1_ec_privkey_tweak_mul'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:474: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_ec_pubkey_tweak_mul':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:496: multiple definition of `secp256k1_ec_pubkey_tweak_mul'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:496: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_context_randomize':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:520: multiple definition of `secp256k1_context_randomize'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:520: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_ec_pubkey_combine':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:527: multiple definition of `secp256k1_ec_pubkey_combine'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/secp256k1.c:527: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_ecdsa_recoverable_signature_parse_compact':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/recovery/main_impl.h:38: multiple definition of `secp256k1_ecdsa_recoverable_signature_parse_compact'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/recovery/main_impl.h:38: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_ecdsa_recoverable_signature_serialize_compact':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/recovery/main_impl.h:60: multiple definition of `secp256k1_ecdsa_recoverable_signature_serialize_compact'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/recovery/main_impl.h:60: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_ecdsa_recoverable_signature_convert':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/recovery/main_impl.h:74: multiple definition of `secp256k1_ecdsa_recoverable_signature_convert'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/recovery/main_impl.h:74: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_ecdsa_sign_recoverable':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/recovery/main_impl.h:123: multiple definition of `secp256k1_ecdsa_sign_recoverable'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/recovery/main_impl.h:123: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_ecdsa_recover':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/recovery/main_impl.h:170: multiple definition of `secp256k1_ecdsa_recover'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/modules/recovery/main_impl.h:170: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_ext_scalar_mul':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/ext.h:113: multiple definition of `secp256k1_ext_scalar_mul'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/ext.h:101: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_fe_normalize_weak':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_10x26_impl.h:121: multiple definition of `secp256k1_nonce_function_default'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_10x26_impl.h:121: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_fe_normalize_weak':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_10x26_impl.h:113: multiple definition of `secp256k1_nonce_function_rfc6979'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_10x26_impl.h:113: first defined here
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000007.o: In function `secp256k1_fe_normalize_var':
C:/Users/MyXMachine/src/github.com/miguelmota/go-ethereum-hdwallet/vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_10x26_impl.h:139: multiple definition of `CURVE_B'
C:\Users\MyXMachine\AppData\Local\Temp\go-link-637321475\000003.o:C:/Users/MyXMachine/src/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/field_10x26_impl.h:139: first defined here
collect2.exe: error: ld returned 1 exit status```


Thanks,
TheeCodeDragon

Large go.sum file

Hello! The go.sum file of the repo has a lot of unused packages, importing the code also brings all of them. It would be great if you fixed it. Thanks

Invalid private key generation

        wallet, err := hdwallet.NewFromMnemonic("real town addict extend shoot name disagree vital turn live can tip")
	if err != nil {
		return "", err
	}

	path := hdwallet.MustParseDerivationPath("m/44'/60'/0'/0/0")
	account, err := wallet.Derive(path, false)
	if err != nil {
		return "", err
	}

	keyHex, err := wallet.PrivateKeyHex(account)
	if err != nil {
		return "", err
	}

        return keyHex, nil

got c64f0b3e510d03adef3f057d1814bdc8a7f904caafa6928550fc10670dcff031
wanted c29cd818232f40614691a58c9afcbd5518b539cb135d73b1d9e26d5f5f5dcbbe (https://iancoleman.io/bip39/)

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.