straight-server 0.2.3 → 1.0.0

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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -2
  3. data/Gemfile +21 -16
  4. data/Gemfile.lock +44 -30
  5. data/Gemfile.travis +15 -16
  6. data/README.md +66 -47
  7. data/VERSION +1 -1
  8. data/db/migrations/011_add_callback_data_to_orders.rb +1 -1
  9. data/db/migrations/012_add_address_provider.rb +11 -0
  10. data/db/migrations/013_add_address_derivation_scheme.rb +11 -0
  11. data/db/migrations/014_pubkey_null_address_provider_not_null.rb +8 -0
  12. data/db/migrations/015_add_amount_paid_to_orders.rb +11 -0
  13. data/db/migrations/016_add_new_params_to_orders.rb +13 -0
  14. data/db/migrations/017_add_test_mode_to_gateways.rb +11 -0
  15. data/db/migrations/018_add_test_keychain_id_to_gateways.rb +11 -0
  16. data/db/migrations/019_add_test_pubkey_to_gateways.rb +11 -0
  17. data/db/migrations/020_add_test_mode_to_orders.rb +11 -0
  18. data/db/schema.rb +11 -1
  19. data/lib/straight-server.rb +11 -9
  20. data/lib/straight-server/config.rb +28 -18
  21. data/lib/straight-server/gateway.rb +167 -87
  22. data/lib/straight-server/initializer.rb +13 -7
  23. data/lib/straight-server/order.rb +39 -17
  24. data/lib/straight-server/orders_controller.rb +71 -21
  25. data/lib/straight-server/random_string.rb +3 -13
  26. data/lib/straight-server/server.rb +3 -4
  27. data/lib/straight-server/signature_validator.rb +69 -0
  28. data/lib/straight-server/thread.rb +19 -4
  29. data/lib/straight-server/throttler.rb +7 -13
  30. data/lib/tasks/db.rake +1 -1
  31. data/spec/.straight/config.yml +8 -3
  32. data/spec/.straight/default_test_last_keychain_id +1 -0
  33. data/spec/factories.rb +2 -1
  34. data/spec/lib/gateway_spec.rb +222 -94
  35. data/spec/lib/initializer_spec.rb +1 -1
  36. data/spec/lib/order_spec.rb +26 -7
  37. data/spec/lib/orders_controller_spec.rb +65 -6
  38. data/spec/lib/signature_validator_spec.rb +72 -0
  39. data/spec/lib/thread_spec.rb +16 -0
  40. data/spec/lib/throttle_spec.rb +2 -2
  41. data/spec/spec_helper.rb +17 -22
  42. data/straight-server.gemspec +31 -12
  43. data/templates/config.yml +19 -10
  44. metadata +52 -11
@@ -2,13 +2,10 @@
2
2
  # useful when your run many gateways on the same server.
3
3
  gateways_source: config
4
4
 
5
+ # Used for:
6
+ # - scoping Redis keys
5
7
  environment: development
6
8
 
7
- # This enabled order counting using Redis. Please see he README file for details.
8
- # You're gonna need to install redis-server and redis rubygem on your system and provide
9
- # redis-server connection details below.
10
- count_orders: false
11
-
12
9
  # When you display a payment window to a user, he has some time to pay. But what if a
13
10
  # transaction has been made in the last seconds and Straight didn't have time to detect it?
14
11
  # This just adds a little bit more time to each expiration period.
@@ -24,6 +21,9 @@ expiration_overtime: 30
24
21
  # technically receive the money, but it's never detected by the wallet.
25
22
  reuse_address_orders_threshold: 20
26
23
 
24
+ # Comment out to disable orders counting.
25
+ count_orders: true
26
+
27
27
  # Uncomment this if you want to limit orders creation rate.
28
28
  # For example, if user's cat makes more than 21 new orders during 60 seconds (from the same IP and Widget),
29
29
  # any user with this IP will be unable to create more orders via this Widget during those 60 seconds
@@ -33,11 +33,9 @@ reuse_address_orders_threshold: 20
33
33
  # period: 60 # in seconds
34
34
  # ip_ban_duration: 300 # in seconds
35
35
 
36
- # Uncomment this if you want to use Gateway's order counters feature
37
- # It requires redis.
38
- #redis:
39
- #host: localhost
40
- #port: 6380
36
+ redis:
37
+ host: localhost
38
+ port: 6379
41
39
  #db: null # change to 1, 2, 3 etc. or leave as is
42
40
  #password: null # if no password is needed, leave as is
43
41
 
@@ -52,6 +50,9 @@ gateways:
52
50
  default_currency: 'BTC'
53
51
  orders_expiration_period: 600 # seconds
