money-tree 0.11.0 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe MoneyTree::PrivateKey do
4
4
  before do
@@ -17,7 +17,7 @@ describe MoneyTree::PrivateKey do
17
17
  end
18
18
 
19
19
  it "is a valid hex" do
20
- expect(@key.to_hex).to eql('5eae5375fb5f7a0ea650566363befa2830ef441bdcb19198adf318faee86d64b')
20
+ expect(@key.to_hex).to eql("5eae5375fb5f7a0ea650566363befa2830ef441bdcb19198adf318faee86d64b")
21
21
  end
22
22
  end
23
23
 
@@ -31,7 +31,7 @@ describe MoneyTree::PrivateKey do
31
31
  end
32
32
 
33
33
  it "is a valid compressed wif" do
34
- expect(@key.to_wif).to eql('KzPkwAXJ4wtXHnbamTaJqoMrzwCUUJaqhUxnqYhnZvZH6KhgmDPK')
34
+ expect(@key.to_wif).to eql("KzPkwAXJ4wtXHnbamTaJqoMrzwCUUJaqhUxnqYhnZvZH6KhgmDPK")
35
35
  end
36
36
  end
37
37
 
@@ -41,17 +41,17 @@ describe MoneyTree::PrivateKey do
41
41
  end
42
42
 
43
43
  it "starts with 5" do
44
- expect(@key.to_wif(compressed: false)[0]).to eql('5')
44
+ expect(@key.to_wif(compressed: false)[0]).to eql("5")
45
45
  end
46
46
 
47
47
  it "is valid" do
48
- expect(@key.to_wif(compressed: false)).to eql('5JXz5ZyFk31oHVTQxqce7yitCmTAPxBqeGQ4b7H3Aj3L45wUhoa')
48
+ expect(@key.to_wif(compressed: false)).to eql("5JXz5ZyFk31oHVTQxqce7yitCmTAPxBqeGQ4b7H3Aj3L45wUhoa")
49
49
  end
50
50
  end
51
51
 
52
52
  describe "from_wif(wif)" do
53
53
  it "returns the key from a wif" do
54
- expect(@key.from_wif("5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ")).to eql('0c28fca386c7a227600b2fe50b7cae11ec86d3bf1fbe471be89827e19d72aa1d')
54
+ expect(@key.from_wif("5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ")).to eql("0c28fca386c7a227600b2fe50b7cae11ec86d3bf1fbe471be89827e19d72aa1d")
55
55
  end
56
56
 
57
57
  it "raises an error on bad checksum" do
@@ -65,7 +65,7 @@ describe MoneyTree::PrivateKey do
65
65
  end
66
66
 
67
67
  it "is a valid base64" do
68
- expect(@key.to_base64).to eql('Xq5Tdftfeg6mUFZjY776KDDvRBvcsZGYrfMY+u6G1ks=')
68
+ expect(@key.to_base64).to eql("Xq5Tdftfeg6mUFZjY776KDDvRBvcsZGYrfMY+u6G1ks=")
69
69
  end
70
70
  end
71
71
 
@@ -76,7 +76,7 @@ describe MoneyTree::PrivateKey do
76
76
  end
77
77
 
78
78
  it "returns the key from base64 encoding" do
79
- expect(@key.from_base64("Xq5Tdftfeg6mUFZjY776KDDvRBvcsZGYrfMY+u6G1ks=")).to eql('5eae5375fb5f7a0ea650566363befa2830ef441bdcb19198adf318faee86d64b')
79
+ expect(@key.from_base64("Xq5Tdftfeg6mUFZjY776KDDvRBvcsZGYrfMY+u6G1ks=")).to eql("5eae5375fb5f7a0ea650566363befa2830ef441bdcb19198adf318faee86d64b")
80
80
  end
81
81
 
82
82
  it "raises an error on bad encoding" do
@@ -109,12 +109,12 @@ describe MoneyTree::PrivateKey do
109
109
 
110
110
  context "testnet" do
111
111
  before do
112
- @key = MoneyTree::PrivateKey.new key: 'cRhes8SBnsF6WizphaRKQKZZfDniDa9Bxcw31yKeEC1KDExhxFgD'
112
+ @key = MoneyTree::PrivateKey.new key: "cRhes8SBnsF6WizphaRKQKZZfDniDa9Bxcw31yKeEC1KDExhxFgD"
113
113
  end
114
114
 
115
115
  describe "to_wif" do
116
116
  it "returns same wif" do
