Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Feature: Use HD wallet #42

Closed
5 tasks done
tcoulter opened this issue Mar 24, 2016 · 11 comments
Closed
5 tasks done

Feature: Use HD wallet #42

tcoulter opened this issue Mar 24, 2016 · 11 comments

Comments

@tcoulter
Copy link
Contributor

TODO:

  • allow -m/--mnemonic to input an HD wallet mnemonic
  • print out private keys
  • print out mnemonic
  • -d option uses a default mnemonic instead of default seed
  • Finally, create accounts through the HD wallet rather than generating them randomly like we do now.

Sample code provided by @axic:

const bip39 = require('bip39')
const hdkey = require('ethereumjs-wallet/hdkey')

var mnemonic = 'awake book subject inch gentle blur grant damage process float month clown'
var wallet = hdkey.fromMasterSeed(bip39.mnemonicToSeed(mnemonic)

var account = wallet.derivePath("m/44'/60'/0'/0/" + index) // index is a number
var address = account.getWallet().getAddressString() // 0x prefixed String
var publicKey = account.getWallet().getPublicKey() // Buffer
var secretkey = account.getWallet().getPrivateKey() // Buffer
@tcoulter
Copy link
Contributor Author

Someone should have told me I've been spelling mnemonic wrong the whole time. :)

@tcoulter
Copy link
Contributor Author

Suggested output on initialization should look like this:

EthereumJS TestRPC v1.2.1

Available Accounts
==================
0xbebf6e6aa73735779891d0f6ee00476781e9bc4d
0xda3dc42d8957da6f20081392e2c474694b4e49f3
0x856a2f4f43a17a11b99c6f1d2a94120ecc5c1e58
0x368e4f55b4d148fbb31c5a0edd06b09a15a5a360
0x9491b630ead587ecab09f89bbe81de54a3011f54
0x2ad39db1b0b2aeb914b65f360bbe6fbda8cba8d6
0x64dd2a806a9299171c1d426150bb4840d8860206
0xc54dc905e9f4b2622473dac825ec1abdb35e7c5f
0x2da766f19671de5923c2b407ba34b9054d3fa2c9
0x0a5fdda3071ce95be3f77e7034f04494a81565a3

Private Keys
==================
0124dd7620251eba66091dd40a42ffbc6a3fae3ee90f9e28de317dcc23315c28
fad4c21de284284cc182b8c40126f266114967c4f85464f52e089a354055d694
d08d89ce84e41eee85ec35045980a72c39d5591b0b94d0ae6bc7fe5721c494b7
9f6c9f9d34a4da23586492a85a514234b1cf310952416b7a80acb0250ba3850a
0deefa383b54774a6555c02bbab12d632046b0c545cfec7f3f20c0e436919546
69dab4f123f4c0d655445c4f2744d4624a7c7297f7581d181eb3b2011a00b6e9
8d33028b0dd13cb4adfb9acd17c13502a00e74e647351313517967a73f35d67b
07a6d20042e470449137b3e8d8e8d250dba0ceffabb436254df0580ac62da451
0df00d6668749afb2a4306aeac3d1d370ffa6868f79cd54300e746e23fa8dc9f
f499d9d5bef6df41294796a17052d0fbb1d6229499d1e71e64cb83dd515fa1c2

HD Wallet Mnemonic
==================
awake book subject inch gentle blur grant damage process float month clown

Listening on localhost:8545

@tcoulter
Copy link
Contributor Author

@axic Does that look right to you?

@tcoulter
Copy link
Contributor Author

@axic I'm going to start on this now, see what I can do.

@axic
Copy link
Contributor

axic commented Mar 24, 2016

Looks good, I might prefix each of the account/key lines with the index so it is easy to see the pairs.

Also list the base HD path below the mnemonic: m/44'/60'/0'/0 or m/44'/60'/0'/0/{accountIndex}?

@tcoulter
Copy link
Contributor Author

Hmm. I can print that. What is an hd path anyway? And quick links?

@axic
Copy link
Contributor

axic commented Mar 24, 2016

It is the derivation path and defines the steps involved in calculating an account.

BIP44 would be a useful document to understand the user-side implications of the path, without going into detail how to calculate things.

@tcoulter
Copy link
Contributor Author

@axic Check it: #44

🔥

@tcoulter
Copy link
Contributor Author

Would you look at that. BIP44 on issue #44. 👌

@axic
Copy link
Contributor

axic commented Mar 24, 2016

... in issue #42. It must be right 🤓

@tcoulter
Copy link
Contributor Author

Closed. Thanks guys!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants