money-tree 0.8.6 → 0.8.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 76fae287322e75b281ac5fe776a1093ef8b66cb2
4
- data.tar.gz: c4db93671c80b8086d8ae90b3af4091b79558e61
3
+ metadata.gz: a90e8474cf23c05904d4abc4e84043f043189ecb
4
+ data.tar.gz: 4c4281adf487eeba40c7821c3418470a0e6c1a1a
5
5
  SHA512:
6
- metadata.gz: 708a812eead8840e0e15a66dcbf9e0fe9892d387dc187b6b00f72c5e0e5c863fd571b5d1605a82c14026d74a9ce9b0f369722a031a8fb5bbeb0b6f2866b91902
7
- data.tar.gz: 7e047fc0d16a409eb1aed72b31a7d89e8a89998ccdbae34bc9c5c660bb78ec667524b3f07aa4dbfd12d71e20ad0ed87bdfbd73411af3882077dd09e37d042d6d
6
+ metadata.gz: f18dc30cb0f0f9388272d4ea896408c80284729da44ba7934c3b2b524e19ea2f2383acc68d9422c52ea5305e451d8435395a5043ee6ddaa9a29a2fb74db6caa4
7
+ data.tar.gz: d61b370aad727819049ff671f2225f8543110dfdf68cbbb375ba14aeeecc74cde5937d29a407887aa20380c181cfd768bc88596e0cd9a961bd1dd7394bf432d1
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  # MoneyTree
3
3
  ### RSpec tested. Big Brother removed.
4
4
 