117
- expect(@key.to_wif(network: :bitcoin_testnet)).to eql('cRhes8SBnsF6WizphaRKQKZZfDniDa9Bxcw31yKeEC1KDExhxFgD')
117
+ expect(@key.to_wif(network: :bitcoin_testnet)).to eql("cRhes8SBnsF6WizphaRKQKZZfDniDa9Bxcw31yKeEC1KDExhxFgD")
118
118
  end
119
119
  end
120
120
  end
@@ -1,7 +1,6 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe MoneyTree::PublicKey do
4
-
5
4
  describe "with a private key" do
6
5
  before do
7
6
  @private_key = MoneyTree::PrivateKey.new key: "5eae5375fb5f7a0ea650566363befa2830ef441bdcb19198adf318faee86d64b"
@@ -14,7 +13,7 @@ describe MoneyTree::PublicKey do
14
13
  end
15
14
 
16
15
  it "is a valid hex" do
17
- expect(@key.uncompressed.to_hex).to eql('042dfc2557a007c93092c2915f11e8aa70c4f399a6753e2e908330014091580e4b11203096f1a1c5276a73f91b9465357004c2103cc42c63d6d330df589080d2e4')
16
+ expect(@key.uncompressed.to_hex).to eql("042dfc2557a007c93092c2915f11e8aa70c4f399a6753e2e908330014091580e4b11203096f1a1c5276a73f91b9465357004c2103cc42c63d6d330df589080d2e4")
18
17
  end
19
18
  end
20
19
 
@@ -24,7 +23,7 @@ describe MoneyTree::PublicKey do
24
23
  end
25
24
 
26
25
  it "is a valid compressed hex" do
27
- expect(@key.to_hex).to eql('022dfc2557a007c93092c2915f11e8aa70c4f399a6753e2e908330014091580e4b')
26
+ expect(@key.to_hex).to eql("022dfc2557a007c93092c2915f11e8aa70c4f399a6753e2e908330014091580e4b")
28
27
  end
29
28
  end
30
29
 
@@ -40,7 +39,17 @@ describe MoneyTree::PublicKey do
40
39
  end
41
40
 
42
41
  it "is a valid bitcoin address" do
43
- expect(@key.uncompressed.to_address).to eql('133bJA2xoVqBUsiR3uSkciMo5r15fLAaZg')
42
+ expect(@key.uncompressed.to_address).to eql("133bJA2xoVqBUsiR3uSkciMo5r15fLAaZg")
43
+ end
44
+ end
45
+
46
+ describe "to_bech32_address" do
47
+ it "has 42 characters" do
48
+ expect(@key.to_bech32_address.length).to eql(42)
49
+ end
50
+
51
+ it "is a valid bitcoin address" do
52
+ expect(@key.to_bech32_address).to eql("bc1qrlwlgt5d0sdtq882qvk3jc0sywucn76fwcmqma")
44
53
  end
45
54
  end
46
55
 
@@ -50,14 +59,24 @@ describe MoneyTree::PublicKey do
50
59
  end
51
60
 
52
61
  it "is a valid compressed bitcoin address" do
53
- expect(@key.to_address).to eql('13uVqa35BMo4mYq9LiZrXVzoz9EFZ6aoXe')
62
+ expect(@key.to_address).to eql("13uVqa35BMo4mYq9LiZrXVzoz9EFZ6aoXe")
63
+ end
64
+ end
65
+
66
+ describe "to_p2wpkh_p2sh" do
67
+ it "has 34 characters" do
68
+ expect(@key.to_p2wpkh_p2sh.length).to eql(34)
69
+ end
70
+
71
+ it "is a valid p2wpkh_p2sh bitcoin address" do
72
+ expect(@key.to_p2wpkh_p2sh).to eql("31vNN7WVDxjvc5XZVKW3qV4B3nFLxsRPnE")
54
73
  end
55
74
  end
56
75
  end
57
76
 
58
77
  describe "without a private key" do
59
78
  before do
60
- @key = MoneyTree::PublicKey.new '042dfc2557a007c93092c2915f11e8aa70c4f399a6753e2e908330014091580e4b11203096f1a1c5276a73f91b9465357004c2103cc42c63d6d330df589080d2e4'
79
+ @key = MoneyTree::PublicKey.new "042dfc2557a007c93092c2915f11e8aa70c4f399a6753e2e908330014091580e4b11203096f1a1c5276a73f91b9465357004c2103cc42c63d6d330df589080d2e4"
61
80
  end
62
81
 
63
82
  describe "to_hex(compressed: false)" do
@@ -66,7 +85,7 @@ describe MoneyTree::PublicKey do
66
85
  end
67
86
 
68
87
  it "is a valid hex" do
