bip44-extended 0.2.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.idea/$CACHE_FILE$ +6 -0
- data/.idea/.gitignore +2 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/bip44.iml +25 -0
- data/.idea/misc.xml +7 -0
- data/.idea/modules.xml +8 -0
- data/.idea/vcs.xml +6 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +42 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bip44-extended-0.2.20.gem +0 -0
- data/bip44-extended-0.2.21.gem +0 -0
- data/bip44-extended-0.2.22.gem +0 -0
- data/bip44-extended-0.2.23.gem +0 -0
- data/bip44.gemspec +35 -0
- data/lib/bip44.rb +47 -0
- data/lib/bip44/bitcoin.rb +8 -0
- data/lib/bip44/bitcoin_cash.rb +7 -0
- data/lib/bip44/ethereum.rb +16 -0
- data/lib/bip44/litecoin.rb +7 -0
- data/lib/bip44/utils.rb +22 -0
- data/lib/bip44/version.rb +3 -0
- data/lib/bip44/wallet.rb +71 -0
- data/lib/bip44/zcoin.rb +7 -0
- metadata +217 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 69c3110162407a1f3fe26ae78ab1f644cdd7cc93ee70f2b43a258d5c1b1117e0
|
4
|
+
data.tar.gz: 240768e49537d2f3768576efb8787aa6cd7ee0f733c18be82d69717942b6af42
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bdd298b8c12bab19b4c335f56475dc0aed661f4d54600eb835c1cf8118413f59753cf34e67437f5963c017c388914500ee4e0adee2d62cc2d7fc2a028415c589
|
7
|
+
data.tar.gz: 1192dc2323dbb1916f90dae3eb76cdd712acee35e0c0a8c0d3ca6c147f1c512c753cde8cc27ef3191bfcfe3644f9fb753ae3136b2c48b163417c01eb844b6e0a
|
data/.gitignore
ADDED
data/.idea/$CACHE_FILE$
ADDED
data/.idea/.gitignore
ADDED
data/.idea/.rakeTasks
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<Settings><!--This file was automatically generated by Ruby plugin.
|
3
|
+
You are allowed to:
|
4
|
+
1. Remove rake task
|
5
|
+
2. Add existing rake tasks
|
6
|
+
To add existing rake tasks automatically delete this file and reload the project.
|
7
|
+
--><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build bip44-0.2.18.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Remove any temporary products" fullCmd="clean" taksId="clean" /><RakeTask description="Remove any generated files" fullCmd="clobber" taksId="clobber" /><RakeTask description="Build and install bip44-0.2.18.gem into system gems" fullCmd="install" taksId="install" /><RakeGroup description="" fullCmd="" taksId="install"><RakeTask description="Build and install bip44-0.2.18.gem into system gems without network access" fullCmd="install:local" taksId="local" /></RakeGroup><RakeTask description="Create tag v0.2.18 and build and push bip44-0.2.18.gem to rubygems.org" fullCmd="release[remote]" taksId="release[remote]" /><RakeTask description="Run tests" fullCmd="test" taksId="test" /><RakeTask description="" fullCmd="default" taksId="default" /><RakeTask description="" fullCmd="release" taksId="release" /><RakeGroup description="" fullCmd="" taksId="release"><RakeTask description="" fullCmd="release:guard_clean" taksId="guard_clean" /><RakeTask description="" fullCmd="release:rubygem_push" taksId="rubygem_push" /><RakeTask description="" fullCmd="release:source_control_push" taksId="source_control_push" /></RakeGroup></RakeGroup></Settings>
|
data/.idea/bip44.iml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="ModuleRunConfigurationManager">
|
4
|
+
<shared />
|
5
|
+
</component>
|
6
|
+
<component name="NewModuleRootManager">
|
7
|
+
<content url="file://$MODULE_DIR$" />
|
8
|
+
<orderEntry type="inheritedJdk" />
|
9
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
10
|
+
<orderEntry type="library" scope="PROVIDED" name="bip_mnemonic (v0.0.4, rbenv: 2.5.1) [gem]" level="application" />
|
11
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.17.1, rbenv: 2.5.1) [gem]" level="application" />
|
12
|
+
<orderEntry type="library" scope="PROVIDED" name="digest-sha3 (v1.1.0, rbenv: 2.5.1) [gem]" level="application" />
|
13
|
+
<orderEntry type="library" scope="PROVIDED" name="ecdsa (v1.2.0, rbenv: 2.5.1) [gem]" level="application" />
|
14
|
+
<orderEntry type="library" scope="PROVIDED" name="eth (v0.4.10, rbenv: 2.5.1) [gem]" level="application" />
|
15
|
+
<orderEntry type="library" scope="PROVIDED" name="execjs (v2.4.0, rbenv: 2.5.1) [gem]" level="application" />
|
16
|
+
<orderEntry type="library" scope="PROVIDED" name="ffi (v1.11.1, rbenv: 2.5.1) [gem]" level="application" />
|
17
|
+
<orderEntry type="library" scope="PROVIDED" name="ffi-compiler (v1.0.1, rbenv: 2.5.1) [gem]" level="application" />
|
18
|
+
<orderEntry type="library" scope="PROVIDED" name="minitest (v5.11.3, rbenv: 2.5.1) [gem]" level="application" />
|
19
|
+
<orderEntry type="library" scope="PROVIDED" name="money-tree (v0.10.0, rbenv: 2.5.1) [gem]" level="application" />
|
20
|
+
<orderEntry type="library" scope="PROVIDED" name="money-tree-extended (v0.11.1, rbenv: 2.5.1) [gem]" level="application" />
|
21
|
+
<orderEntry type="library" scope="PROVIDED" name="rake (v10.5.0, rbenv: 2.5.1) [gem]" level="application" />
|
22
|
+
<orderEntry type="library" scope="PROVIDED" name="rlp (v0.7.3, rbenv: 2.5.1) [gem]" level="application" />
|
23
|
+
<orderEntry type="library" scope="PROVIDED" name="scrypt (v3.0.6, rbenv: 2.5.1) [gem]" level="application" />
|
24
|
+
</component>
|
25
|
+
</module>
|
data/.idea/misc.xml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="JavaScriptSettings">
|
4
|
+
<option name="languageLevel" value="ES6" />
|
5
|
+
</component>
|
6
|
+
<component name="ProjectRootManager" version="2" project-jdk-name="rbenv: 2.5.1" project-jdk-type="RUBY_SDK" />
|
7
|
+
</project>
|
data/.idea/modules.xml
ADDED
data/.idea/vcs.xml
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at wuminzhe@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 wuminzhe
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# bip44 for ruby
|
2
|
+
|
3
|
+
IMPORTANT: there is a serious bug of version <= 0.2.13, so use >= 0.2.14
|
4
|
+
|
5
|
+
A ruby library to generate multi coin addresses from a hierarchical deterministic wallet according to the [BIP44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki) standard.
|
6
|
+
|
7
|
+
Internally it uses [money-tree](https://github.com/GemHQ/money-tree) for the deterministic private and public keys which allows to use many additional features like deriving address from mnemonic backups (BIP32).
|
8
|
+
|
9
|
+
Compatible with most hd wallet client like: imToken,MetaMask,Jaxx,MyEtherWallet,TREZOR,Exodus...
|
10
|
+
|
11
|
+
I will add more coin support to it.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'bip44', '~> 0.2.14'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install bip44
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
See test
|
32
|
+
|
33
|
+
TODO: Write usage instructions here
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/wuminzhe/bip44. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
38
|
+
|
39
|
+
## License
|
40
|
+
|
41
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
42
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "bip44"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/bip44.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "bip44/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bip44-extended"
|
8
|
+
spec.version = Bip44::VERSION
|
9
|
+
spec.authors = ["wuminzhe, nikharR"]
|
10
|
+
spec.email = ["wuminzhe@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "A ruby library to generate Ethereum addresses from a hierarchical deterministic wallet according to the BIP44 standard. (Extended)"
|
13
|
+
spec.description = "A ruby library to generate Ethereum addresses from a hierarchical deterministic wallet according to the BIP44 standard. (Extended)"
|
14
|
+
spec.homepage = "https://github.com/nikharR/bip44"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
27
|
+
spec.add_development_dependency "execjs", "~> 2.4.0"
|
28
|
+
|
29
|
+
spec.add_dependency "money-tree-extended", "~> 0.11.1"
|
30
|
+
spec.add_dependency "ecdsa", "~> 1.2.0"
|
31
|
+
spec.add_dependency "digest-sha3", "~> 1.1.0"
|
32
|
+
spec.add_dependency "rlp", "~> 0.7.3"
|
33
|
+
spec.add_dependency "bip_mnemonic"
|
34
|
+
spec.add_dependency "eth"
|
35
|
+
end
|
data/lib/bip44.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require "bip44/version"
|
2
|
+
require 'ecdsa'
|
3
|
+
require 'digest/sha3'
|
4
|
+
require 'rlp'
|
5
|
+
require 'money-tree'
|
6
|
+
require 'bip_mnemonic'
|
7
|
+
require 'eth'
|
8
|
+
require 'bip44/utils'
|
9
|
+
require 'bip44/bitcoin'
|
10
|
+
require 'bip44/ethereum'
|
11
|
+
require 'bip44/litecoin'
|
12
|
+
require 'bip44/bitcoin_cash'
|
13
|
+
require 'bip44/zcoin'
|
14
|
+
require 'bip44/wallet'
|
15
|
+
|
16
|
+
module Bip44
|
17
|
+
def self.create_mnemonic_wallet
|
18
|
+
words = BipMnemonic.to_mnemonic(bits: 128)
|
19
|
+
puts words
|
20
|
+
seed = BipMnemonic.to_seed(mnemonic: words)
|
21
|
+
puts "seed: #{seed}"
|
22
|
+
ethereum_wallet = Bip44::Wallet.from_seed(seed, "m/44'/60'/0'/0")
|
23
|
+
puts 'ethereum xprv: ' + ethereum_wallet.xprv
|
24
|
+
puts 'ethereum xpub: ' + ethereum_wallet.xpub
|
25
|
+
bitcoin_wallet = Bip44::Wallet.from_seed(seed, "m/44'/0'/0'/0")
|
26
|
+
puts 'bitcoin xprv: ' + bitcoin_wallet.xprv
|
27
|
+
puts 'bitcoin xpub: ' + bitcoin_wallet.xpub
|
28
|
+
dash_wallet = Bip44::Wallet.from_seed(seed, "m/44'/5'/0'/0")
|
29
|
+
puts 'dash xprv: ' + dash_wallet.xprv
|
30
|
+
puts 'dash xpub: ' + dash_wallet.xpub
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.from_mnemonic(words)
|
34
|
+
seed = BipMnemonic.to_seed(mnemonic: words)
|
35
|
+
puts "seed: #{seed}"
|
36
|
+
ethereum_wallet = Bip44::Wallet.from_seed(seed, "m/44'/60'/0'/0")
|
37
|
+
puts 'ethereum xprv: ' + ethereum_wallet.xprv
|
38
|
+
puts 'ethereum xpub: ' + ethereum_wallet.xpub
|
39
|
+
bitcoin_wallet = Bip44::Wallet.from_seed(seed, "m/44'/0'/0'/0")
|
40
|
+
puts 'bitcoin xprv: ' + bitcoin_wallet.xprv
|
41
|
+
puts 'bitcoin xpub: ' + bitcoin_wallet.xpub
|
42
|
+
dash_wallet = Bip44::Wallet.from_seed(seed, "m/44'/5'/0'/0")
|
43
|
+
puts 'dash xprv: ' + dash_wallet.xprv
|
44
|
+
puts 'dash xpub: ' + dash_wallet.xpub
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Bip44
|
2
|
+
module Ethereum
|
3
|
+
def ethereum_address
|
4
|
+
# from bitcoin public key to ethereum public key
|
5
|
+
group = ECDSA::Group::Secp256k1
|
6
|
+
public_key = ECDSA::Format::PointOctetString.decode(@wallet_node.public_key.to_bytes, group) # a point
|
7
|
+
ethereum_public = Utils.padding64(public_key.x.to_s(16)) + Utils.padding64(public_key.y.to_s(16))
|
8
|
+
|
9
|
+
# from ethereum public key to ethereum address
|
10
|
+
bytes = Bip44::Utils.hex_to_bin(ethereum_public)
|
11
|
+
address_bytes = Digest::SHA3.new(256).digest(bytes)[-20..-1]
|
12
|
+
address = Bip44::Utils.bin_to_hex(address_bytes)
|
13
|
+
Bip44::Utils.prefix_hex(address)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/bip44/utils.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Bip44
|
2
|
+
module Utils
|
3
|
+
def self.hex_to_bin(string)
|
4
|
+
RLP::Utils.decode_hex string
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.bin_to_hex(string)
|
8
|
+
RLP::Utils.encode_hex string
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.padding64(str)
|
12
|
+
if str =~ /^0x[a-f0-9]*/
|
13
|
+
str = str[2 .. str.length-1]
|
14
|
+
end
|
15
|
+
str.rjust(64, '0')
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.prefix_hex(hex)
|
19
|
+
hex.match(/\A0x/) ? hex : "0x#{hex}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/bip44/wallet.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
module Bip44
|
2
|
+
|
3
|
+
# "44'", # bip 44
|
4
|
+
# "60'", # coin, 0': bitcoin, 60': ethereum
|
5
|
+
# "0'", # wallet
|
6
|
+
# "0" # 0 - public, 1 = private
|
7
|
+
# "0" # index
|
8
|
+
class Wallet
|
9
|
+
include Bip44::Bitcoin
|
10
|
+
include Bip44::Ethereum
|
11
|
+
include Bip44::BitcoinCash
|
12
|
+
include Bip44::Litecoin
|
13
|
+
include Bip44::Zcoin
|
14
|
+
|
15
|
+
def self.from_seed(seed, path)
|
16
|
+
master = MoneyTree::Master.new(seed_hex: seed) # 3. 种子用于使用 HMAC-SHA512 生成根私钥(参见 BIP32)
|
17
|
+
wallet_node = master.node_for_path(path) # 4. 从该根私钥,导出子私钥(参见 BIP32),其中节点布局由BIP44设置
|
18
|
+
Wallet.new(wallet_node)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.from_mnemonic(mnemonic, path)
|
22
|
+
seed = BipMnemonic.to_seed(mnemonic: mnemonic) # 2. 该助记词使用 PBKDF2 转化为种子(参见 BIP39)
|
23
|
+
Wallet.from_seed(seed, path)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.from_xpub(xpub)
|
27
|
+
wallet_node = MoneyTree::Node.from_bip32(xpub)
|
28
|
+
Wallet.new(wallet_node)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.from_xprv(xprv)
|
32
|
+
wallet_node = MoneyTree::Node.from_bip32(xprv)
|
33
|
+
Wallet.new(wallet_node)
|
34
|
+
end
|
35
|
+
|
36
|
+
def sub_wallet(path)
|
37
|
+
Wallet.new(@wallet_node.node_for_path(path))
|
38
|
+
end
|
39
|
+
|
40
|
+
def xpub(testnet: false)
|
41
|
+
return @wallet_node.to_bip32(:public, network: :bitcoin_testnet) if testnet
|
42
|
+
@wallet_node.to_bip32(:public)
|
43
|
+
end
|
44
|
+
|
45
|
+
def xprv(testnet: :false)
|
46
|
+
return @wallet_node.to_bip32(:private, network: :bitcoin_testnet) if testnet
|
47
|
+
@wallet_node.to_bip32(:private)
|
48
|
+
end
|
49
|
+
|
50
|
+
def wif(compressed: true, testnet: false)
|
51
|
+
return @wallet_node.private_key.to_wif(compressed: compressed, network: :bitcoin_testnet) if testnet
|
52
|
+
@wallet_node.private_key.to_wif(compressed: compressed)
|
53
|
+
end
|
54
|
+
|
55
|
+
def private_key
|
56
|
+
@wallet_node.private_key.to_hex
|
57
|
+
end
|
58
|
+
|
59
|
+
def public_key
|
60
|
+
@wallet_node.public_key.uncompressed.to_hex
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def initialize(wallet_node)
|
66
|
+
@wallet_node = wallet_node
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
data/lib/bip44/zcoin.rb
ADDED
metadata
ADDED
@@ -0,0 +1,217 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bip44-extended
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.24
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- wuminzhe, nikharR
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-09-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.15'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.15'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: execjs
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.4.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.4.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: money-tree-extended
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.11.1
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.11.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: ecdsa
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.2.0
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.2.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: digest-sha3
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.1.0
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.1.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rlp
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.7.3
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.7.3
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: bip_mnemonic
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: eth
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
description: A ruby library to generate Ethereum addresses from a hierarchical deterministic
|
154
|
+
wallet according to the BIP44 standard. (Extended)
|
155
|
+
email:
|
156
|
+
- wuminzhe@gmail.com
|
157
|
+
executables: []
|
158
|
+
extensions: []
|
159
|
+
extra_rdoc_files: []
|
160
|
+
files:
|
161
|
+
- ".DS_Store"
|
162
|
+
- ".gitignore"
|
163
|
+
- ".idea/$CACHE_FILE$"
|
164
|
+
- ".idea/.gitignore"
|
165
|
+
- ".idea/.rakeTasks"
|
166
|
+
- ".idea/bip44.iml"
|
167
|
+
- ".idea/misc.xml"
|
168
|
+
- ".idea/modules.xml"
|
169
|
+
- ".idea/vcs.xml"
|
170
|
+
- ".travis.yml"
|
171
|
+
- CODE_OF_CONDUCT.md
|
172
|
+
- Gemfile
|
173
|
+
- LICENSE.txt
|
174
|
+
- README.md
|
175
|
+
- Rakefile
|
176
|
+
- bin/console
|
177
|
+
- bin/setup
|
178
|
+
- bip44-extended-0.2.20.gem
|
179
|
+
- bip44-extended-0.2.21.gem
|
180
|
+
- bip44-extended-0.2.22.gem
|
181
|
+
- bip44-extended-0.2.23.gem
|
182
|
+
- bip44.gemspec
|
183
|
+
- lib/bip44.rb
|
184
|
+
- lib/bip44/bitcoin.rb
|
185
|
+
- lib/bip44/bitcoin_cash.rb
|
186
|
+
- lib/bip44/ethereum.rb
|
187
|
+
- lib/bip44/litecoin.rb
|
188
|
+
- lib/bip44/utils.rb
|
189
|
+
- lib/bip44/version.rb
|
190
|
+
- lib/bip44/wallet.rb
|
191
|
+
- lib/bip44/zcoin.rb
|
192
|
+
homepage: https://github.com/nikharR/bip44
|
193
|
+
licenses:
|
194
|
+
- MIT
|
195
|
+
metadata: {}
|
196
|
+
post_install_message:
|
197
|
+
rdoc_options: []
|
198
|
+
require_paths:
|
199
|
+
- lib
|
200
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
201
|
+
requirements:
|
202
|
+
- - ">="
|
203
|
+
- !ruby/object:Gem::Version
|
204
|
+
version: '0'
|
205
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
206
|
+
requirements:
|
207
|
+
- - ">="
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: '0'
|
210
|
+
requirements: []
|
211
|
+
rubyforge_project:
|
212
|
+
rubygems_version: 2.7.6
|
213
|
+
signing_key:
|
214
|
+
specification_version: 4
|
215
|
+
summary: A ruby library to generate Ethereum addresses from a hierarchical deterministic
|
216
|
+
wallet according to the BIP44 standard. (Extended)
|
217
|
+
test_files: []
|