Comments (8)
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.
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.
@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.
Sorry @mhluska , apprentice on the wheel here, but maybe related to #22 ?
from money-tree.
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.
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.
@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.
@thedoctor "money-tree" the name itself should support everything. not just bitcoin 👍
from money-tree.
Related Issues (20)
- Wrong address from equivalents derivation path HOT 2
- BIP49 (SegWit) derivation path HOT 10
- money-tree doesn't work on heroku HOT 1
- p2sh support HOT 1
- Update gemspec / publish gem HOT 6
- how can we adopt this to litecoin? HOT 3
- [proposal] activate testnet mode via configuration HOT 1
- can't import to electrum or the other way HOT 2
- DASH and DASH Testnet support
- Problem with openssl version on macOS for Ruby 2.6.5 HOT 6
- `money-tree` performs unsafe FFI and Monkey Patching of OpenSSL HOT 4
- Support for Bitcoin only? HOT 2
- release lib money-tree v0.11.0 to rubygems.org HOT 13
- Bip 32 test vector 5 fails 10/16
- litecoin support HOT 2
- Generate master node from private key HOT 1
- OpenSSL 3 deprecated RIPEMD160 ("legacy feature") HOT 8
- Private Key import fails with OpenSSL 3.0 HOT 2
- Bech32 dependency HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from money-tree.