69
- expect(@key.uncompressed.to_hex).to eql('042dfc2557a007c93092c2915f11e8aa70c4f399a6753e2e908330014091580e4b11203096f1a1c5276a73f91b9465357004c2103cc42c63d6d330df589080d2e4')
88
+ expect(@key.uncompressed.to_hex).to eql("042dfc2557a007c93092c2915f11e8aa70c4f399a6753e2e908330014091580e4b11203096f1a1c5276a73f91b9465357004c2103cc42c63d6d330df589080d2e4")
70
89
  end
71
90
  end
72
91
 
@@ -76,7 +95,7 @@ describe MoneyTree::PublicKey do
76
95
  end
77
96
 
78
97
  it "is a valid compressed hex" do
79
- expect(@key.compressed.to_hex).to eql('022dfc2557a007c93092c2915f11e8aa70c4f399a6753e2e908330014091580e4b')
98
+ expect(@key.compressed.to_hex).to eql("022dfc2557a007c93092c2915f11e8aa70c4f399a6753e2e908330014091580e4b")
80
99
  end
81
100
  end
82
101
 
@@ -92,7 +111,7 @@ describe MoneyTree::PublicKey do
92
111
  end
93
112
 
94
113
  it "is a valid bitcoin address" do
95
- expect(@key.uncompressed.to_address).to eql('133bJA2xoVqBUsiR3uSkciMo5r15fLAaZg')
114
+ expect(@key.uncompressed.to_address).to eql("133bJA2xoVqBUsiR3uSkciMo5r15fLAaZg")
96
115
  end
97
116
  end
98
117
 
@@ -102,7 +121,17 @@ describe MoneyTree::PublicKey do
102
121
  end
103
122
 
104
123
  it "is a valid compressed bitcoin address" do
105
- expect(@key.compressed.to_address).to eql('13uVqa35BMo4mYq9LiZrXVzoz9EFZ6aoXe')
124
+ expect(@key.compressed.to_address).to eql("13uVqa35BMo4mYq9LiZrXVzoz9EFZ6aoXe")
125
+ end
126
+ end
127
+
128
+ describe "to_p2wpkh_p2sh" do
129
+ it "has 34 characters" do
130
+ expect(@key.to_p2wpkh_p2sh.length).to eql(34)
131
+ end
132
+
133
+ it "is a valid p2wpkh_p2sh bitcoin address" do
134
+ expect(@key.to_p2wpkh_p2sh).to eql("3JUBTtepUbTZgUtjbde7UANs5cey8N57xa")
106
135
  end
107
136
  end
108
137
 
@@ -118,7 +147,7 @@ describe MoneyTree::PublicKey do
118
147
 
119
148
  describe "with a bad key" do
120
149
  it "raises KeyFormatNotFound" do
121
- expect { @key = MoneyTree::PublicKey.new 'THISISNOTAVALIDKEY' }.to raise_error(MoneyTree::Key::KeyFormatNotFound)
150
+ expect { @key = MoneyTree::PublicKey.new "THISISNOTAVALIDKEY" }.to raise_error(MoneyTree::Key::KeyFormatNotFound)
122
151
  end
123
152
  end
124
153
 
@@ -126,7 +155,7 @@ describe MoneyTree::PublicKey do
126
155
  it "produces same results" do
127
156
  results = []
128
157
  100.times do
129
- results << MoneyTree::PublicKey.new('042dfc2557a007c93092c2915f11e8aa70c4f399a6753e2e908330014091580e4b11203096f1a1c5276a73f91b9465357004c2103cc42c63d6d330df589080d2e4').to_s
158
+ results << MoneyTree::PublicKey.new("042dfc2557a007c93092c2915f11e8aa70c4f399a6753e2e908330014091580e4b11203096f1a1c5276a73f91b9465357004c2103cc42c63d6d330df589080d2e4").to_s
130
159
  end
131
160
  expect(results.uniq.length).to eql(1)
132
161
  end
@@ -134,7 +163,7 @@ describe MoneyTree::PublicKey do
134
163
 
135
164
  describe "#uncompressed" do
136
165
  before do
137
- @key = MoneyTree::PublicKey.new('022dfc2557a007c93092c2915f11e8aa70c4f399a6753e2e908330014091580e4b')
166
+ @key = MoneyTree::PublicKey.new("022dfc2557a007c93092c2915f11e8aa70c4f399a6753e2e908330014091580e4b")
138
167
  end
139
168
 
140
169
  it "does not mutate key" do
@@ -147,7 +176,7 @@ describe MoneyTree::PublicKey do
147
176
 
148
177
  describe "#compressed" do
149
178
  before do
