Ruby: How do I create a wallet and import an electrum seed using money-tree gem

1

I am looking for a way to use HD wallets with ruby. This is what I have found: https://github.com/GemHQ/money-tree. However I am having trouble generating a wallet and getting the seed to reload it in the program though that. I would like to be able to create many addresses in this wallet. I am also looking for a way to load my electrum wallet using the ruby money-tree gem, or any other you happen to know of.

How would I do this?

Pabi

Posted 2016-03-09T19:30:05.073

Reputation: 111

Answers

1

Create a new wallet in Electrum. Copy the 'Master Public Key' and pass it to the money-tree gem like this:

require 'money-tree'

@node = MoneyTree::Node.from_bip32("YOUR_MASTER_PUBLIC_KEY")

i = 0
20.times do
  @child = @node.node_for_path "m/0/#{i}"
  puts @child.to_address
  i+= 1
end

This will give you the first 20 child nodes of the first child of the master public key. These addresses should be the same as your "Receiving" addresses in your Electrum wallet.

Ben

Posted 2016-03-09T19:30:05.073

Reputation: 11

Electrum 3.3 tells me 19tSK8Fzeox8Rpg1z4ZAw81bvoBNG2NXXL while this code tells me mpQPcBLyTqPPCw9dhdXYm3Dvnnn58Y4dwATim Kretschmer 2019-05-08T10:12:40.940

1

You can do it the other way around.

Generate a new master node

@master = MoneyTree::Master.new

and then import into electrum the 'Master private key'

@master.to_bip32(:private)

If you create a new wallet in Electrum and select: 'Standard Wallet' >'use public or private keys', there you'll be able to put the BIP32 private key.

I was also having problems passing the electrum seed as a parameter.

Gmae

Posted 2016-03-09T19:30:05.073

Reputation: 11

i tried this several times. i'll get "tprv8ZgxMBicQKsPetzTudFxisrLzJ5mj1nqUfGeXzREzB4xqqTLegLcw2nwdEoHPfC9NnAe9jvE98xGNk61yCK7G985ABpTThLFaKp5pqhShWD" but electrum won't let me import this....Tim Kretschmer 2019-05-08T10:17:05.980