straight 0.2.2 → 0.2.3

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: 04d8199335a24cd3a0c22e95a2db1cc8576e6d57
4
- data.tar.gz: c20786d5a8b3461583df5cc9ee882ee387f5af19
3
+ metadata.gz: 47b083622bc343959f9614caf0a90263c117e490
4
+ data.tar.gz: 7b6fd9a56ffae2d8e20d75c8f69c4bdcc5562978
5
5
  SHA512:
6
- metadata.gz: 59bf81e312babcdaf4e3fb22b80c32ecdb30852484b91490adaa310aa2891c664b9812315644aa25838caa4019fd8be019e8b95b19f2f78c62d6bace037e3308
7
- data.tar.gz: 8c9d2819814f9989d19cfbca2b4de5ef92b9bea5e6a2bca3f88cacfbb513224f97216488dca116537d0e9f6760b73de8c5021d6efdb52cfe212bdfad7018598f
6
+ metadata.gz: 2c750fa3761f2967e448b3b7c8256e60b1815abe215a22bfad1f3c953283a3e46268735084cd8debc2b73d176e3486f81fbe576ed5f1eb789794641454c4dac4
7
+ data.tar.gz: 9ca4bb9f861caf0d57d02ef2d415c5db3adba2fa1b4a3ff39e72272c6d311fd5a9f291d0471326efcbe82e33a565e596c2f9c2b724d9a38f0d53b7d7ed4a6730
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  # Used to generate bip32 addresses
4
- gem 'money-tree'
4
+ gem 'money-tree', "0.9.0"
5
5
 
6
6
  # Used in exchange rate adapters
7
7
  gem 'satoshi-unit'
data/Gemfile.lock CHANGED
@@ -8,7 +8,7 @@ GEM
8
8
  diff-lcs (1.2.5)
9
9
  faraday (0.9.0)
10
10
  multipart-post (>= 1.2, < 3)
11
- ffi (1.9.3)
11
+ ffi (1.9.8)
12
12
  git (1.2.8)
13
13
  github_api (0.11.3)
14
14
  addressable (~> 2.3)
@@ -35,7 +35,7 @@ GEM
35
35
  json (1.8.1)
36
36
  jwt (1.0.0)
37
37
  mini_portile (0.6.0)
38
- money-tree (0.8.7)
38
+ money-tree (0.9.0)
39
39
  ffi
40
40
  multi_json (1.10.1)
41
41
  multi_xml (0.5.5)
@@ -75,6 +75,6 @@ DEPENDENCIES
75
75
  github_api (= 0.11.3)
76
76
  httparty
77
77
  jeweler (~> 2.0.1)
78
- money-tree
78
+ money-tree (= 0.9.0)
79
79
  rspec
80
80
  satoshi-unit
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.3
@@ -87,8 +87,13 @@ module Straight
87
87
  # the one a user of this class is going to properly increment) that is used to generate a
88
88
  # an BIP32 bitcoin address deterministically.
89
89
  def address_for_keychain_id(id)
90
- # The 'm/0/n' notation is used by both Electrum and Mycelium
91
- keychain.node_for_path("m/0/#{id.to_s}").to_address
90
+ # First check the depth. If the depth is 4 use '/i' notation (Mycelium iOS wallet)
91
+ # TODO deal with other depths later. Currently only supports 0 and 4
92
+ if keychain.depth > 0
93
+ keychain.node_for_path(id.to_s).to_address
94
+ else # Otherwise, use 'm/0/n' - both Electrum and Mycelium on Android
95
+ keychain.node_for_path("m/0/#{id.to_s}").to_address
96
+ end
92
97
  end
93
98
 
94
99
  def fetch_transaction(tid, address: nil)
@@ -104,7 +109,7 @@ module Straight
104
109
  end
105
110
 
106
111
  def keychain
107
- @keychain ||= MoneyTree::Node.from_serialized_address(pubkey)
112
+ @keychain ||= MoneyTree::Node.from_bip32(pubkey)
108
113
  end