150
- @key = MoneyTree::PublicKey.new('042dfc2557a007c93092c2915f11e8aa70c4f399a6753e2e908330014091580e4b11203096f1a1c5276a73f91b9465357004c2103cc42c63d6d330df589080d2e4')
179
+ @key = MoneyTree::PublicKey.new("042dfc2557a007c93092c2915f11e8aa70c4f399a6753e2e908330014091580e4b11203096f1a1c5276a73f91b9465357004c2103cc42c63d6d330df589080d2e4")
151
180
  end
152
181
 
153
182
  it "does not mutate key" do
@@ -160,18 +189,18 @@ describe MoneyTree::PublicKey do
160
189
 
161
190
  context "wobine's blackboard 101 series" do
162
191
  # ref https://github.com/wobine/blackboard101/blob/e991ea0b98fd26059bf3806e5749b5e5f737e791/EllipticCurvesPart4-PrivateKeyToPublicKey.py
163
- subject(:wobine) { MoneyTree::PrivateKey.new key: 'A0DC65FFCA799873CBEA0AC274015B9526505DAAAED385155425F7337704883E' }
192
+ subject(:wobine) { MoneyTree::PrivateKey.new key: "A0DC65FFCA799873CBEA0AC274015B9526505DAAAED385155425F7337704883E" }
164
193
 
165
194
  it "always recovers wobine's public keys" do
166
- expect(wobine.key).to eq 'a0dc65ffca799873cbea0ac274015b9526505daaaed385155425f7337704883e'
195
+ expect(wobine.key).to eq "a0dc65ffca799873cbea0ac274015b9526505daaaed385155425f7337704883e"
167
196
  public_key = MoneyTree::PublicKey.new wobine
168
- expect(public_key.key).to eq '020791dc70b75aa995213244ad3f4886d74d61ccd3ef658243fcad14c9ccee2b0a'
169
- expect(public_key.uncompressed.to_hex).to eq '040791dc70b75aa995213244ad3f4886d74d61ccd3ef658243fcad14c9ccee2b0aa762fbc6ac0921b8f17025bb8458b92794ae87a133894d70d7995fc0b6b5ab90'
197
+ expect(public_key.key).to eq "020791dc70b75aa995213244ad3f4886d74d61ccd3ef658243fcad14c9ccee2b0a"
198
+ expect(public_key.uncompressed.to_hex).to eq "040791dc70b75aa995213244ad3f4886d74d61ccd3ef658243fcad14c9ccee2b0aa762fbc6ac0921b8f17025bb8458b92794ae87a133894d70d7995fc0b6b5ab90"
170
199
  end
171
200
  end
172
201
 
173
202
  context "testnet" do
174
- context 'with private key' do
203
+ context "with private key" do
175
204
  before do
176
205
  @private_key = MoneyTree::PrivateKey.new
177
206
  @key = MoneyTree::PublicKey.new(@private_key)
@@ -186,9 +215,9 @@ describe MoneyTree::PublicKey do
186
215
  end
187
216
  end
188
217
 
189
- context 'without private key' do
218
+ context "without private key" do
190
219
  before do
191
- @key = MoneyTree::PublicKey.new('0297b033ba894611345a0e777861237ef1632370fbd58ebe644eb9f3714e8fe2bc')
220
+ @key = MoneyTree::PublicKey.new("0297b033ba894611345a0e777861237ef1632370fbd58ebe644eb9f3714e8fe2bc")
192
221
  end
193
222
 
194
223
  it "should have an address starting with m or n" do
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe MoneyTree::Support do
4
4
  include MoneyTree::Support
data/spec/spec_helper.rb CHANGED
@@ -1,2 +1,15 @@
1
- require 'money-tree'
2
- require 'pry'
1
+ # use the local version of the code instead of a globally installed gem
2
+ $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
3
+
4
+ # only run coverage reports on github actions
5
+ if ENV["COVERAGE"]
6
+ require "simplecov"
7
+ SimpleCov.start
8
+ require "codecov"
9
+ SimpleCov.formatter = SimpleCov::Formatter::Codecov
10
+ end
11
+
12
+ require "money-tree"
13
+
14
+ RSpec.configure do |config|
15
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: money-tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Winkelspecht
@@ -10,77 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
  date: 2022-11-03 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: openssl
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - ">="
19
- - !ruby/object:Gem::Version
20
- version: '2.2'
21
- type: :runtime
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- version: '2.2'
28
- - !ruby/object:Gem::Dependency
29
- name: bundler
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - "~>"
33
- - !ruby/object:Gem::Version
34
- version: '2.2'
35
- type: :development
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - "~>"
40
- - !ruby/object:Gem::Version
41
- version: '2.2'
42
- - !ruby/object:Gem::Dependency
43
- name: rake
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - "~>"
47
- - !ruby/object:Gem::Version
48
- version: '13.0'
49
- type: :development
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - "~>"
54
- - !ruby/object:Gem::Version
55
- version: '13.0'
56
- - !ruby/object:Gem::Dependency
57
- name: rspec
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - "~>"
61
- - !ruby/object:Gem::Version
62
- version: '3.10'
63
- type: :development
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - "~>"
68
- - !ruby/object:Gem::Version
69
- version: '3.10'
70
- - !ruby/object:Gem::Dependency
71
- name: pry
72
- requirement: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - "~>"
75
- - !ruby/object:Gem::Version
76
- version: '0.4'
77
- type: :development
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - "~>"
82
- - !ruby/object:Gem::Version
83
- version: '0.4'
13
+ dependencies: []
84
14
  description: A Ruby Gem implementation of Bitcoin HD Wallets