54
52
 
53
+ # address_provider: 'Bip32'
54
+ # address_derivation_scheme: 'm/0/n'
55
+
55
56
  # This options decides whether we should also check the DB for status updates first
56
57
  # when we check order status. That is, if we're tracking an order and this option
57
58
  # is set to true, it first fetches the fields from the local DB, sees if the status has changed there,
@@ -74,6 +75,8 @@ gateways:
74
75
  # If it's set to false, then it won't be possible to create a new order, but
75
76
  # it will keep checking on the existing ones.
76
77
  active: true
78
+ # If this option set to true, gateway using TESTNET
79
+ test_mode: true
77
80
 
78
81
  # These adapters are used to query the blockchain. If the first one fails, the second one is tried and
79
82
  # so on. The adapters are generally looked up as subclasses of Straight::Blockchain::Adapter
@@ -82,8 +85,14 @@ gateways:
82
85
  blockchain_adapters:
83
86
  - BlockchainInfo # uses Straight::Blockchain::BlockchainInfoAdapter
84
87
  - Mycelium # uses Straight::Blockchain::MyceliumAdapter
88
+ # - InsightAdapter # uses Straight::Blockchain::InsightAdapter
85
89
  # - MyCustomClass::MyCustomBlockchainAdapter
86
90
 
91
+ # If Insight adapter is enabled, it is necessary to provide a url for it.
92
+ # insight_url: "https://localhost/api"
93
+ # You can also set a testnet insight url to use:
94
+ # insight_test_url: "https://test.localhost/api"
95
+
87
96
  logmaster:
88
97
  log_level: INFO # Wise to change to WARN for production
89
98
  file: straight.log
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: straight-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 1.0.0
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-30 00:00:00.000000000 Z
11
+ date: 2015-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: straight
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.2.2
19
+ version: 1.0.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.2.2
26
+ version: 1.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: satoshi-unit
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 0.1.8
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 0.1.8
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: goliath
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -123,19 +123,47 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: money-tree
126
+ name: redis
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
- version: 0.9.0
131
+ version: '0'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '='
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: btcruby
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
+ - !ruby/object:Gem::Dependency
154
+ name: byebug
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
137
158
  - !ruby/object:Gem::Version
138
- version: 0.9.0
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
139
167
  - !ruby/object:Gem::Dependency
140
168
  name: bundler
141
169
  requirement: !ruby/object:Gem::Requirement
@@ -218,6 +246,15 @@ files:
218
246
  - db/migrations/009_add_hashed_id_to_gateways.rb
219
247
  - db/migrations/010_add_address_reusability_orders.rb
220
248
  - db/migrations/011_add_callback_data_to_orders.rb
249
+ - db/migrations/012_add_address_provider.rb
250
+ - db/migrations/013_add_address_derivation_scheme.rb
251
+ - db/migrations/014_pubkey_null_address_provider_not_null.rb
252
+ - db/migrations/015_add_amount_paid_to_orders.rb
253
+ - db/migrations/016_add_new_params_to_orders.rb
254
+ - db/migrations/017_add_test_mode_to_gateways.rb
255
+ - db/migrations/018_add_test_keychain_id_to_gateways.rb
256
+ - db/migrations/019_add_test_pubkey_to_gateways.rb
257
+ - db/migrations/020_add_test_mode_to_orders.rb
221
258
  - db/schema.rb
222
259
  - examples/client/client.dart
223
260
  - examples/client/client.html
@@ -231,11 +268,13 @@ files:
231
268
  - lib/straight-server/orders_controller.rb
232
269
  - lib/straight-server/random_string.rb
233
270
  - lib/straight-server/server.rb
271
+ - lib/straight-server/signature_validator.rb
234
272
  - lib/straight-server/thread.rb
235
273
  - lib/straight-server/throttler.rb
236
274
  - lib/straight-server/utils/hash_string_to_sym_keys.rb
237
275
  - lib/tasks/db.rake
238
276
  - spec/.straight/config.yml
277
+ - spec/.straight/default_test_last_keychain_id
239
278
  - spec/.straight/server_secret
240
279
  - spec/factories.rb
241
280
  - spec/fixtures/addons.yml
@@ -244,6 +283,8 @@ files:
244
283
  - spec/lib/initializer_spec.rb
245
284
  - spec/lib/order_spec.rb
246
285
  - spec/lib/orders_controller_spec.rb
286
+ - spec/lib/signature_validator_spec.rb
287
+ - spec/lib/thread_spec.rb
247
288
  - spec/lib/throttle_spec.rb
248
289
  - spec/lib/utils/hash_string_to_sym_keys.rb
249
290
  - spec/spec_helper.rb