money-tree 0.8.7 → 0.8.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/money-tree/node.rb +12 -3
- data/lib/money-tree/version.rb +1 -1
- data/spec/lib/money-tree/node_spec.rb +3 -1
- data/spec/lib/money-tree/private_key_spec.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7ed16071f92b2708bab3c5f2b6bedcb059879ab4
|
|
4
|
+
data.tar.gz: 6cf07c4bab76d4c13f27b352c1851615afe63229
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 99cb55b14f28c53ba6704c6ec442ed6e5e6b73272ebb96c65cc83bbb892c1d561fa77c50ecbc26f98b16b407431717360203877d20c616da7574e1b5e85638b4
|
|
7
|
+
data.tar.gz: 7998c7a665b64577ca2833cf191237ddaa4e29e604e497ebb403c8897e0a56b28b0d46d4725af777720421a99a7eecd734c758d98b2eed69f1f50d3994dd190e
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[](https://travis-ci.org/GemHQ/money-tree) [](https://coveralls.io/r/GemHQ/money-tree?branch=master) [](https://codeclimate.com/github/GemHQ/money-tree) [](http://badge.fury.io/rb/money-tree)
|
|
2
2
|
# MoneyTree
|
|
3
3
|
### RSpec tested. Big Brother removed.
|
|
4
4
|
|
data/lib/money-tree/node.rb
CHANGED
|
@@ -2,7 +2,8 @@ module MoneyTree
|
|
|
2
2
|
class Node
|
|
3
3
|
include Support
|
|
4
4
|
extend Support
|
|
5
|
-
attr_reader :private_key, :public_key, :chain_code,
|
|
5
|
+
attr_reader :private_key, :public_key, :chain_code,
|
|
6
|
+
:is_private, :depth, :index, :parent, :network, :network_key
|
|
6
7
|
|
|
7
8
|
class PublicDerivationFailure < Exception; end
|
|
8
9
|
class InvalidKeyForIndex < Exception; end
|
|
@@ -20,7 +21,7 @@ module MoneyTree
|
|
|
20
21
|
version = from_version_hex hex.slice!(0..7)
|
|
21
22
|
self.new({
|
|
22
23
|
depth: hex.slice!(0..1).to_i(16),
|
|
23
|
-
|
|
24
|
+
parent_fingerprint: hex.slice!(0..7),
|
|
24
25
|
index: hex.slice!(0..7).to_i(16),
|
|
25
26
|
chain_code: hex.slice!(0..63).to_i(16)
|
|
26
27
|
}.merge(key_options(hex, version)))
|
|
@@ -118,7 +119,7 @@ module MoneyTree
|
|
|
118
119
|
version_key = type.to_sym == :private ? :extended_privkey_version : :extended_pubkey_version
|
|
119
120
|
hex = network[version_key] # version (4 bytes)
|
|
120
121
|
hex += depth_hex(depth) # depth (1 byte)
|
|
121
|
-
hex +=
|
|
122
|
+
hex += parent_fingerprint # fingerprint of key (4 bytes)
|
|
122
123
|
hex += index_hex(index) # child number i (4 bytes)
|
|
123
124
|
hex += chain_code_hex
|
|
124
125
|
hex += type.to_sym == :private ? "00#{private_key.to_hex}" : public_key.compressed.to_hex
|
|
@@ -137,6 +138,14 @@ module MoneyTree
|
|
|
137
138
|
public_key.compressed.to_fingerprint
|
|
138
139
|
end
|
|
139
140
|
|
|
141
|
+
def parent_fingerprint
|
|
142
|
+
if @parent_fingerprint
|
|
143
|
+
@parent_fingerprint
|
|
144
|
+
else
|
|
145
|
+
depth.zero? ? '00000000' : parent.to_fingerprint
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
140
149
|
def to_address
|
|
141
150
|
address = network[:address_version] + to_identifier
|
|
142
151
|
to_serialized_base58 address
|
data/lib/money-tree/version.rb
CHANGED
|
@@ -771,7 +771,8 @@ describe MoneyTree::Master do
|
|
|
771
771
|
@node.is_private?.should == true
|
|
772
772
|
@node.depth.should == 1
|
|
773
773
|
@node.public_key.to_hex.should == "035a784662a4a20a65bf6aab9ae98a6c068a81c52e4b032c0fb5400c706cfccc56"
|
|
774
|
-
@node.chain_code_hex.should == "47fdacbd0f1097043b78c63c20c34ef4ed9a111d980047ad16282c7ae6236141"
|
|
774
|
+
@node.chain_code_hex.should == "47fdacbd0f1097043b78c63c20c34ef4ed9a111d980047ad16282c7ae6236141"
|
|
775
|
+
@node.parent_fingerprint.should == "3442193e"
|
|
775
776
|
end
|
|
776
777
|
|
|
777
778
|
it "imports a valid public node address" do
|
|
@@ -782,6 +783,7 @@ describe MoneyTree::Master do
|
|
|
782
783
|
@node.depth.should == 1
|
|
783
784
|
@node.public_key.to_hex.should == "035a784662a4a20a65bf6aab9ae98a6c068a81c52e4b032c0fb5400c706cfccc56"
|
|
784
785
|
@node.chain_code_hex.should == "47fdacbd0f1097043b78c63c20c34ef4ed9a111d980047ad16282c7ae6236141"
|
|
786
|
+
@node.parent_fingerprint.should == "3442193e"
|
|
785
787
|
end
|
|
786
788
|
end
|
|
787
789
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: money-tree
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Micah Winkelspecht
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-
|
|
11
|
+
date: 2014-12-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: ffi
|
|
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
159
159
|
version: '0'
|
|
160
160
|
requirements: []
|
|
161
161
|
rubyforge_project:
|
|
162
|
-
rubygems_version: 2.2.
|
|
162
|
+
rubygems_version: 2.2.2
|
|
163
163
|
signing_key:
|
|
164
164
|
specification_version: 4
|
|
165
165
|
summary: Bitcoin Hierarchical Deterministic Wallets in Ruby! (Bitcoin standard BIP0032)
|