85
15
  email:
86
16
  - winkelspecht@gmail.com
@@ -98,6 +28,7 @@ files:
98
28
  - README.md
99
29
  - Rakefile
100
30
  - certs/mattatgemco.pem
31
+ - checksum/money-tree-0.11.0.gem.sha512
101
32
  - checksum/money-tree-0.9.0.gem.sha512
102
33
  - lib/money-tree.rb
103
34
  - lib/money-tree/address.rb
@@ -108,17 +39,22 @@ files:
108
39
  - lib/money-tree/version.rb
109
40
  - lib/openssl_extensions.rb
110
41
  - money-tree.gemspec
111
- - spec/lib/money-tree/address_spec.rb
112
- - spec/lib/money-tree/node_spec.rb
113
- - spec/lib/money-tree/openssl_extensions_spec.rb
114
- - spec/lib/money-tree/private_key_spec.rb
115
- - spec/lib/money-tree/public_key_spec.rb
116
- - spec/lib/money-tree/support_spec.rb
42
+ - spec/money-tree/address_spec.rb
43
+ - spec/money-tree/money_tree_spec.rb
44
+ - spec/money-tree/node_spec.rb
45
+ - spec/money-tree/openssl_extensions_spec.rb
46
+ - spec/money-tree/private_key_spec.rb
47
+ - spec/money-tree/public_key_spec.rb
48
+ - spec/money-tree/support_spec.rb
117
49
  - spec/spec_helper.rb
118
- homepage: https://github.com/gemhq/money-tree
50
+ homepage: https://github.com/GemHQ/money-tree
119
51
  licenses:
120
52
  - MIT
121
- metadata: {}
53
+ metadata:
54
+ homepage_uri: https://github.com/GemHQ/money-tree
55
+ source_code_uri: https://github.com/GemHQ/money-tree
56
+ github_repo: https://github.com/GemHQ/money-tree
57
+ bug_tracker_uri: https://github.com/GemHQ/money-tree/issues
122
58
  post_install_message:
123
59
  rdoc_options: []
124
60
  require_paths:
@@ -127,7 +63,10 @@ required_ruby_version: !ruby/object:Gem::Requirement
127
63
  requirements:
128
64
  - - ">="
129
65
  - !ruby/object:Gem::Version
130
- version: '0'
66
+ version: '2.6'
67
+ - - "<"
68
+ - !ruby/object:Gem::Version
69
+ version: '4.0'
131
70
  required_rubygems_version: !ruby/object:Gem::Requirement
132
71
  requirements:
133
72
  - - ">="
@@ -139,10 +78,11 @@ signing_key:
139
78
  specification_version: 4
140
79
  summary: Bitcoin Hierarchical Deterministic Wallets in Ruby! (Bitcoin standard BIP0032)
141
80
  test_files:
142
- - spec/lib/money-tree/address_spec.rb
143
- - spec/lib/money-tree/node_spec.rb
144
- - spec/lib/money-tree/openssl_extensions_spec.rb
145
- - spec/lib/money-tree/private_key_spec.rb
146
- - spec/lib/money-tree/public_key_spec.rb
147
- - spec/lib/money-tree/support_spec.rb
81
+ - spec/money-tree/address_spec.rb
82
+ - spec/money-tree/money_tree_spec.rb
83
+ - spec/money-tree/node_spec.rb
84
+ - spec/money-tree/openssl_extensions_spec.rb
85
+ - spec/money-tree/private_key_spec.rb
86
+ - spec/money-tree/public_key_spec.rb
87
+ - spec/money-tree/support_spec.rb
148
88
  - spec/spec_helper.rb