Giter VIP home page Giter VIP logo

Comments (8)

jackkinsella avatar jackkinsella commented on August 13, 2024 3

I ran into the same problem today. Everything works just dandy with the following code

   # Assumes that the 'eth' gem is available
   Eth::Utils.public_key_to_address(node.public_key.uncompressed.to_hex)

from money-tree.

nofxx avatar nofxx commented on August 13, 2024

It works just fine. You must use Key#private_hex. (Myetherwallet and eth gem).
Now curious about mnemonic words ones... will investigate.

from money-tree.

mhluska avatar mhluska commented on August 13, 2024

@nofxx Can you elaborate? I'm trying to use an extended public key to create Ethereum addresses. Here's how I'm trying it:

require 'money-tree'
require 'eth'

key = 'xpub6Dv28vySKcyJSvYivLP8PEedEZf6Cut2D7cUUaPgushD7MNWvpsy34oZaxrAbdbtuGN61hMLbv17tc4hFPfiYN4oMLJxt9SyvfoxtJadbiR'
master = MoneyTree::Node.from_bip32(key)
node = master.node_for_path("m/44'/60'/0'/0/0") # This step throws MoneyTree::Node::PrivatePublicMismatch
Eth::Utils.public_key_to_address(node.public_key.to_hex)

I suspect the from_bip32 method isn't set up to handle Ethereum addresses but I'm not familiar enough with this to know for sure.

This would be useful in a related gem: Sailias/cryptocoin_payable#3

What does work, however, is this:

require 'eth'
require 'bitcoin'
require 'money-tree'

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

This is not ideal because I would prefer to generate the addresses from the extended public key rather than from the mnemonic.

from money-tree.

nofxx avatar nofxx commented on August 13, 2024

Sorry @mhluska , apprentice on the wheel here, but maybe related to #22 ?

from money-tree.

mhluska avatar mhluska commented on August 13, 2024

Seems to be related. Looks like not much is happening to help fix the issue? I can give it a shot this week.

from money-tree.

mhluska avatar mhluska commented on August 13, 2024

So the MoneyTree::Node::PrivatePublicMismatch happens because hardened derivations can't happen without a master private key. If I replace the xpub with an xprv, it runs fine but the resulting Ethereum address is still incorrect.

from money-tree.

thedoctor avatar thedoctor commented on August 13, 2024

@mhluska Correct regarding the hardened derivation issue.
@jackkinsella is (ostensibly) correct with the use of uncompressed. I don't know the Eth::Utils class myself, but it clearly expects uncompressed public keys.

It's probably not a likely that we'll add support for ethereum addresses directly to this repo as that's beyond the scope of money-tree

from money-tree.

krtschmr avatar krtschmr commented on August 13, 2024

@thedoctor "money-tree" the name itself should support everything. not just bitcoin 👍

from money-tree.

Related Issues (20)

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.