peatio-decredcoin 2.0.2 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/peatio/decredcoin/blockchain.rb +5 -8
- data/lib/peatio/decredcoin/client.rb +3 -5
- data/lib/peatio/decredcoin/version.rb +1 -1
- data/lib/peatio/decredcoin/wallet.rb +22 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a29cfc88f36b57a5541a40f2870e49ce4dfbf941ab162e143b878db47d6fdf2e
|
4
|
+
data.tar.gz: 703d9426bb8a02ed9f163421cf6dd7760329a972533765122d7e41eabaec3087
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa8874c7a3afc6bfb0ed5dbae2b282470685df738a2e2d2e2258dd47966341a0da5e718cadaea6d4975d8e5b233f5e1532ab4c05a6de9d0304db8a027ef89d57
|
7
|
+
data.tar.gz: 7e763b8ffd44599f93fc1cc0a85035adc65d9801e3b5b4b8bf56c5984fc158d0be38eed564db3253a084711c4418a40ed26313d8dfa8971e69638ca168a6279b
|
data/Gemfile.lock
CHANGED
@@ -19,8 +19,8 @@ module Peatio
|
|
19
19
|
def fetch_block!(block_number)
|
20
20
|
block_hash = client.json_rpc(:getblockhash, [block_number])
|
21
21
|
|
22
|
-
client.json_rpc(:getblock, [block_hash,
|
23
|
-
.fetch('
|
22
|
+
client.json_rpc(:getblock, [block_hash, true, true])
|
23
|
+
.fetch('rawtx').each_with_object([]) do |tx, txs_array|
|
24
24
|
txs = build_transaction(tx).map do |ntx|
|
25
25
|
Peatio::Transaction.new(ntx.merge(block_number: block_number))
|
26
26
|
end
|
@@ -53,12 +53,9 @@ module Peatio
|
|
53
53
|
private
|
54
54
|
|
55
55
|
def build_transaction(tx_hash)
|
56
|
-
tx_hash.fetch('vout')
|
57
|
-
|
58
|
-
|
59
|
-
entry['scriptPubKey'].has_key?('addresses')
|
60
|
-
end
|
61
|
-
.each_with_object([]) do |entry, formatted_txs|
|
56
|
+
tx_hash.fetch('vout').select do |entry|
|
57
|
+
entry.fetch('value').to_d > 0 && entry['scriptPubKey'].has_key?('addresses')
|
58
|
+
end.each_with_object([]) do |entry, formatted_txs|
|
62
59
|
no_currency_tx =
|
63
60
|
{ hash: tx_hash['txid'], txout: entry['n'],
|
64
61
|
to_address: entry['scriptPubKey']['addresses'][0],
|
@@ -47,14 +47,12 @@ module Peatio
|
|
47
47
|
private
|
48
48
|
|
49
49
|
def connection
|
50
|
+
user, pass = [@json_rpc_endpoint.user, @json_rpc_endpoint.password]
|
50
51
|
@connection ||= Faraday.new(@json_rpc_endpoint) do |f|
|
51
|
-
f.adapter :
|
52
|
+
f.adapter :net_http, pool_size: 5
|
52
53
|
f.ssl[:verify] = @is_secure
|
53
54
|
end.tap do |connection|
|
54
|
-
unless
|
55
|
-
connection.basic_auth(@json_rpc_endpoint.user,
|
56
|
-
@json_rpc_endpoint.password)
|
57
|
-
end
|
55
|
+
connection.basic_auth(user, pass) unless user.blank?
|
58
56
|
end
|
59
57
|
end
|
60
58
|
end
|
@@ -31,14 +31,26 @@ module Peatio
|
|
31
31
|
raise Peatio::Wallet::ClientError, e
|
32
32
|
end
|
33
33
|
|
34
|
+
|
35
|
+
|
36
|
+
def unlock_wallet!(passphrase, timeout = 15)
|
37
|
+
# unlock wallet for 10 seconds
|
38
|
+
client.json_rpc(:walletpassphrase,
|
39
|
+
[
|
40
|
+
passphrase,
|
41
|
+
timeout
|
42
|
+
])
|
43
|
+
rescue Decredcoin::Client::Error => e
|
44
|
+
raise Peatio::Wallet::ClientError, e
|
45
|
+
end
|
46
|
+
|
47
|
+
|
34
48
|
def create_transaction!(transaction, options = {})
|
49
|
+
# create a transaction
|
35
50
|
txid = client.json_rpc(:sendtoaddress,
|
36
51
|
[
|
37
52
|
transaction.to_address,
|
38
|
-
transaction.amount
|
39
|
-
'',
|
40
|
-
'',
|
41
|
-
options[:subtract_fee].to_s == 'true' # subtract fee from transaction amount.
|
53
|
+
transaction.amount.to_f
|
42
54
|
])
|
43
55
|
transaction.hash = txid
|
44
56
|
transaction
|
@@ -46,9 +58,13 @@ module Peatio
|
|
46
58
|
raise Peatio::Wallet::ClientError, e
|
47
59
|
end
|
48
60
|
|
49
|
-
def load_balance!
|
50
|
-
client.json_rpc(:getbalance)
|
61
|
+
def load_balance!(account_name = 'default')
|
62
|
+
response = client.json_rpc(:getbalance)
|
63
|
+
account = response['balances'].find { |k| k['accountname'].eql? account_name }
|
64
|
+
|
65
|
+
raise Decredcoin::Client::Error.new 'account does not exists' unless account
|
51
66
|
|
67
|
+
account['total'].to_d
|
52
68
|
rescue Decredcoin::Client::Error => e
|
53
69
|
raise Peatio::Wallet::ClientError, e
|
54
70
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peatio-decredcoin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anuj Dhiman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|