peatio-coinpaymentnew 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +1 -1
- data/Gemfile.lock +54 -14
- data/config/blockchains.yml +10 -0
- data/config/currencies.yml +18 -0
- data/config/wallets.yml +44 -0
- data/lib/peatio/coinpaymentnew/blockchain.rb +85 -21
- data/lib/peatio/coinpaymentnew/client.rb +60 -0
- data/lib/peatio/coinpaymentnew/hooks.rb +42 -42
- data/lib/peatio/coinpaymentnew/railtie.rb +13 -13
- data/lib/peatio/coinpaymentnew/version.rb +1 -3
- data/lib/peatio/coinpaymentnew/wallet.rb +69 -345
- data/lib/peatio/coinpaymentnew.rb +1 -1
- data/peatio-coinpaymentnew.gemspec +8 -6
- metadata +33 -14
- data/lib/peatio/coinpaymentnew/walletApi.rb +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9c6e56f704eacf68895dbfa46288561887452f72
|
4
|
+
data.tar.gz: db1c498a5cad91159146be6495df805b9c1692ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e14195d4e43eeaaeb3f8b1c6787b88b8531770c5afac92e2a4ec186754bac466fc13968c373ce16b07678913b30c0512ae7fc2c1f95fd93b408dc08fdde3ba5
|
7
|
+
data.tar.gz: 5d30ac68bbce4a3e977d1cb0cc8381bc7624089edbbe51077b69265126defbbf15b101b618cc2cae757ec2abf4383c0ba19e0d22b22f6eaaa33b41208d10eba1
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
peatio-coinpaymentnew (
|
4
|
+
peatio-coinpaymentnew (0.0.5)
|
5
5
|
activesupport (~> 5.2.3)
|
6
6
|
better-faraday (~> 1.0.5)
|
7
|
-
|
7
|
+
coinpayments (~> 0.0.4)
|
8
|
+
faraday (~> 0.17)
|
8
9
|
memoist (~> 0.16.0)
|
9
|
-
peatio (~>
|
10
|
+
peatio (~> 2.6.3)
|
10
11
|
|
11
12
|
GEM
|
12
13
|
remote: https://rubygems.org/
|
@@ -37,22 +38,47 @@ GEM
|
|
37
38
|
hashie
|
38
39
|
httparty
|
39
40
|
concurrent-ruby (1.1.9)
|
41
|
+
cookiejar (0.3.3)
|
40
42
|
crack (0.4.5)
|
41
43
|
rexml
|
44
|
+
daemons (1.4.1)
|
42
45
|
diff-lcs (1.4.4)
|
43
|
-
em-
|
46
|
+
em-http-request (1.1.7)
|
47
|
+
addressable (>= 2.3.4)
|
48
|
+
cookiejar (!= 0.3.1)
|
49
|
+
em-socksify (>= 0.3)
|
50
|
+
eventmachine (>= 1.0.3)
|
51
|
+
http_parser.rb (>= 0.6.0)
|
52
|
+
em-socksify (0.3.2)
|
53
|
+
eventmachine (>= 1.0.0.beta.4)
|
54
|
+
em-synchrony (1.0.6)
|
55
|
+
eventmachine (>= 1.0.0.beta.1)
|
56
|
+
em-websocket (0.5.3)
|
44
57
|
eventmachine (>= 0.12.9)
|
45
|
-
http_parser.rb (~> 0
|
58
|
+
http_parser.rb (~> 0)
|
46
59
|
eventmachine (1.2.7-x64-mingw32)
|
47
|
-
faraday (0.
|
60
|
+
faraday (0.17.4)
|
48
61
|
multipart-post (>= 1.2, < 3)
|
62
|
+
faraday_middleware (0.13.1)
|
63
|
+
faraday (>= 0.7.4, < 1.0)
|
64
|
+
faye (1.4.0)
|
65
|
+
cookiejar (>= 0.3.0)
|
66
|
+
em-http-request (>= 1.1.6)
|
67
|
+
eventmachine (>= 0.12.0)
|
68
|
+
faye-websocket (>= 0.11.0)
|
69
|
+
multi_json (>= 1.0.0)
|
70
|
+
rack (>= 1.0.0)
|
71
|
+
websocket-driver (>= 0.5.1)
|
72
|
+
faye-websocket (0.11.1)
|
73
|
+
eventmachine (>= 0.12.0)
|
74
|
+
websocket-driver (>= 0.5.1)
|
49
75
|
hashdiff (1.0.1)
|
50
76
|
hashie (4.1.0)
|
51
|
-
http_parser.rb (0.
|
77
|
+
http_parser.rb (0.8.0)
|
52
78
|
httparty (0.20.0)
|
53
79
|
mime-types (~> 3.0)
|
54
80
|
multi_xml (>= 0.5.2)
|
55
|
-
i18n (1.8.
|
81
|
+
i18n (1.8.11)
|
56
82
|
concurrent-ruby (~> 1.0)
|
57
83
|
jwt (2.3.0)
|
58
84
|
memoist (0.16.2)
|
@@ -62,18 +88,25 @@ GEM
|
|
62
88
|
mime-types-data (3.2021.0901)
|
63
89
|
minitest (5.14.4)
|
64
90
|
mocha (1.13.0)
|
91
|
+
multi_json (1.15.0)
|
65
92
|
multi_xml (0.6.0)
|
66
93
|
multipart-post (2.1.1)
|
67
94
|
mysql2 (0.5.3-x64-mingw32)
|
68
|
-
peatio (
|
95
|
+
peatio (2.6.5)
|
69
96
|
activemodel (> 5.2, <= 6.0.0)
|
70
97
|
amqp
|
71
98
|
bunny
|
72
99
|
clamp
|
100
|
+
em-synchrony (~> 1.0)
|
73
101
|
em-websocket
|
74
102
|
eventmachine
|
103
|
+
faraday_middleware (~> 0.13.1)
|
104
|
+
faye (~> 1.2)
|
75
105
|
jwt
|
76
106
|
mysql2
|
107
|
+
prometheus-client
|
108
|
+
thin
|
109
|
+
prometheus-client (2.1.0)
|
77
110
|
pry (0.13.1)
|
78
111
|
coderay (~> 1.1)
|
79
112
|
method_source (~> 1.0)
|
@@ -81,7 +114,8 @@ GEM
|
|
81
114
|
byebug (~> 11.0)
|
82
115
|
pry (~> 0.13.0)
|
83
116
|
public_suffix (4.0.6)
|
84
|
-
|
117
|
+
rack (2.2.3)
|
118
|
+
rake (13.0.6)
|
85
119
|
rbtree (0.4.4)
|
86
120
|
rexml (3.2.5)
|
87
121
|
rspec (3.10.0)
|
@@ -97,10 +131,14 @@ GEM
|
|
97
131
|
diff-lcs (>= 1.2.0, < 2.0)
|
98
132
|
rspec-support (~> 3.10.0)
|
99
133
|
rspec-support (3.10.2)
|
100
|
-
set (1.0.
|
134
|
+
set (1.0.2)
|
101
135
|
sorted_set (1.0.3)
|
102
136
|
rbtree
|
103
137
|
set (~> 1.0)
|
138
|
+
thin (1.8.1)
|
139
|
+
daemons (~> 1.0, >= 1.0.9)
|
140
|
+
eventmachine (~> 1.0, >= 1.0.4)
|
141
|
+
rack (>= 1, < 3)
|
104
142
|
thread_safe (0.3.6)
|
105
143
|
tzinfo (1.2.9)
|
106
144
|
thread_safe (~> 0.1)
|
@@ -108,19 +146,21 @@ GEM
|
|
108
146
|
addressable (>= 2.8.0)
|
109
147
|
crack (>= 0.3.2)
|
110
148
|
hashdiff (>= 0.4.0, < 2.0.0)
|
149
|
+
websocket-driver (0.7.5)
|
150
|
+
websocket-extensions (>= 0.1.0)
|
151
|
+
websocket-extensions (0.1.5)
|
111
152
|
|
112
153
|
PLATFORMS
|
113
154
|
x64-mingw32
|
114
155
|
|
115
156
|
DEPENDENCIES
|
116
157
|
bundler (~> 1.16)
|
117
|
-
coinpayments
|
118
158
|
mocha (~> 1.8)
|
119
159
|
peatio-coinpaymentnew!
|
120
160
|
pry-byebug
|
121
|
-
rake (~>
|
161
|
+
rake (~> 13.0)
|
122
162
|
rspec (~> 3.0)
|
123
163
|
webmock (~> 3.5)
|
124
164
|
|
125
165
|
BUNDLED WITH
|
126
|
-
1.17.
|
166
|
+
1.17.3
|
@@ -0,0 +1,10 @@
|
|
1
|
+
- key: ltc-testnet
|
2
|
+
name: Coinpayment Testnet
|
3
|
+
client: coinpayment # API client name.
|
4
|
+
server: http://user:password@127.0.0.1:18332 # Public Coinpayment node endpoint.
|
5
|
+
height: 1087160 # 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: https://chain.so/address/LTCTEST/#{address}
|
9
|
+
transaction: https://chain.so/tx/LTCTEST/#{txid}
|
10
|
+
status: active
|
@@ -0,0 +1,18 @@
|
|
1
|
+
- id: ltc
|
2
|
+
name: Coinpayment
|
3
|
+
blockchain_key: ltc-testnet
|
4
|
+
symbol: 'Ł'
|
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: 0.5
|
14
|
+
withdraw_limit_72h: 1.2
|
15
|
+
deposit_fee: 0
|
16
|
+
withdraw_fee: 0
|
17
|
+
position: 5
|
18
|
+
options: {}
|
data/config/wallets.yml
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
- name: Coinpayment Deposit Wallet
|
2
|
+
blockchain_key: ltc-testnet
|
3
|
+
currency_id: ltc
|
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: coinpaymentd # Gateway client name.
|
11
|
+
settings:
|
12
|
+
#
|
13
|
+
# Coinpaymentd gateway client settings.
|
14
|
+
uri: http://user:password@127.0.0.1:19332
|
15
|
+
|
16
|
+
- name: Coinpayment Hot Wallet
|
17
|
+
blockchain_key: ltc-testnet
|
18
|
+
currency_id: ltc
|
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: 5.0
|
24
|
+
status: active
|
25
|
+
gateway: coinpaymentd # Gateway client name.
|
26
|
+
settings:
|
27
|
+
#
|
28
|
+
# Coinpaymentd gateway client settings.
|
29
|
+
uri: http://user:password@127.0.0.1:19332
|
30
|
+
|
31
|
+
- name: Coinpayment Warm Wallet
|
32
|
+
blockchain_key: ltc-testnet
|
33
|
+
currency_id: ltc
|
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: 50.0
|
39
|
+
status: active
|
40
|
+
gateway: coinpaymentd # Gateway client name.
|
41
|
+
settings:
|
42
|
+
#
|
43
|
+
# Coinpaymentd gateway client settings.
|
44
|
+
uri: http://user:password@127.0.0.1:19332
|
@@ -1,21 +1,85 @@
|
|
1
|
-
|
2
|
-
module Peatio
|
3
|
-
module Coinpaymentnew
|
4
|
-
# TODO: Processing of unconfirmed transactions from mempool isn't supported now.
|
5
|
-
class Blockchain < Peatio::Blockchain::Abstract
|
6
|
-
|
7
|
-
DEFAULT_FEATURES = {case_sensitive: true, cash_addr_format: false}.freeze
|
8
|
-
|
9
|
-
def initialize(custom_features = {})
|
10
|
-
@features = DEFAULT_FEATURES.merge(custom_features).slice(*SUPPORTED_FEATURES)
|
11
|
-
@settings = {}
|
12
|
-
end
|
13
|
-
|
14
|
-
def configure(settings = {})
|
15
|
-
# Clean client state during configure.
|
16
|
-
@client = nil
|
17
|
-
@settings.merge!(settings.slice(*SUPPORTED_SETTINGS))
|
18
|
-
end
|
19
|
-
|
20
|
-
|
21
|
-
|
1
|
+
|
2
|
+
module Peatio
|
3
|
+
module Coinpaymentnew
|
4
|
+
# TODO: Processing of unconfirmed transactions from mempool isn't supported now.
|
5
|
+
class Blockchain < Peatio::Blockchain::Abstract
|
6
|
+
|
7
|
+
DEFAULT_FEATURES = {case_sensitive: true, cash_addr_format: false}.freeze
|
8
|
+
|
9
|
+
def initialize(custom_features = {})
|
10
|
+
@features = DEFAULT_FEATURES.merge(custom_features).slice(*SUPPORTED_FEATURES)
|
11
|
+
@settings = {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def configure(settings = {})
|
15
|
+
# Clean client state during configure.
|
16
|
+
@client = nil
|
17
|
+
@settings.merge!(settings.slice(*SUPPORTED_SETTINGS))
|
18
|
+
end
|
19
|
+
|
20
|
+
def fetch_block!(block_number)
|
21
|
+
block_hash = client.json_rpc(:getblockhash, [block_number])
|
22
|
+
|
23
|
+
client.json_rpc(:getblock, [block_hash, 2])
|
24
|
+
.fetch('tx').each_with_object([]) do |tx, txs_array|
|
25
|
+
txs = build_transaction(tx).map do |ntx|
|
26
|
+
Peatio::Transaction.new(ntx.merge(block_number: block_number))
|
27
|
+
end
|
28
|
+
txs_array.append(*txs)
|
29
|
+
end.yield_self { |txs_array| Peatio::Block.new(block_number, txs_array) }
|
30
|
+
rescue Client::Error => e
|
31
|
+
raise Peatio::Blockchain::ClientError, e
|
32
|
+
end
|
33
|
+
|
34
|
+
def latest_block_number
|
35
|
+
client.json_rpc(:getblockcount)
|
36
|
+
rescue Client::Error => e
|
37
|
+
raise Peatio::Blockchain::ClientError, e
|
38
|
+
end
|
39
|
+
|
40
|
+
def load_balance_of_address!(address, _currency_id)
|
41
|
+
address_with_balance = client.json_rpc(:listaddressgroupings)
|
42
|
+
.flatten(1)
|
43
|
+
.find { |addr| addr[0] == address }
|
44
|
+
|
45
|
+
if address_with_balance.blank?
|
46
|
+
raise Peatio::Blockchain::UnavailableAddressBalanceError, address
|
47
|
+
end
|
48
|
+
|
49
|
+
address_with_balance[1].to_d
|
50
|
+
rescue Client::Error => e
|
51
|
+
raise Peatio::Blockchain::ClientError, e
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def build_transaction(tx_hash)
|
57
|
+
tx_hash.fetch('vout')
|
58
|
+
.select do |entry|
|
59
|
+
entry.fetch('value').to_d > 0 &&
|
60
|
+
entry['scriptPubKey'].has_key?('addresses')
|
61
|
+
end
|
62
|
+
.each_with_object([]) do |entry, formatted_txs|
|
63
|
+
no_currency_tx =
|
64
|
+
{ hash: tx_hash['txid'], txout: entry['n'],
|
65
|
+
to_address: entry['scriptPubKey']['addresses'][0],
|
66
|
+
amount: entry.fetch('value').to_d,
|
67
|
+
status: 'success' }
|
68
|
+
|
69
|
+
# Build transaction for each currency belonging to blockchain.
|
70
|
+
settings_fetch(:currencies).pluck(:id).each do |currency_id|
|
71
|
+
formatted_txs << no_currency_tx.merge(currency_id: currency_id)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def client
|
77
|
+
@client ||= Client.new(settings_fetch(:server))
|
78
|
+
end
|
79
|
+
|
80
|
+
def settings_fetch(key)
|
81
|
+
@settings.fetch(key) { raise Peatio::Blockchain::MissingSettingError, key.to_s }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'memoist'
|
4
|
+
require 'faraday'
|
5
|
+
require 'better-faraday'
|
6
|
+
|
7
|
+
module Peatio
|
8
|
+
module Coinpaymentnew
|
9
|
+
class Client
|
10
|
+
Error = Class.new(StandardError)
|
11
|
+
ConnectionError = Class.new(Error)
|
12
|
+
|
13
|
+
class ResponseError < Error
|
14
|
+
def initialize(code, msg)
|
15
|
+
@code = code
|
16
|
+
@msg = msg
|
17
|
+
end
|
18
|
+
|
19
|
+
def message
|
20
|
+
"#{@msg} (#{@code})"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
extend Memoist
|
25
|
+
|
26
|
+
def initialize(endpoint)
|
27
|
+
@json_rpc_endpoint = URI.parse(endpoint)
|
28
|
+
end
|
29
|
+
|
30
|
+
def json_rpc(method, params = [])
|
31
|
+
response = connection.post \
|
32
|
+
'/',
|
33
|
+
{ jsonrpc: '1.0', method: method, params: params }.to_json,
|
34
|
+
{ 'Accept' => 'application/json',
|
35
|
+
'Content-Type' => 'application/json' }
|
36
|
+
response.assert_2xx!
|
37
|
+
response = JSON.parse(response.body)
|
38
|
+
response['error'].tap do |e|
|
39
|
+
raise ResponseError.new(e['code'], e['message']) if e
|
40
|
+
end
|
41
|
+
response.fetch('result')
|
42
|
+
rescue Faraday::Error => e
|
43
|
+
raise ConnectionError, e
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def connection
|
49
|
+
@connection ||= Faraday.new(@json_rpc_endpoint) do |f|
|
50
|
+
f.adapter :net_http_persistent, pool_size: 5
|
51
|
+
end.tap do |connection|
|
52
|
+
unless @json_rpc_endpoint.user.blank?
|
53
|
+
connection.basic_auth(@json_rpc_endpoint.user,
|
54
|
+
@json_rpc_endpoint.password)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -1,42 +1,42 @@
|
|
1
|
-
module Peatio
|
2
|
-
module Coinpaymentnew
|
3
|
-
module Hooks
|
4
|
-
BLOCKCHAIN_VERSION_REQUIREMENT = "~> 1.0.0"
|
5
|
-
WALLET_VERSION_REQUIREMENT = "~> 1.0.0"
|
6
|
-
|
7
|
-
class << self
|
8
|
-
def check_compatibility
|
9
|
-
unless Gem::Requirement.new(BLOCKCHAIN_VERSION_REQUIREMENT)
|
10
|
-
.satisfied_by?(Gem::Version.new(Peatio::Blockchain::VERSION))
|
11
|
-
[
|
12
|
-
"
|
13
|
-
"
|
14
|
-
"Peatio::Blockchain version is #{Peatio::Blockchain::VERSION}"
|
15
|
-
].join('\n').tap { |s| Kernel.abort s }
|
16
|
-
end
|
17
|
-
|
18
|
-
unless Gem::Requirement.new(WALLET_VERSION_REQUIREMENT)
|
19
|
-
.satisfied_by?(Gem::Version.new(Peatio::Wallet::VERSION))
|
20
|
-
[
|
21
|
-
"
|
22
|
-
"
|
23
|
-
"Peatio::Wallet version is #{Peatio::Wallet::VERSION}"
|
24
|
-
].join('\n').tap { |s| Kernel.abort s }
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def register
|
29
|
-
Peatio::Blockchain.registry[:
|
30
|
-
Peatio::Wallet.registry[:
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
if defined?(Rails::Railtie)
|
35
|
-
require "peatio/
|
36
|
-
else
|
37
|
-
check_compatibility
|
38
|
-
register
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
1
|
+
module Peatio
|
2
|
+
module Coinpaymentnew
|
3
|
+
module Hooks
|
4
|
+
BLOCKCHAIN_VERSION_REQUIREMENT = "~> 1.0.0"
|
5
|
+
WALLET_VERSION_REQUIREMENT = "~> 1.0.0"
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def check_compatibility
|
9
|
+
unless Gem::Requirement.new(BLOCKCHAIN_VERSION_REQUIREMENT)
|
10
|
+
.satisfied_by?(Gem::Version.new(Peatio::Blockchain::VERSION))
|
11
|
+
[
|
12
|
+
"Coinpayment blockchain version requiremnt was not suttisfied by Peatio::Blockchain.",
|
13
|
+
"Coinpayment blockchain requires #{BLOCKCHAIN_VERSION_REQUIREMENT}.",
|
14
|
+
"Peatio::Blockchain version is #{Peatio::Blockchain::VERSION}"
|
15
|
+
].join('\n').tap { |s| Kernel.abort s }
|
16
|
+
end
|
17
|
+
|
18
|
+
unless Gem::Requirement.new(WALLET_VERSION_REQUIREMENT)
|
19
|
+
.satisfied_by?(Gem::Version.new(Peatio::Wallet::VERSION))
|
20
|
+
[
|
21
|
+
"Coinpayment wallet version requiremnt was not suttisfied by Peatio::Wallet.",
|
22
|
+
"Coinpayment wallet requires #{WALLET_VERSION_REQUIREMENT}.",
|
23
|
+
"Peatio::Wallet version is #{Peatio::Wallet::VERSION}"
|
24
|
+
].join('\n').tap { |s| Kernel.abort s }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def register
|
29
|
+
Peatio::Blockchain.registry[:coinpayment] = Coinpayment::Blockchain
|
30
|
+
Peatio::Wallet.registry[:coinpaymentd] = Coinpayment::Wallet
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
if defined?(Rails::Railtie)
|
35
|
+
require "peatio/coinpayment/railtie"
|
36
|
+
else
|
37
|
+
check_compatibility
|
38
|
+
register
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -1,13 +1,13 @@
|
|
1
|
-
module Peatio
|
2
|
-
module Coinpaymentnew
|
3
|
-
class Railtie < Rails::Railtie
|
4
|
-
config.before_initialize do
|
5
|
-
Hooks.check_compatibility
|
6
|
-
end
|
7
|
-
|
8
|
-
config.after_initialize do
|
9
|
-
Hooks.register
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
1
|
+
module Peatio
|
2
|
+
module Coinpaymentnew
|
3
|
+
class Railtie < Rails::Railtie
|
4
|
+
config.before_initialize do
|
5
|
+
Hooks.check_compatibility
|
6
|
+
end
|
7
|
+
|
8
|
+
config.after_initialize do
|
9
|
+
Hooks.register
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -1,345 +1,69 @@
|
|
1
|
-
module Peatio
|
2
|
-
module Coinpaymentnew
|
3
|
-
class Wallet < Peatio::Wallet::Abstract
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
@
|
17
|
-
|
18
|
-
@settings.
|
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
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
#
|
71
|
-
# if response['feeString'].present?
|
72
|
-
# fee = convert_from_base_unit(response['feeString'])
|
73
|
-
# transaction.fee = fee
|
74
|
-
# end
|
75
|
-
|
76
|
-
transaction.hash = normalize_txid(response[:txn_id])
|
77
|
-
transaction.fee_currency_id = erc20_currency_id
|
78
|
-
transaction
|
79
|
-
# end
|
80
|
-
rescue Coinpaymentnew::Client::Error => e
|
81
|
-
raise Peatio::Wallet::ClientError, e
|
82
|
-
end
|
83
|
-
|
84
|
-
#
|
85
|
-
# def build_raw_transaction(transaction)
|
86
|
-
# client.rest_api(:post, "#{currency_id}/wallet/#{wallet_id}/tx/build", {
|
87
|
-
# recipients: [{
|
88
|
-
# address: transaction.to_address,
|
89
|
-
# amount: convert_to_base_unit(transaction.amount).to_s
|
90
|
-
# }]
|
91
|
-
# }.compact)
|
92
|
-
# end
|
93
|
-
|
94
|
-
# def create_eth_transaction(transaction, options = {})
|
95
|
-
# amount = convert_to_base_unit(transaction.amount)
|
96
|
-
# hop = true unless options.slice(:gas_price).present?
|
97
|
-
#
|
98
|
-
# fee_estimate = fee_estimate(amount.to_s, hop)
|
99
|
-
#
|
100
|
-
# if transaction.options.present? && transaction.options[:gas_price].present?
|
101
|
-
# options[:gas_price] = transaction.options[:gas_price]
|
102
|
-
# else
|
103
|
-
# options[:gas_price] = fee_estimate['minGasPrice'].to_i
|
104
|
-
# end
|
105
|
-
#
|
106
|
-
# response = client.rest_api(:post, "#{currency_id}/wallet/#{wallet_id}/sendcoins", {
|
107
|
-
# address: transaction.to_address.to_s,
|
108
|
-
# amount: amount.to_s,
|
109
|
-
# walletPassphrase: bitgo_wallet_passphrase,
|
110
|
-
# gas: options.fetch(:gas_limit).to_i,
|
111
|
-
# gasPrice: options.fetch(:gas_price).to_i,
|
112
|
-
# hop: hop
|
113
|
-
# }.compact)
|
114
|
-
#
|
115
|
-
# if response['feeString'].present?
|
116
|
-
# fee = convert_from_base_unit(response['feeString'])
|
117
|
-
# transaction.fee = fee
|
118
|
-
# end
|
119
|
-
#
|
120
|
-
# transaction.hash = normalize_txid(response['txid'])
|
121
|
-
# transaction.fee_currency_id = erc20_currency_id
|
122
|
-
# transaction.options = options
|
123
|
-
# transaction
|
124
|
-
# end
|
125
|
-
|
126
|
-
def fee_estimate(amount, hop)
|
127
|
-
client.rest_api(:get, "#{erc20_currency_id}/tx/fee", { amount: amount, hop: hop }.compact)
|
128
|
-
end
|
129
|
-
|
130
|
-
def load_balance!
|
131
|
-
# if @currency.fetch(:options).slice(:erc20_contract_address).present?
|
132
|
-
# load_erc20_balance!
|
133
|
-
# else
|
134
|
-
# response = client.rest_api(:get, "#{currency_id}/wallet/#{wallet_id}")
|
135
|
-
response = WalletApi.balance
|
136
|
-
response = response.fetch(currency_id)
|
137
|
-
convert_from_base_unit(response["balance"])
|
138
|
-
# end
|
139
|
-
rescue Coinpaymentnew::Client::Error => e
|
140
|
-
raise Peatio::Wallet::ClientError, e
|
141
|
-
end
|
142
|
-
|
143
|
-
# def load_erc20_balance!
|
144
|
-
# response = client.rest_api(:get, "#{erc20_currency_id}/wallet/#{wallet_id}?allTokens=true")
|
145
|
-
# convert_from_base_unit(response.dig('tokens', currency_id, 'balanceString'))
|
146
|
-
# rescue Coinpaymentnew::Client::Error => e
|
147
|
-
# raise Peatio::Wallet::ClientError, e
|
148
|
-
# end
|
149
|
-
|
150
|
-
def trigger_webhook_event(request)
|
151
|
-
currency = @wallet.fetch(:testnet).present? ? 't' + @currency.fetch(:id) : @currency.fetch(:id)
|
152
|
-
if request.params['type'] == 'transfer'
|
153
|
-
return unless currency == request.params['coin'] &&
|
154
|
-
@wallet.fetch(:wallet_id) == request.params['wallet']
|
155
|
-
else
|
156
|
-
return unless @wallet.fetch(:wallet_id) == request.params['walletId']
|
157
|
-
end
|
158
|
-
|
159
|
-
if request.params['type'] == 'transfer'
|
160
|
-
transactions = fetch_transfer!(request.params['transfer'])
|
161
|
-
return transactions
|
162
|
-
elsif request.params['type'] == 'address_confirmation'
|
163
|
-
address_id = fetch_address_id(request.params['address'])
|
164
|
-
return { address_id: address_id, address: request.params['address'], currency_id: currency_id }
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
def register_webhooks!(url)
|
169
|
-
transfer_webhook(url)
|
170
|
-
address_confirmation_webhook(url)
|
171
|
-
end
|
172
|
-
|
173
|
-
# def fetch_address_id(address)
|
174
|
-
# currency = erc20_currency_id
|
175
|
-
# client.rest_api(:get, "#{currency}/wallet/#{wallet_id}/address/#{address}")
|
176
|
-
# .fetch('id')
|
177
|
-
# rescue Coinpaymentnew::Client::Error => e
|
178
|
-
# raise Peatio::Wallet::ClientError, e
|
179
|
-
# end
|
180
|
-
|
181
|
-
def fetch_transfer!(id)
|
182
|
-
response = client.rest_api(:get, "#{currency_id}/wallet/#{wallet_id}/transfer/#{id}")
|
183
|
-
parse_entries(response['entries']).map do |entry|
|
184
|
-
to_address = if response.dig('coinSpecific', 'memo').present?
|
185
|
-
memo = response.dig('coinSpecific', 'memo')
|
186
|
-
memo_type = memo.kind_of?(Array) ? memo.first : memo
|
187
|
-
build_address(entry['address'], memo_type)
|
188
|
-
else
|
189
|
-
entry['address']
|
190
|
-
end
|
191
|
-
state = define_transaction_state(response['state'])
|
192
|
-
|
193
|
-
if response['outputs'].present?
|
194
|
-
output = response['outputs'].find { |out| out['address'] == to_address }
|
195
|
-
txout = output['index'] if output.present?
|
196
|
-
end
|
197
|
-
|
198
|
-
if response['feeString'].present?
|
199
|
-
fee = convert_from_base_unit(response['feeString']) / response['entries'].count
|
200
|
-
end
|
201
|
-
|
202
|
-
transaction = Peatio::Transaction.new(
|
203
|
-
currency_id: @currency.fetch(:id),
|
204
|
-
amount: convert_from_base_unit(entry['valueString']),
|
205
|
-
fee: fee,
|
206
|
-
fee_currency_id: erc20_currency_id,
|
207
|
-
hash: normalize_txid(response['txid']),
|
208
|
-
to_address: to_address,
|
209
|
-
block_number: response['height'],
|
210
|
-
txout: txout.to_i,
|
211
|
-
status: state
|
212
|
-
)
|
213
|
-
|
214
|
-
transaction if transaction.valid?
|
215
|
-
end.compact
|
216
|
-
rescue Coinpaymentnew::Client::Error => e
|
217
|
-
raise Peatio::Wallet::ClientError, e
|
218
|
-
end
|
219
|
-
|
220
|
-
def transfer_webhook(url)
|
221
|
-
client.rest_api(:post, "#{currency_id}/wallet/#{wallet_id}/webhooks", {
|
222
|
-
type: 'transfer',
|
223
|
-
allToken: true,
|
224
|
-
url: url,
|
225
|
-
label: "webhook for #{url}",
|
226
|
-
listenToFailureStates: false
|
227
|
-
})
|
228
|
-
end
|
229
|
-
|
230
|
-
def address_confirmation_webhook(url)
|
231
|
-
client.rest_api(:post, "#{currency_id}/wallet/#{wallet_id}/webhooks", {
|
232
|
-
type: 'address_confirmation',
|
233
|
-
allToken: true,
|
234
|
-
url: url,
|
235
|
-
label: "webhook for #{url}",
|
236
|
-
listenToFailureStates: false
|
237
|
-
})
|
238
|
-
end
|
239
|
-
|
240
|
-
def parse_entries(entries)
|
241
|
-
entries.map do |e|
|
242
|
-
e if e["valueString"].to_i.positive?
|
243
|
-
end.compact
|
244
|
-
end
|
245
|
-
|
246
|
-
private
|
247
|
-
|
248
|
-
def client
|
249
|
-
uri = @wallet.fetch(:uri) { raise Peatio::Wallet::MissingSettingError, :uri }
|
250
|
-
access_token = @wallet.fetch(:access_token) { raise Peatio::Wallet::MissingSettingError, :access_token }
|
251
|
-
|
252
|
-
currency_code_prefix = @wallet.fetch(:testnet) ? 't' : ''
|
253
|
-
uri = uri.gsub(/\/+\z/, '') + '/' + currency_code_prefix
|
254
|
-
@client ||= Client.new(uri, access_token)
|
255
|
-
end
|
256
|
-
|
257
|
-
def build_address(address, memo)
|
258
|
-
"#{address}?memoId=#{memo['value']}"
|
259
|
-
end
|
260
|
-
|
261
|
-
# All these functions will have to be done with the coin set to eth or teth
|
262
|
-
# since that is the actual coin type being used.
|
263
|
-
def erc20_currency_id
|
264
|
-
return 'eth' if @currency.fetch(:options).slice(:erc20_contract_address).present?
|
265
|
-
|
266
|
-
currency_id
|
267
|
-
end
|
268
|
-
|
269
|
-
def xlm_memo(address)
|
270
|
-
build_xlm_memo(address) if @currency.fetch(:id) == 'xlm'
|
271
|
-
end
|
272
|
-
|
273
|
-
def build_xlm_memo(address)
|
274
|
-
case address.split('?').last.split('=').first
|
275
|
-
when 'memoId'
|
276
|
-
memo_value_from(address, 'memoId')
|
277
|
-
when 'memoText'
|
278
|
-
memo_value_from(address, 'memoText')
|
279
|
-
when 'memoHash'
|
280
|
-
memo_value_from(address, 'memoHash')
|
281
|
-
when 'memoReturn'
|
282
|
-
memo_value_from(address, 'memoReturn')
|
283
|
-
end
|
284
|
-
end
|
285
|
-
|
286
|
-
def memo_value_from(address, type)
|
287
|
-
memo_value = address.partition(type + '=').last
|
288
|
-
return { type: XLM_MEMO_TYPES[type.to_sym], value: memo_value } if memo_value.present?
|
289
|
-
end
|
290
|
-
|
291
|
-
def currency_id
|
292
|
-
@currency.fetch(:id) { raise Peatio::Wallet::MissingSettingError, :id }
|
293
|
-
end
|
294
|
-
|
295
|
-
def coinpayment_wallet_passphrase
|
296
|
-
@wallet.fetch(:secret)
|
297
|
-
end
|
298
|
-
|
299
|
-
def wallet_id
|
300
|
-
@wallet.fetch(:wallet_id)
|
301
|
-
end
|
302
|
-
|
303
|
-
def normalize_address(address)
|
304
|
-
if @currency.fetch(:id) == 'xlm'
|
305
|
-
address.split('?').first
|
306
|
-
else
|
307
|
-
address
|
308
|
-
end
|
309
|
-
end
|
310
|
-
|
311
|
-
def normalize_txid(txid)
|
312
|
-
txid.downcase
|
313
|
-
end
|
314
|
-
|
315
|
-
def convert_from_base_unit(value)
|
316
|
-
value.to_d / @currency.fetch(:base_factor)
|
317
|
-
end
|
318
|
-
|
319
|
-
def convert_to_base_unit(value)
|
320
|
-
x = value.to_d * @currency.fetch(:base_factor)
|
321
|
-
unless (x % 1).zero?
|
322
|
-
raise Peatio::WalletClient::Error,
|
323
|
-
"Failed to convert value to base (smallest) unit because it exceeds the maximum precision: " \
|
324
|
-
"#{value.to_d} - #{x.to_d} must be equal to zero."
|
325
|
-
end
|
326
|
-
x.to_i
|
327
|
-
end
|
328
|
-
|
329
|
-
def time_difference_in_minutes(updated_at)
|
330
|
-
(Time.now - updated_at)/60
|
331
|
-
end
|
332
|
-
|
333
|
-
def define_transaction_state(state)
|
334
|
-
case state
|
335
|
-
when 'unconfirmed'
|
336
|
-
'pending'
|
337
|
-
when 'confirmed'
|
338
|
-
'success'
|
339
|
-
when 'failed','rejected'
|
340
|
-
'failed'
|
341
|
-
end
|
342
|
-
end
|
343
|
-
end
|
344
|
-
end
|
345
|
-
end
|
1
|
+
module Peatio
|
2
|
+
module Coinpaymentnew
|
3
|
+
class Wallet < Peatio::Wallet::Abstract
|
4
|
+
|
5
|
+
DEFAULT_FEATURES = { skip_deposit_collection: false }.freeze
|
6
|
+
|
7
|
+
def initialize(custom_features = {})
|
8
|
+
@features = DEFAULT_FEATURES.merge(custom_features).slice(*SUPPORTED_FEATURES)
|
9
|
+
@settings = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def configure(settings = {})
|
13
|
+
# Clean client state during configure.
|
14
|
+
@client = nil
|
15
|
+
|
16
|
+
@settings.merge!(settings.slice(*SUPPORTED_SETTINGS))
|
17
|
+
|
18
|
+
@wallet = @settings.fetch(:wallet) do
|
19
|
+
raise Peatio::Wallet::MissingSettingError, :wallet
|
20
|
+
end.slice(:uri, :address)
|
21
|
+
|
22
|
+
@currency = @settings.fetch(:currency) do
|
23
|
+
raise Peatio::Wallet::MissingSettingError, :currency
|
24
|
+
end.slice(:id, :base_factor, :options)
|
25
|
+
end
|
26
|
+
|
27
|
+
def create_address!(_options = {})
|
28
|
+
r = Coinpayments.get_callback_address('BTC', {ipn_url: "https://v2app.rokes.exchange/api/v2/peatio/public/webhooks/deposit"})
|
29
|
+
{ address: r[:address] }
|
30
|
+
rescue Coinpaymentnew::Client::Error => e
|
31
|
+
raise Peatio::Wallet::ClientError, e
|
32
|
+
end
|
33
|
+
|
34
|
+
def create_transaction!(transaction, options = {})
|
35
|
+
res = Coinpayments.create_transaction(transaction.amount, "USD", currency_id, {buyer_email: "joshirockstar007@gmail.com", address: transaction.to_address, ipn_url: "https://v2app.rokes.exchange/api/v2/peatio/public/webhooks/deposit"})
|
36
|
+
# txid = client.json_rpc(:sendtoaddress,
|
37
|
+
# [
|
38
|
+
# transaction.to_address,
|
39
|
+
# transaction.amount,
|
40
|
+
# '',
|
41
|
+
# '',
|
42
|
+
# options[:subtract_fee].to_s == 'true' # subtract fee from transaction amount.
|
43
|
+
# ])
|
44
|
+
transaction.hash = res[:txn_id]
|
45
|
+
transaction
|
46
|
+
rescue Coinpaymentnew::Client::Error => e
|
47
|
+
raise Peatio::Wallet::ClientError, e
|
48
|
+
end
|
49
|
+
|
50
|
+
def load_balance!
|
51
|
+
client.json_rpc(:getbalance).to_d
|
52
|
+
|
53
|
+
rescue Coinpaymentnew::Client::Error => e
|
54
|
+
raise Peatio::Wallet::ClientError, e
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def client
|
60
|
+
uri = @wallet.fetch(:uri) { raise Peatio::Wallet::MissingSettingError, :uri }
|
61
|
+
@client ||= Client.new(uri)
|
62
|
+
end
|
63
|
+
|
64
|
+
def currency_id
|
65
|
+
@currency.fetch(:id) { raise Peatio::Wallet::MissingSettingError, :id }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -2,7 +2,6 @@
|
|
2
2
|
require 'em/pure_ruby'
|
3
3
|
require "peatio"
|
4
4
|
require "coinpayments"
|
5
|
-
require_relative "../../config/initializers/coinpayments"
|
6
5
|
require_relative "coinpaymentnew/version"
|
7
6
|
|
8
7
|
module Peatio
|
@@ -13,6 +12,7 @@ module Peatio
|
|
13
12
|
require "bigdecimal/util"
|
14
13
|
|
15
14
|
require_relative "coinpaymentnew/blockchain"
|
15
|
+
require_relative "coinpaymentnew/client"
|
16
16
|
require_relative "coinpaymentnew/wallet"
|
17
17
|
|
18
18
|
require_relative "coinpaymentnew/hooks"
|
@@ -8,9 +8,9 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["Harishankar Joshi"]
|
9
9
|
spec.email = ["joshirockstar007@gmail.com"]
|
10
10
|
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage = "
|
11
|
+
spec.summary = %q{Gem for extending Peatio plugable system with Coinpayment implementation.}
|
12
|
+
spec.description = %q{Coinpayment Peatio gem which implements Peatio::Blockchain::Abstract & Peatio::Wallet::Abstract.}
|
13
|
+
spec.homepage = "https://openware.com/"
|
14
14
|
spec.license = "MIT"
|
15
15
|
spec.required_ruby_version = ">= 2.4.0"
|
16
16
|
|
@@ -33,14 +33,16 @@ Gem::Specification.new do |spec|
|
|
33
33
|
# spec.add_dependency "example-gem", "~> 1.0"
|
34
34
|
spec.add_dependency "activesupport", "~> 5.2.3"
|
35
35
|
spec.add_dependency "better-faraday", "~> 1.0.5"
|
36
|
-
spec.add_dependency "faraday", "~> 0.
|
36
|
+
spec.add_dependency "faraday", "~> 0.17"
|
37
37
|
spec.add_dependency "memoist", "~> 0.16.0"
|
38
|
-
spec.add_dependency "peatio", "~>
|
38
|
+
spec.add_dependency "peatio", "~> 2.6.3" # Required.
|
39
|
+
spec.add_dependency "coinpayments", "~> 0.0.4" # Required.
|
40
|
+
|
39
41
|
#
|
40
42
|
spec.add_development_dependency "bundler", "~> 1.16"
|
41
43
|
spec.add_development_dependency "mocha", "~> 1.8"
|
42
44
|
spec.add_development_dependency "pry-byebug"
|
43
|
-
spec.add_development_dependency "rake", "~>
|
45
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
44
46
|
spec.add_development_dependency "rspec", "~> 3.0"
|
45
47
|
spec.add_development_dependency "webmock", "~> 3.5"
|
46
48
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peatio-coinpaymentnew
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harishankar Joshi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: '0.17'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: '0.17'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: memoist
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,28 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 2.6.3
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 2.6.3
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: coinpayments
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.0.4
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.0.4
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: bundler
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,14 +142,14 @@ dependencies:
|
|
128
142
|
requirements:
|
129
143
|
- - "~>"
|
130
144
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
145
|
+
version: '13.0'
|
132
146
|
type: :development
|
133
147
|
prerelease: false
|
134
148
|
version_requirements: !ruby/object:Gem::Requirement
|
135
149
|
requirements:
|
136
150
|
- - "~>"
|
137
151
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
152
|
+
version: '13.0'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: rspec
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,7 +178,8 @@ dependencies:
|
|
164
178
|
- - "~>"
|
165
179
|
- !ruby/object:Gem::Version
|
166
180
|
version: '3.5'
|
167
|
-
description:
|
181
|
+
description: Coinpayment Peatio gem which implements Peatio::Blockchain::Abstract
|
182
|
+
& Peatio::Wallet::Abstract.
|
168
183
|
email:
|
169
184
|
- joshirockstar007@gmail.com
|
170
185
|
executables: []
|
@@ -190,21 +205,24 @@ files:
|
|
190
205
|
- Rakefile
|
191
206
|
- bin/console
|
192
207
|
- bin/setup
|
208
|
+
- config/blockchains.yml
|
209
|
+
- config/currencies.yml
|
193
210
|
- config/initializers/coinpayments.rb
|
211
|
+
- config/wallets.yml
|
194
212
|
- lib/peatio/coinpaymentnew.rb
|
195
213
|
- lib/peatio/coinpaymentnew/blockchain.rb
|
214
|
+
- lib/peatio/coinpaymentnew/client.rb
|
196
215
|
- lib/peatio/coinpaymentnew/hooks.rb
|
197
216
|
- lib/peatio/coinpaymentnew/railtie.rb
|
198
217
|
- lib/peatio/coinpaymentnew/version.rb
|
199
218
|
- lib/peatio/coinpaymentnew/wallet.rb
|
200
|
-
- lib/peatio/coinpaymentnew/walletApi.rb
|
201
219
|
- peatio-coinpaymentnew.gemspec
|
202
|
-
homepage:
|
220
|
+
homepage: https://openware.com/
|
203
221
|
licenses:
|
204
222
|
- MIT
|
205
223
|
metadata:
|
206
224
|
allowed_push_host: https://rubygems.org/
|
207
|
-
homepage_uri:
|
225
|
+
homepage_uri: https://openware.com/
|
208
226
|
source_code_uri: http://v2app.rokes.exchange/
|
209
227
|
changelog_uri: http://v2app.rokes.exchange/
|
210
228
|
post_install_message:
|
@@ -222,8 +240,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
222
240
|
- !ruby/object:Gem::Version
|
223
241
|
version: '0'
|
224
242
|
requirements: []
|
225
|
-
|
243
|
+
rubyforge_project:
|
244
|
+
rubygems_version: 2.6.6
|
226
245
|
signing_key:
|
227
246
|
specification_version: 4
|
228
|
-
summary:
|
247
|
+
summary: Gem for extending Peatio plugable system with Coinpayment implementation.
|
229
248
|
test_files: []
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Peatio
|
4
|
-
module Coinpaymentnew
|
5
|
-
class WalletApi
|
6
|
-
public
|
7
|
-
def self.balance
|
8
|
-
Coinpayments.balances
|
9
|
-
end
|
10
|
-
def self.rate
|
11
|
-
Coinpayments.rates
|
12
|
-
end
|
13
|
-
def self.createTransaction(amount, currency1, currency2, address)
|
14
|
-
Coinpayments.create_transaction(amount, currency1, currency2, {address: address, buyer_email: "joshirockstar007@gmail.com"})
|
15
|
-
end
|
16
|
-
def self.createWithdrawal(amount, currency, address)
|
17
|
-
Coinpayments.create_withdrawal(amount, currency, address)
|
18
|
-
end
|
19
|
-
def self.cancelWithdrawal(id)
|
20
|
-
Coinpayments.cancel_withdrawal(id)
|
21
|
-
end
|
22
|
-
def self.getTxInfo(txid)
|
23
|
-
Coinpayments.get_tx_info(txid)
|
24
|
-
end
|
25
|
-
def self.getCallbackAddress(currency)
|
26
|
-
Coinpayments.get_callback_address(currency)
|
27
|
-
end
|
28
|
-
def self.get_deposit_address(currency, options = {})
|
29
|
-
args = { currency: currency }.merge!(options)
|
30
|
-
Coinpayments.api_call(args)
|
31
|
-
end
|
32
|
-
def self.getWithdrawalInfo(id)
|
33
|
-
Coinpayments.get_withdrawal_info(id)
|
34
|
-
end
|
35
|
-
def self.Sign(secretPhrase)
|
36
|
-
Coinpayments.sign(secretPhrase)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|