peatio-goldcash 2.6.3 → 2.6.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/Gemfile +3 -1
- data/Gemfile.lock +34 -2
- data/LICENSE.txt +12 -21
- data/README.md +7 -35
- data/Rakefile +3 -1
- data/bin/console +1 -0
- data/lib/peatio/goldcash.rb +3 -1
- data/lib/peatio/goldcash/blockchain.rb +65 -53
- data/lib/peatio/goldcash/client.rb +41 -45
- data/lib/peatio/goldcash/hooks.rb +4 -2
- data/lib/peatio/goldcash/railtie.rb +2 -0
- data/lib/peatio/goldcash/version.rb +3 -1
- data/lib/peatio/goldcash/wallet.rb +57 -59
- data/peatio-goldcash.gemspec +27 -11
- metadata +56 -17
- data/config/blockchains.yml +0 -10
- data/config/currencies.yml +0 -18
- data/config/wallets.yml +0 -44
- data/docs/integration.md +0 -29
- data/docs/json-rpc.md +0 -29
- data/docs/testnet.md +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b49233782ebd62a00898f80b007c2f99ef10a04d2ee39c4a9a5a34efde9574b
|
4
|
+
data.tar.gz: dda5b4346240f310818627794a9d3b2b3211a029405aa352eb122c977cc86e12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30d0f806e2303a6ea6ed90682c218e75178d54ffdeab20bbf8b7dfd16a2d35af710135524df29c95b2e0e0b3355e8e85ca0a2bc51a81af669f0d466629badbc9
|
7
|
+
data.tar.gz: 86eac432bfac27e3345408031321c9f099d266dac65ba0b8f8b8fa55127ccbc25dac633d73c561e7258e5b00d10bfd0fd4be6193858a931e1b0787f6394ad891
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source "https://rubygems.org"
|
2
4
|
|
3
5
|
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
4
6
|
|
5
|
-
# Specify your gem's dependencies in peatio-
|
7
|
+
# Specify your gem's dependencies in peatio-gold.gemspec
|
6
8
|
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
peatio-goldcash (2.6.
|
4
|
+
peatio-goldcash (2.6.8)
|
5
5
|
activesupport (~> 5.2.3)
|
6
6
|
better-faraday (~> 1.0.5)
|
7
7
|
faraday (~> 0.17)
|
@@ -25,6 +25,7 @@ GEM
|
|
25
25
|
amqp (1.8.0)
|
26
26
|
amq-protocol (>= 2.2.0)
|
27
27
|
eventmachine
|
28
|
+
ast (2.4.0)
|
28
29
|
better-faraday (1.0.8)
|
29
30
|
activesupport (>= 4.0, < 6.0)
|
30
31
|
faraday (~> 0.12)
|
@@ -40,6 +41,7 @@ GEM
|
|
40
41
|
safe_yaml (~> 1.0.0)
|
41
42
|
daemons (1.3.1)
|
42
43
|
diff-lcs (1.3)
|
44
|
+
docile (1.3.2)
|
43
45
|
em-http-request (1.1.6)
|
44
46
|
addressable (>= 2.3.4)
|
45
47
|
cookiejar (!= 0.3.1)
|
@@ -73,6 +75,10 @@ GEM
|
|
73
75
|
http_parser.rb (0.6.0)
|
74
76
|
i18n (1.8.3)
|
75
77
|
concurrent-ruby (~> 1.0)
|
78
|
+
io-console (0.5.6)
|
79
|
+
irb (1.2.3)
|
80
|
+
reline (>= 0.0.1)
|
81
|
+
jaro_winkler (1.5.4)
|
76
82
|
jwt (2.2.1)
|
77
83
|
memoist (0.16.2)
|
78
84
|
method_source (1.0.0)
|
@@ -83,6 +89,9 @@ GEM
|
|
83
89
|
mysql2 (0.5.3)
|
84
90
|
net-http-persistent (3.0.1)
|
85
91
|
connection_pool (~> 2.2)
|
92
|
+
parallel (1.19.1)
|
93
|
+
parser (2.7.0.5)
|
94
|
+
ast (~> 2.4.0)
|
86
95
|
peatio (2.6.1)
|
87
96
|
activemodel (> 5.2, <= 6.0.0)
|
88
97
|
amqp
|
@@ -106,7 +115,11 @@ GEM
|
|
106
115
|
pry (~> 0.13.0)
|
107
116
|
public_suffix (4.0.4)
|
108
117
|
rack (2.2.3)
|
118
|
+
rainbow (3.0.0)
|
109
119
|
rake (13.0.1)
|
120
|
+
reline (0.1.3)
|
121
|
+
io-console (~> 0.5)
|
122
|
+
rexml (3.2.4)
|
110
123
|
rspec (3.9.0)
|
111
124
|
rspec-core (~> 3.9.0)
|
112
125
|
rspec-expectations (~> 3.9.0)
|
@@ -120,7 +133,22 @@ GEM
|
|
120
133
|
diff-lcs (>= 1.2.0, < 2.0)
|
121
134
|
rspec-support (~> 3.9.0)
|
122
135
|
rspec-support (3.9.2)
|
136
|
+
rubocop (0.80.1)
|
137
|
+
jaro_winkler (~> 1.5.1)
|
138
|
+
parallel (~> 1.10)
|
139
|
+
parser (>= 2.7.0.1)
|
140
|
+
rainbow (>= 2.2.2, < 4.0)
|
141
|
+
rexml
|
142
|
+
ruby-progressbar (~> 1.7)
|
143
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
144
|
+
rubocop-github (0.14.0)
|
145
|
+
rubocop (~> 0.59)
|
146
|
+
ruby-progressbar (1.10.1)
|
123
147
|
safe_yaml (1.0.5)
|
148
|
+
simplecov (0.18.5)
|
149
|
+
docile (~> 1.1)
|
150
|
+
simplecov-html (~> 0.11)
|
151
|
+
simplecov-html (0.12.2)
|
124
152
|
thin (1.7.2)
|
125
153
|
daemons (~> 1.0, >= 1.0.9)
|
126
154
|
eventmachine (~> 1.0, >= 1.0.4)
|
@@ -128,6 +156,7 @@ GEM
|
|
128
156
|
thread_safe (0.3.6)
|
129
157
|
tzinfo (1.2.7)
|
130
158
|
thread_safe (~> 0.1)
|
159
|
+
unicode-display_width (1.6.1)
|
131
160
|
webmock (3.8.3)
|
132
161
|
addressable (>= 2.3.6)
|
133
162
|
crack (>= 0.3.2)
|
@@ -140,12 +169,15 @@ PLATFORMS
|
|
140
169
|
ruby
|
141
170
|
|
142
171
|
DEPENDENCIES
|
143
|
-
bundler (~> 1.
|
172
|
+
bundler (~> 1.17)
|
173
|
+
irb
|
144
174
|
mocha (~> 1.8)
|
145
175
|
peatio-goldcash!
|
146
176
|
pry-byebug
|
147
177
|
rake (~> 13.0)
|
148
178
|
rspec (~> 3.0)
|
179
|
+
rubocop-github
|
180
|
+
simplecov
|
149
181
|
webmock (~> 3.5)
|
150
182
|
|
151
183
|
BUNDLED WITH
|
data/LICENSE.txt
CHANGED
@@ -1,21 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
in
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|
1
|
+
Copyright (C) Alcox.biz - All Rights Reserved
|
2
|
+
|
3
|
+
NOTICE: All information contained herein is, and remains
|
4
|
+
the property of Alcox.biz and its suppliers, if any.
|
5
|
+
The intellectual and technical concepts contained herein are proprietary to Alcox.biz
|
6
|
+
and its suppliers and may be covered by U.S. and Foreign Patents,
|
7
|
+
patents in process, and are protected by trade secret or copyright law.
|
8
|
+
Dissemination of this information or reproduction of this material
|
9
|
+
is strictly forbidden unless prior written permission is obtained
|
10
|
+
from Alcox.biz.
|
11
|
+
|
12
|
+
Proprietary and confidential
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Peatio::Goldcash
|
2
2
|
|
3
|
-
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/peatio/gold`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
@@ -20,38 +22,13 @@ Or install it yourself as:
|
|
20
22
|
|
21
23
|
## Usage
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
### Image Build.
|
26
|
-
|
27
|
-
1. Add peatio-goldcash gem into your Gemfile.plugin
|
28
|
-
```ruby
|
29
|
-
gem 'peatio-goldcash', '~> 0.2.0'
|
30
|
-
```
|
31
|
-
|
32
|
-
2. Run `bundle install` for updating Gemfile.lock
|
33
|
-
|
34
|
-
3. Build custom Peatio [docker image with Goldcash plugin](https://github.com/rubykube/peatio/blob/master/docs/plugins.md#build)
|
35
|
-
|
36
|
-
4. Push your image using `docker push`
|
37
|
-
|
38
|
-
5. Update your deployment to use image with peatio-goldcash gem
|
39
|
-
|
40
|
-
### Peatio Configuration.
|
41
|
-
|
42
|
-
1. Create Goldcash Blockchain [config example](../config/blockchains.yml).
|
43
|
-
* No additional steps are needed
|
44
|
-
|
45
|
-
2. Create Goldcash Currency [config example](../config/currencies.yml).
|
46
|
-
* No additional steps are needed
|
47
|
-
|
48
|
-
3. Create Goldcash Wallets [config example](../config/wallets.yml)(deposit and hot wallets are required).
|
49
|
-
* No additional steps are needed
|
50
|
-
|
25
|
+
TODO: Write usage instructions here
|
51
26
|
|
52
27
|
## Development
|
53
28
|
|
54
|
-
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
55
32
|
|
56
33
|
## Contributing
|
57
34
|
|
@@ -60,8 +37,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/alcoxb
|
|
60
37
|
## License
|
61
38
|
|
62
39
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
63
|
-
|
64
|
-
## Consulting
|
65
|
-
|
66
|
-
You can contact Openware for finding certified vendors:
|
67
|
-
[Openware.com](https://www.openware.com)
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
data/lib/peatio/goldcash.rb
CHANGED
@@ -1,84 +1,96 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Peatio
|
2
|
-
|
3
|
-
|
4
|
-
|
4
|
+
module Goldcash
|
5
|
+
# TODO: Processing of unconfirmed transactions from mempool isn't supported now.
|
6
|
+
class Blockchain < Peatio::Blockchain::Abstract
|
5
7
|
|
6
|
-
|
8
|
+
DEFAULT_FEATURES = {case_sensitive: true, cash_addr_format: false}.freeze
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
def initialize(custom_features = {})
|
11
|
+
@features = DEFAULT_FEATURES.merge(custom_features).slice(*SUPPORTED_FEATURES)
|
12
|
+
@settings = {}
|
13
|
+
end
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
def configure(settings = {})
|
16
|
+
# Clean client state during configure.
|
17
|
+
@client = nil
|
18
|
+
@settings.merge!(settings.slice(*SUPPORTED_SETTINGS))
|
19
|
+
end
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
+
def fetch_block!(block_number)
|
22
|
+
block_hash = client.json_rpc(:getblockhash, [block_number])
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
+
client.json_rpc(:getblock, [block_hash])
|
25
|
+
.fetch('tx').each_with_object([]) do |tx, txs_array|
|
24
26
|
txs = build_transaction(tx).map do |ntx|
|
25
27
|
Peatio::Transaction.new(ntx.merge(block_number: block_number))
|
26
28
|
end
|
27
29
|
txs_array.append(*txs)
|
28
30
|
end.yield_self { |txs_array| Peatio::Block.new(block_number, txs_array) }
|
29
|
-
|
30
|
-
|
31
|
-
|
31
|
+
rescue Goldcash::Client::Error => e
|
32
|
+
raise Peatio::Blockchain::ClientError, e
|
33
|
+
end
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
def latest_block_number
|
36
|
+
client.json_rpc(:getblockcount)
|
37
|
+
rescue Goldcash::Client::Error => e
|
38
|
+
raise Peatio::Blockchain::ClientError, e
|
39
|
+
end
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
def transaction_sources(transaction)
|
42
|
+
transaction_hash = client.json_rpc(:getrawtransaction, [transaction.hash, 1])
|
43
|
+
transaction_hash['vin'].each_with_object([]) do |vin, source_addresses|
|
44
|
+
next if vin['txid'].blank?
|
43
45
|
|
44
|
-
|
45
|
-
|
46
|
-
|
46
|
+
vin_transaction = client.json_rpc(:getrawtransaction, [vin['txid'], 1])
|
47
|
+
source = vin_transaction['vout'].find { |hash| hash['n'] == vin['vout'] }
|
48
|
+
source_addresses << source['scriptPubKey']['addresses'][0]
|
49
|
+
end.compact.uniq
|
50
|
+
end
|
51
|
+
|
52
|
+
def load_balance_of_address!(address, _currency_id)
|
53
|
+
address_with_balance = client.json_rpc(:listaddressgroupings)
|
54
|
+
.flatten(1)
|
55
|
+
.find { |addr| addr[0] == address }
|
47
56
|
|
48
|
-
|
49
|
-
|
50
|
-
raise Peatio::Blockchain::ClientError, e
|
57
|
+
if address_with_balance.blank?
|
58
|
+
raise Peatio::Blockchain::UnavailableAddressBalanceError, address
|
51
59
|
end
|
52
60
|
|
53
|
-
|
61
|
+
address_with_balance[1].to_d
|
62
|
+
rescue Goldcash::Client::Error => e
|
63
|
+
raise Peatio::Blockchain::ClientError, e
|
64
|
+
end
|
54
65
|
|
55
|
-
|
56
|
-
|
57
|
-
|
66
|
+
private
|
67
|
+
|
68
|
+
def build_transaction(tx_hash)
|
69
|
+
tx_hash.fetch('vout')
|
70
|
+
.select do |entry|
|
58
71
|
entry.fetch('value').to_d > 0 &&
|
59
|
-
|
72
|
+
entry['scriptPubKey'].has_key?('addresses')
|
60
73
|
end
|
61
|
-
|
74
|
+
.each_with_object([]) do |entry, formatted_txs|
|
62
75
|
no_currency_tx =
|
63
76
|
{ hash: tx_hash['txid'], txout: entry['n'],
|
64
77
|
to_address: entry['scriptPubKey']['addresses'][0],
|
65
78
|
amount: entry.fetch('value').to_d,
|
66
79
|
status: 'success' }
|
67
80
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
81
|
+
# Build transaction for each currency belonging to blockchain.
|
82
|
+
settings_fetch(:currencies).pluck(:id).each do |currency_id|
|
83
|
+
formatted_txs << no_currency_tx.merge(currency_id: currency_id)
|
84
|
+
end
|
72
85
|
end
|
73
|
-
|
86
|
+
end
|
74
87
|
|
75
|
-
|
76
|
-
|
77
|
-
|
88
|
+
def client
|
89
|
+
@client ||= Goldcash::Client.new(settings_fetch(:server))
|
90
|
+
end
|
78
91
|
|
79
|
-
|
80
|
-
|
81
|
-
end
|
92
|
+
def settings_fetch(key)
|
93
|
+
@settings.fetch(key) { raise Peatio::Blockchain::MissingSettingError, key.to_s }
|
82
94
|
end
|
83
95
|
end
|
84
|
-
end
|
96
|
+
end
|
@@ -1,60 +1,56 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require "memoist"
|
4
|
+
require "faraday"
|
5
|
+
require "better-faraday"
|
6
6
|
|
7
7
|
module Peatio
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
ConnectionError = Class.new(Error)
|
12
|
-
|
13
|
-
class ResponseError < Error
|
14
|
-
def initialize(code, msg)
|
15
|
-
@code = code
|
16
|
-
@msg = msg
|
17
|
-
end
|
8
|
+
module Goldcash
|
9
|
+
class Client
|
10
|
+
Error = Class.new(StandardError)
|
18
11
|
|
19
|
-
|
20
|
-
|
21
|
-
|
12
|
+
class ConnectionError < Error; end
|
13
|
+
|
14
|
+
class ResponseError < Error
|
15
|
+
def initialize(code, msg)
|
16
|
+
super "#{msg} (#{code})"
|
22
17
|
end
|
18
|
+
end
|
23
19
|
|
24
|
-
|
20
|
+
extend Memoist
|
25
21
|
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
def initialize(endpoint, idle_timeout: 5)
|
23
|
+
@json_rpc_endpoint = URI.parse(endpoint)
|
24
|
+
@path = @json_rpc_endpoint.path.empty? ? "/" : @json_rpc_endpoint.path
|
25
|
+
@idle_timeout = idle_timeout
|
26
|
+
end
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
28
|
+
def json_rpc(method, params = [])
|
29
|
+
response = connection.post \
|
30
|
+
@path,
|
31
|
+
{jsonrpc: '1.0', method: method, params: params}.to_json,
|
32
|
+
{'Accept' => 'application/json',
|
33
|
+
'Content-Type' => 'application/json'}
|
34
|
+
response.assert_success!
|
35
|
+
response = JSON.parse(response.body)
|
36
|
+
response['error'].tap { |error| raise ResponseError.new(error['code'], error['message']) if error }
|
37
|
+
response.fetch('result')
|
38
|
+
rescue Faraday::Error => e
|
39
|
+
raise ConnectionError, e
|
40
|
+
rescue StandardError => e
|
41
|
+
raise Error, e
|
42
|
+
end
|
45
43
|
|
46
|
-
|
44
|
+
private
|
47
45
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
@json_rpc_endpoint.password)
|
55
|
-
end
|
46
|
+
def connection
|
47
|
+
@connection ||= Faraday.new(@json_rpc_endpoint) do |f|
|
48
|
+
f.adapter :net_http_persistent, pool_size: 5, idle_timeout: @idle_timeout
|
49
|
+
end.tap do |connection|
|
50
|
+
unless @json_rpc_endpoint.user.blank?
|
51
|
+
connection.basic_auth(@json_rpc_endpoint.user, @json_rpc_endpoint.password)
|
56
52
|
end
|
57
53
|
end
|
58
54
|
end
|
59
55
|
end
|
60
|
-
end
|
56
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Peatio
|
2
4
|
module Goldcash
|
3
5
|
module Hooks
|
@@ -12,7 +14,7 @@ module Peatio
|
|
12
14
|
"Goldcash blockchain version requiremnt was not suttisfied by Peatio::Blockchain.",
|
13
15
|
"Goldcash blockchain requires #{BLOCKCHAIN_VERSION_REQUIREMENT}.",
|
14
16
|
"Peatio::Blockchain version is #{Peatio::Blockchain::VERSION}"
|
15
|
-
].join('\n').tap {
|
17
|
+
].join('\n').tap {|s| Kernel.abort s }
|
16
18
|
end
|
17
19
|
|
18
20
|
unless Gem::Requirement.new(WALLET_VERSION_REQUIREMENT)
|
@@ -21,7 +23,7 @@ module Peatio
|
|
21
23
|
"Goldcash wallet version requiremnt was not suttisfied by Peatio::Wallet.",
|
22
24
|
"Goldcash wallet requires #{WALLET_VERSION_REQUIREMENT}.",
|
23
25
|
"Peatio::Wallet version is #{Peatio::Wallet::VERSION}"
|
24
|
-
].join('\n').tap {
|
26
|
+
].join('\n').tap {|s| Kernel.abort s }
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
@@ -1,63 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Peatio
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
def client
|
58
|
-
uri = @wallet.fetch(:uri) { raise Peatio::Wallet::MissingSettingError, :uri }
|
59
|
-
@client ||= Client.new(uri)
|
60
|
-
end
|
4
|
+
module Goldcash
|
5
|
+
class Wallet < Peatio::Wallet::Abstract
|
6
|
+
|
7
|
+
def initialize(settings = {})
|
8
|
+
@settings = settings
|
9
|
+
end
|
10
|
+
|
11
|
+
def configure(settings = {})
|
12
|
+
# Clean client state during configure.
|
13
|
+
@client = nil
|
14
|
+
|
15
|
+
@settings.merge!(settings.slice(*SUPPORTED_SETTINGS))
|
16
|
+
|
17
|
+
@wallet = @settings.fetch(:wallet) do
|
18
|
+
raise Peatio::Wallet::MissingSettingError, :wallet
|
19
|
+
end.slice(:uri, :address)
|
20
|
+
|
21
|
+
@currency = @settings.fetch(:currency) do
|
22
|
+
raise Peatio::Wallet::MissingSettingError, :currency
|
23
|
+
end.slice(:id, :base_factor, :options)
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_address!(_options = {})
|
27
|
+
{ address: client.json_rpc(:getnewaddress) }
|
28
|
+
rescue Goldcash::Client::Error => e
|
29
|
+
raise Peatio::Wallet::ClientError, e
|
30
|
+
end
|
31
|
+
|
32
|
+
def create_transaction!(transaction, options = {})
|
33
|
+
txid = client.json_rpc(:sendtoaddress,
|
34
|
+
[
|
35
|
+
transaction.to_address,
|
36
|
+
transaction.amount,
|
37
|
+
'',
|
38
|
+
'',
|
39
|
+
options[:subtract_fee].to_s == 'true' # subtract fee from transaction amount.
|
40
|
+
])
|
41
|
+
transaction.hash = txid
|
42
|
+
transaction
|
43
|
+
rescue Goldcash::Client::Error => e
|
44
|
+
raise Peatio::Wallet::ClientError, e
|
45
|
+
end
|
46
|
+
|
47
|
+
def load_balance!
|
48
|
+
client.json_rpc(:getbalance).to_d
|
49
|
+
|
50
|
+
rescue Goldcash::Client::Error => e
|
51
|
+
raise Peatio::Wallet::ClientError, e
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def client
|
57
|
+
uri = @wallet.fetch(:uri) { raise Peatio::Wallet::MissingSettingError, :uri }
|
58
|
+
@client ||= Client.new(uri, idle_timeout: 1)
|
61
59
|
end
|
62
60
|
end
|
63
61
|
end
|
data/peatio-goldcash.gemspec
CHANGED
@@ -1,26 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
|
-
lib = File.expand_path("
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require "peatio/goldcash/version"
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
8
|
spec.name = "peatio-goldcash"
|
8
9
|
spec.version = Peatio::Goldcash::VERSION
|
9
|
-
spec.authors = ["
|
10
|
-
spec.email = ["
|
10
|
+
spec.authors = ["D.H."]
|
11
|
+
spec.email = ["dh@alcox.biz"]
|
11
12
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage = "https://
|
15
|
-
spec.license = "
|
13
|
+
spec.summary = "Peatio Blockchain Plugin"
|
14
|
+
spec.description = "Peatio Blockchain Plugin for Rubykube"
|
15
|
+
spec.homepage = "https://github.com/alcoxbiz/"
|
16
|
+
spec.license = "Proprietary"
|
17
|
+
|
18
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
19
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
20
|
+
if spec.respond_to?(:metadata)
|
21
|
+
|
22
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
23
|
+
spec.metadata["source_code_uri"] = "https://github.com/alcoxbiz/peatio-goldcash"
|
24
|
+
spec.metadata["changelog_uri"] = "https://github.com/alcoxbiz/peatio-goldcash/commits/master"
|
25
|
+
else
|
26
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
27
|
+
"public gem pushes."
|
28
|
+
end
|
16
29
|
|
17
30
|
# Specify which files should be added to the gem when it is released.
|
18
31
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
-
spec.files
|
20
|
-
`git ls-files -z`.split("\x0").reject {
|
32
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
33
|
+
`git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/}) }
|
21
34
|
end
|
22
35
|
spec.bindir = "exe"
|
23
|
-
spec.executables = spec.files.grep(%r{^exe/}) {
|
36
|
+
spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f) }
|
24
37
|
spec.require_paths = ["lib"]
|
25
38
|
|
26
39
|
spec.add_dependency "activesupport", "~> 5.2.3"
|
@@ -30,10 +43,13 @@ Gem::Specification.new do |spec|
|
|
30
43
|
spec.add_dependency "peatio", ">= 0.6.3"
|
31
44
|
spec.add_dependency 'net-http-persistent', '~> 3.0.1'
|
32
45
|
|
33
|
-
spec.add_development_dependency "bundler", "~> 1.
|
46
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
47
|
+
spec.add_development_dependency "irb"
|
34
48
|
spec.add_development_dependency "mocha", "~> 1.8"
|
35
49
|
spec.add_development_dependency "pry-byebug"
|
36
50
|
spec.add_development_dependency "rake", "~> 13.0"
|
37
51
|
spec.add_development_dependency "rspec", "~> 3.0"
|
52
|
+
spec.add_development_dependency "rubocop-github"
|
53
|
+
spec.add_development_dependency "simplecov"
|
38
54
|
spec.add_development_dependency "webmock", "~> 3.5"
|
39
55
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peatio-goldcash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- D.H.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -100,14 +100,28 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '1.
|
103
|
+
version: '1.17'
|
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
|
-
version: '1.
|
110
|
+
version: '1.17'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: irb
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: mocha
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,6 +178,34 @@ dependencies:
|
|
164
178
|
- - "~>"
|
165
179
|
- !ruby/object:Gem::Version
|
166
180
|
version: '3.0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: rubocop-github
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: simplecov
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
167
209
|
- !ruby/object:Gem::Dependency
|
168
210
|
name: webmock
|
169
211
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,9 +220,9 @@ dependencies:
|
|
178
220
|
- - "~>"
|
179
221
|
- !ruby/object:Gem::Version
|
180
222
|
version: '3.5'
|
181
|
-
description:
|
223
|
+
description: Peatio Blockchain Plugin for Rubykube
|
182
224
|
email:
|
183
|
-
-
|
225
|
+
- dh@alcox.biz
|
184
226
|
executables: []
|
185
227
|
extensions: []
|
186
228
|
extra_rdoc_files: []
|
@@ -196,12 +238,6 @@ files:
|
|
196
238
|
- Rakefile
|
197
239
|
- bin/console
|
198
240
|
- bin/setup
|
199
|
-
- config/blockchains.yml
|
200
|
-
- config/currencies.yml
|
201
|
-
- config/wallets.yml
|
202
|
-
- docs/integration.md
|
203
|
-
- docs/json-rpc.md
|
204
|
-
- docs/testnet.md
|
205
241
|
- lib/peatio/goldcash.rb
|
206
242
|
- lib/peatio/goldcash/blockchain.rb
|
207
243
|
- lib/peatio/goldcash/client.rb
|
@@ -210,10 +246,13 @@ files:
|
|
210
246
|
- lib/peatio/goldcash/version.rb
|
211
247
|
- lib/peatio/goldcash/wallet.rb
|
212
248
|
- peatio-goldcash.gemspec
|
213
|
-
homepage: https://
|
249
|
+
homepage: https://github.com/alcoxbiz/
|
214
250
|
licenses:
|
215
|
-
-
|
216
|
-
metadata:
|
251
|
+
- Proprietary
|
252
|
+
metadata:
|
253
|
+
homepage_uri: https://github.com/alcoxbiz/
|
254
|
+
source_code_uri: https://github.com/alcoxbiz/peatio-goldcash
|
255
|
+
changelog_uri: https://github.com/alcoxbiz/peatio-goldcash/commits/master
|
217
256
|
post_install_message:
|
218
257
|
rdoc_options: []
|
219
258
|
require_paths:
|
@@ -232,5 +271,5 @@ requirements: []
|
|
232
271
|
rubygems_version: 3.0.6
|
233
272
|
signing_key:
|
234
273
|
specification_version: 4
|
235
|
-
summary:
|
274
|
+
summary: Peatio Blockchain Plugin
|
236
275
|
test_files: []
|
data/config/blockchains.yml
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
- key: gold-mainnet
|
2
|
-
name: Goldcash Mainnet
|
3
|
-
client: goldcash # API client name.
|
4
|
-
server: http://user:password@127.0.0.1:8345 # Public Goldcash node endpoint.
|
5
|
-
height: 11576 # Initial block number from which sync will be started.
|
6
|
-
min_confirmations: 6 # Minimal confirmations needed for withdraw and deposit confirmation.
|
7
|
-
explorer:
|
8
|
-
address: http://goldcashblockexplorer.co.uk/address/#{address}
|
9
|
-
transaction: http://goldcashblockexplorer.co.uk/tx/#{txid}
|
10
|
-
status: active
|
data/config/currencies.yml
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
- id: gold
|
2
|
-
name: Goldcash
|
3
|
-
blockchain_key: gold-mainnet
|
4
|
-
symbol: 'G'
|
5
|
-
type: coin
|
6
|
-
precision: 8
|
7
|
-
base_factor: 100_000_000
|
8
|
-
enabled: true
|
9
|
-
# Deposits with less amount are skipped during blockchain synchronization.
|
10
|
-
# We advise to set value 10 times bigger than the network fee to prevent losses.
|
11
|
-
min_deposit_amount: 0.0004488
|
12
|
-
min_collection_amount: 0.0004488
|
13
|
-
withdraw_limit_24h: 100.0
|
14
|
-
withdraw_limit_72h: 300.0
|
15
|
-
deposit_fee: 0
|
16
|
-
withdraw_fee: 0
|
17
|
-
position: 6
|
18
|
-
options: {}
|
data/config/wallets.yml
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
- name: Goldcash Deposit Wallet
|
2
|
-
blockchain_key: gold-mainnet
|
3
|
-
currency_id: gold
|
4
|
-
# Address where deposits will be collected to.
|
5
|
-
address: 'Qc2BM7gp8mKgJPPxLAadLAHteNQwhFwwuf' # IMPORTANT: Always wrap this value in quotes!
|
6
|
-
kind: deposit # Wallet kind (deposit, hot, warm, cold or fee).
|
7
|
-
nsig: 1 # Number of signatures required for performing withdraw.
|
8
|
-
max_balance: 0.0
|
9
|
-
status: active
|
10
|
-
gateway: goldcashd # Gateway client name.
|
11
|
-
settings:
|
12
|
-
#
|
13
|
-
# Goldcashd gateway client settings.
|
14
|
-
uri: http://user:password@127.0.0.1:8345
|
15
|
-
|
16
|
-
- name: Goldcash Hot Wallet
|
17
|
-
blockchain_key: gold-mainnet
|
18
|
-
currency_id: gold
|
19
|
-
# Address where deposits will be collected to.
|
20
|
-
address: 'Qc2BM7gp8mKgJPPxLAadLAHteNQwhFwwuf' # IMPORTANT: Always wrap this value in quotes!
|
21
|
-
kind: hot # Wallet kind (deposit, hot, warm, cold or fee).
|
22
|
-
nsig: 1 # Number of signatures required for performing withdraw.
|
23
|
-
max_balance: 100.0
|
24
|
-
status: active
|
25
|
-
gateway: goldcashd # Gateway client name.
|
26
|
-
settings:
|
27
|
-
#
|
28
|
-
# Goldcashd gateway client settings.
|
29
|
-
uri: http://user:password@127.0.0.1:8345
|
30
|
-
|
31
|
-
- name: Goldcash Warm Wallet
|
32
|
-
blockchain_key: gold-mainnet
|
33
|
-
currency_id: gold
|
34
|
-
# Address where deposits will be collected to.
|
35
|
-
address: 'Qc2BM7gp8mKgJPPxLAadLAHteNQwhFwwuf' # IMPORTANT: Always wrap this value in quotes!
|
36
|
-
kind: warm # Wallet kind (deposit, hot, warm, cold or fee).
|
37
|
-
nsig: 1 # Number of signatures required for performing withdraw.
|
38
|
-
max_balance: 500.0
|
39
|
-
status: active
|
40
|
-
gateway: goldcashd # Gateway client name.
|
41
|
-
settings:
|
42
|
-
#
|
43
|
-
# Goldcashd gateway client settings.
|
44
|
-
uri: http://user:password@127.0.0.1:8345
|
data/docs/integration.md
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# Integration.
|
2
|
-
|
3
|
-
For Peatio Goldcash plugin integration you need to do the following steps:
|
4
|
-
|
5
|
-
## Image Build.
|
6
|
-
|
7
|
-
1. Add peatio-litecoin gem into your Gemfile.plugin
|
8
|
-
```ruby
|
9
|
-
gem 'peatio-goldcash', '~> 0.2.0'
|
10
|
-
```
|
11
|
-
|
12
|
-
2. Run `bundle install` for updating Gemfile.lock
|
13
|
-
|
14
|
-
3. Build custom Peatio [docker image with Goldcash plugin](https://github.com/rubykube/peatio/blob/master/docs/plugins.md#build)
|
15
|
-
|
16
|
-
4. Push your image using `docker push`
|
17
|
-
|
18
|
-
5. Update your deployment to use image with peatio-goldcash gem
|
19
|
-
|
20
|
-
## Peatio Configuration.
|
21
|
-
|
22
|
-
1. Create Goldcash Blockchain [config example](../config/blockchains.yml).
|
23
|
-
* No additional steps are needed
|
24
|
-
|
25
|
-
2. Create Goldcash Currency [config example](../config/currencies.yml).
|
26
|
-
* No additional steps are needed
|
27
|
-
|
28
|
-
3. Create Goldcash Wallets [config example](../config/wallets.yml)(deposit and hot wallets are required).
|
29
|
-
* No additional steps are needed
|
data/docs/json-rpc.md
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# JSON RPC
|
2
|
-
|
3
|
-
The next list of JSON RPC calls where used for plugin development.
|
4
|
-
For response examples see spec/resources:
|
5
|
-
|
6
|
-
* getbalance
|
7
|
-
|
8
|
-
`curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getbalance", "params": [] }' -H 'content-type: text/plain;' http://user:password@127.0.0.1:8345`
|
9
|
-
* getblock
|
10
|
-
|
11
|
-
`curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblock", "params": ["754d4a0d346a84d710985935f9d403e346e6d889cf89fe45b37168791ad0d9c6"] }' -H 'content-type: text/plain;' http://user:password@127.0.0.1:8345`
|
12
|
-
* getblockcount
|
13
|
-
|
14
|
-
`curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockcount", "params": [] }' -H 'content-type: text/plain;' http://user:password@127.0.0.1:8345`
|
15
|
-
* getblockhash
|
16
|
-
|
17
|
-
`curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockhash", "params": [11576] }' -H 'content-type: text/plain;' http://user:password@127.0.0.1:8345 `
|
18
|
-
* getnewaddress
|
19
|
-
|
20
|
-
`curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getnewaddress", "params": [] }' -H 'content-type: text/plain;' http://user:password@127.0.0.1:8345 `
|
21
|
-
* listaddressgroupings
|
22
|
-
|
23
|
-
`curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "listaddressgroupings", "params": [] }' -H 'content-type: text/plain;' http://user:password@127.0.0.1:8345`
|
24
|
-
* sendtoaddress
|
25
|
-
|
26
|
-
`curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "sendtoaddress", "params": ["GTeo8ZGtKfn1Q2qSB5mpcJZPBaHTAifanw", 0.5] }' -H 'content-type: text/plain;' http://user:password@127.0.0.1:8345`
|
27
|
-
* methodnotfound
|
28
|
-
|
29
|
-
`curl --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "methodnotfound", "params": [] }' -H 'content-type: text/plain;' http://user:password@127.0.0.1:8345`
|