109
114
 
110
115
  # This is a callback method called from each order
@@ -46,10 +46,15 @@ RSpec.describe Straight::Gateway do
46
46
  expect(@gateway.order_for_keychain_id(amount: 1, keychain_id: 1).address).to eq(expected_address)
47
47
  end
48
48
 
49
+ it "checks the depth of the xpub key and uses derivation notation according to the depth" do
50
+ @gateway.pubkey = 'xpub6DkF8MtNnbJY6NBR5tBSZ2NYQL16sT4fiT1R8U4D24bfSNmzzbhzNdP25LLgmis6c7EsVdzdUqv1MZoU8TNHaNNRHfTE1hqXRNMfPyJ2fCw'
51
+ expect(@gateway.address_for_keychain_id(0)).to eq("1GS7KMkpz27xpFKddFPkjqCAAPPo9eyUev")
52
+ end
53
+
49
54
  it "calls all the order callbacks" do
50
55
  callback1 = double('callback1')
51
56
  callback2 = double('callback1')
52
- @gateway.pubkey = MoneyTree::Master.new.to_serialized_address
57
+ @gateway.pubkey = MoneyTree::Master.new.to_bip32
53
58
  @gateway.order_callbacks = [callback1, callback2]
54
59
 
55
60
  order = @gateway.order_for_keychain_id(amount: 1, keychain_id: 1)
data/straight.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: straight 0.2.2 ruby lib
5
+ # stub: straight 0.2.3 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "straight"
9
- s.version = "0.2.2"
9
+ s.version = "0.2.3"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Roman Snitko"]
14
- s.date = "2015-05-07"
14
+ s.date = "2015-05-30"
15
15
  s.description = "An engine for the Straight payment gateway software. Requires no state to be saved (that is, no storage or DB). Its responsibilities only include processing data coming from an actual gateway."
16
16
  s.email = "roman.snitko@gmail.com"
17
17
  s.extra_rdoc_files = [
@@ -69,14 +69,14 @@ Gem::Specification.new do |s|
69
69
  s.specification_version = 4
70
70
 
71
71
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
72
- s.add_runtime_dependency(%q<money-tree>, [">= 0"])
72
+ s.add_runtime_dependency(%q<money-tree>, ["= 0.9.0"])
73
73
  s.add_runtime_dependency(%q<satoshi-unit>, [">= 0"])
74
74
  s.add_runtime_dependency(%q<httparty>, [">= 0"])
75
75
  s.add_development_dependency(%q<bundler>, ["~> 1.0"])
76
76
  s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
77
77
  s.add_development_dependency(%q<github_api>, ["= 0.11.3"])
78
78
  else
79
- s.add_dependency(%q<money-tree>, [">= 0"])
79
+ s.add_dependency(%q<money-tree>, ["= 0.9.0"])
80
80
  s.add_dependency(%q<satoshi-unit>, [">= 0"])
81
81
  s.add_dependency(%q<httparty>, [">= 0"])
82
82
  s.add_dependency(%q<bundler>, ["~> 1.0"])
@@ -84,7 +84,7 @@ Gem::Specification.new do |s|
84
84
  s.add_dependency(%q<github_api>, ["= 0.11.3"])
85
85
  end
86
86
  else
87
- s.add_dependency(%q<money-tree>, [">= 0"])
87
+ s.add_dependency(%q<money-tree>, ["= 0.9.0"])
88
88
  s.add_dependency(%q<satoshi-unit>, [">= 0"])
89
89
  s.add_dependency(%q<httparty>, [">= 0"])
90
90
  s.add_dependency(%q<bundler>, ["~> 1.0"])
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: straight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Snitko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-07 00:00:00.000000000 Z
11
+ date: 2015-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: money-tree
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 0.9.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
- version: '0'
26
+ version: 0.9.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: satoshi-unit
29
29
  requirement: !ruby/object:Gem::Requirement