5
- MoneyTree is a Ruby implementation of Bitcoin Wallets. Specifically, it supports [Hierachical Deterministic wallets](https://en.bitcoin.it/wiki/Deterministic_Wallet) according to the protocol specified in [BIP0032](https://en.bitcoin.it/wiki/BIP_0032).
5
+ MoneyTree is a Ruby implementation of Bitcoin Wallets. Specifically, it supports [Hierachical Deterministic wallets](https://en.bitcoin.it/wiki/Deterministic_Wallet) according to the protocol specified in [BIP0032](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki).
6
6
 
7
7
  ___
8
8
  If you find this helpful, please consider a small Bitcoin donation to 1nj2kie1hATcFbAaD7dEY53QaxNgt4KBp
@@ -32,7 +32,7 @@ Want to give your accountant access to view all transactions, but you don't want
32
32
 
33
33
  ## Where can I learn more?
34
34
  - [A quick primer on deterministic wallets](https://en.bitcoin.it/wiki/Deterministic_wallet)
35
- - [The official HD Wallet spec on the Bitcoin wiki](https://en.bitcoin.it/wiki/BIP_0032)
35
+ - [The official HD Wallet spec on the Bitcoin wiki](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki)
36
36
  - [An awesome talk by Pieter Wuille at Bitcoin 2013 Conference](http://youtu.be/cfkCs4NdNss)
37
37
 
38
38
  ## Installation
@@ -56,7 +56,7 @@ If you have a serious problem with this and REALLY need it to work on previous v
56
56
 
57
57
  ## Usage
58
58
 
59
- These instructions assume you have a decent understanding of how Bitcoin wallets operate and a cursory knowledge of how a [Hierarchical Deterministic Bitcoin Wallet (HD Wallet)](https://en.bitcoin.it/wiki/BIP_0032) works.
59
+ These instructions assume you have a decent understanding of how Bitcoin wallets operate and a cursory knowledge of how a [Hierarchical Deterministic Bitcoin Wallet (HD Wallet)](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) works.
60
60
 
61
61
  ### Create a Master Node (seed)
62
62
 
@@ -84,6 +84,7 @@ module MoneyTree
84
84
  end
85
85
 
86
86
  def from_bignum(bignum = raw_key)
87
+ # TODO: does this need a byte size specification?
87
88
  int_to_hex(bignum)
88
89
  end
89
90
 
@@ -137,7 +138,7 @@ module MoneyTree
137
138
  end
138
139
 
139
140
  def to_hex
140
- int_to_hex @ec_key.private_key
141
+ int_to_hex @ec_key.private_key, 64
141
142
  end
142
143
 
143
144
  def to_wif(opts = {})
@@ -251,7 +252,7 @@ module MoneyTree
251
252
  end
252
253
 
253
254
  def to_hex
254
- int_to_hex to_i
255
+ int_to_hex to_i, 66
255
256
  end
256
257
 
257
258
  def to_i
@@ -213,7 +213,7 @@ module MoneyTree
213
213
  end
214
214
 
215
215
  def chain_code_hex
216
- int_to_hex chain_code
216
+ int_to_hex chain_code, 64
217
217
  end
218
218
  end
219
219
 
@@ -289,5 +289,9 @@ module MoneyTree
289
289
  @chain_code = right_from_hash(seed_hash)
290
290
  @public_key = MoneyTree::PublicKey.new @private_key
291
291
  end
292
+
293
+ def seed_hex
294
+ bytes_to_hex(seed)
295
+ end
292
296
  end
293
297
  end
@@ -95,10 +95,17 @@ module MoneyTree
95
95
  bytes.unpack("H*")[0].to_i(16)
96
96
  end
97
97
 
98
- def int_to_hex(i)
99
- hex = i.to_s(16)
100
- hex = '0' + hex unless (hex.length % 2).zero?
101
- hex.downcase
98
+ def int_to_hex(i, size=nil)
99
+ hex = i.to_s(16).downcase
100
+ if (hex.size % 2) != 0
101
+ hex = "#{0}#{hex}"
102
+ end
103
+
104
+ if size
105
+ hex.rjust(size, "0")
106
+ else
107
+ hex
108
+ end
102
109
  end
103
110
 
104
111
  def int_to_bytes(i)
@@ -117,4 +124,4 @@ module MoneyTree
117
124
  hex.to_i(16)
118
125
  end
119
126
  end
120
- end
127
+ end
@@ -1,3 +1,3 @@
1
1
  module MoneyTree
2
- VERSION = "0.8.6"
2
+ VERSION = "0.8.7"
3
3
  end
@@ -11,6 +11,11 @@ describe MoneyTree::Master do
11
11
  it "generates a random seed 32 bytes long" do
12
12
  @master.seed.bytesize.should == 32
13
13
  end
14
+
15
+ it "exports the seed in hex format" do
16
+ @master.should respond_to(:seed_hex)
17
+ @master.seed_hex.size.should == 64
18
+ end
14
19
  end
15
20
 
16
21
  context "testnet" do
@@ -6,9 +6,14 @@ describe MoneyTree::PrivateKey do
6
6
  end
7
7
 
8
8
  describe "to_hex" do
9
- it "has 62 - 64 characters" do
10
- # could be only 31 bytes if key has leading zeros
11
- [62, 64].should include(@key.to_hex.length)
9
+ it "has 64 characters" do
10
+ # must always be 64 characters - leading zeroes need to be preserved!
11
+ @key.to_hex.length.should == 64
12
+ end
13
+
14
+ it "preserves leading zeros" do
15
+ master = MoneyTree::Master.new seed_hex: "9cf6b6e8451c7d551cb402e2997566e5c7c258543eadb184f9f39322b2e6959b"
16
+ master.node_for_path("m/427").private_key.to_hex.length.should == 64
12
17
  end
13
18
 
14
19
  it "is a valid hex" do
metadata CHANGED
@@ -1,111 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: money-tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.6
4
+ version: 0.8.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Winkelspecht
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-26 00:00:00.000000000 Z
11
+ date: 2014-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: coveralls
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: pry
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  description: A Ruby Gem implementation of Bitcoin HD Wallets
@@ -115,10 +115,10 @@ executables: []
115
115
  extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
- - .gitignore
119
- - .rspec
120
- - .simplecov
121
- - .travis.yml
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".simplecov"
121
+ - ".travis.yml"
122
122
  - Gemfile
123
123
  - LICENSE.txt
124
124
  - README.md
@@ -149,17 +149,17 @@ require_paths:
149
149
  - lib
150
150
  required_ruby_version: !ruby/object:Gem::Requirement
151
151
  requirements:
152
- - - '>='
152
+ - - ">="
153
153
  - !ruby/object:Gem::Version
154
154
  version: '0'
155
155
  required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - '>='
157
+ - - ">="
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
160
  requirements: []
161
161
  rubyforge_project:
162
- rubygems_version: 2.1.11
162
+ rubygems_version: 2.2.0
163
163
  signing_key:
164
164
  specification_version: 4
165
165
  summary: Bitcoin Hierarchical Deterministic Wallets in Ruby! (Bitcoin standard BIP0032)