1

I'm trying to find a way to programmatically generate Ethereum addresses based on an initial seed and then extract any funds that land in those addresses.

Here's what I've tried:

  • Generated a 24 word mnemonic and seed using Bitcoin::Trezor::Mnemonic.generate
  • Passed it to digix-geth HD Vault to generate an address: 0xf2D5286B51a8a3326CBC007477435EeC47722228
  • Sent 3 ether into it using the Rinkeby faucet
  • Loaded the wallet on MyEtherWallet.com using the seed and derivation path m/0'/0'/0'/0 (the same one that digix-eth uses by default) but the balance is showing as 0. (this gem seems to just be using money-tree underneath)
  • I've also tried using the derivation path m/44'/60'/0'/0 to match Trezor and setting chain_id = 4, no luck. The wallet addresses that MyEtherWallet offers don't match the ones that the Ruby library generates.

At this point I'm not sure if it's the Ruby library that is faulty, MyEtherWallet that is faulty or I'm just doing something wrong.

What can I try to extract the 3 ether now?

Edit: The addresses that this separate tool is generating match the ones MyEtherWallet are generating. So it's likely a fault of the Ruby library.

1 Answer 1

3

I managed to get this working. There's definitely something wrong with that digix-eth fork of the eth gem. I suspect it's the padding he adds to the mnemonic. Anyway, here's how you can generate HD addresses using a seed:

require 'bitcoin'
require 'eth'

NODE_INDEX = 0    # An index corresponds to a unique Ethereum address.
MNEMONIC = '...'  # Generate this using `Bitcoin::Trezor::Mnemonic.generate`.

master = MoneyTree::Master.new(seed_hex: Bitcoin::Trezor::Mnemonic.to_seed(MNEMONIC))
node = master.node_for_path("m/44'/60'/0'/0/#{NODE_INDEX}")
key = Eth::Key.new(priv: node.private_key.to_hex)

puts key.to_address

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.