peatio-decredcoin 2.0.1 → 2.1.2
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 +15 -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: bdd4576af52bb55c83e9efa792861342290f34b717255a4a166e2dfbcc025ddd
|
4
|
+
data.tar.gz: 7960d3c91a761780b13f3f4b37c2687ca4aa0d0c9968701e3a82537f0a598eb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfa5b3e27be8ea8f4709215fce0ff8024f40a87bf076532af0a82fa9156143eafbde825387f5125c645a6cf1dc684c75caa25121373b39c0c733d70641e55694
|
7
|
+
data.tar.gz: '08e8497ee99301a6f6c459350e2281245a545f0d6a796de20bf790711193299725dd99e3f0d3157deeb6d260acbd8daad5ced9cc6e725a8e6c5021a94db79a1f'
|
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
|
@@ -3,6 +3,7 @@ module Peatio
|
|
3
3
|
class Wallet < Peatio::Wallet::Abstract
|
4
4
|
|
5
5
|
DEFAULT_FEATURES = { skip_deposit_collection: false }.freeze
|
6
|
+
SUPPORTED_FEATURES = {case_sensitive: true, cash_addr_format: false}.freeze
|
6
7
|
|
7
8
|
def initialize(custom_features = {})
|
8
9
|
@features = DEFAULT_FEATURES.merge(custom_features).slice(*SUPPORTED_FEATURES)
|
@@ -31,13 +32,17 @@ module Peatio
|
|
31
32
|
end
|
32
33
|
|
33
34
|
def create_transaction!(transaction, options = {})
|
35
|
+
# unlock wallet for 10 seconds
|
36
|
+
client.json_rpc(:walletpassphrase,
|
37
|
+
[
|
38
|
+
options[:passphrase],
|
39
|
+
options[:seconds]
|
40
|
+
])
|
41
|
+
# create a transaction
|
34
42
|
txid = client.json_rpc(:sendtoaddress,
|
35
43
|
[
|
36
44
|
transaction.to_address,
|
37
|
-
transaction.amount
|
38
|
-
'',
|
39
|
-
'',
|
40
|
-
options[:subtract_fee].to_s == 'true' # subtract fee from transaction amount.
|
45
|
+
transaction.amount.to_f
|
41
46
|
])
|
42
47
|
transaction.hash = txid
|
43
48
|
transaction
|
@@ -45,9 +50,13 @@ module Peatio
|
|
45
50
|
raise Peatio::Wallet::ClientError, e
|
46
51
|
end
|
47
52
|
|
48
|
-
def load_balance!
|
49
|
-
client.json_rpc(:getbalance)
|
53
|
+
def load_balance!(account_name = 'default')
|
54
|
+
response = client.json_rpc(:getbalance)
|
55
|
+
account = response['balances'].find { |k| k['accountname'].eql? account_name }
|
50
56
|
|
57
|
+
raise Decredcoin::Client::Error.new 'account does not exists' unless account
|
58
|
+
|
59
|
+
account['total'].to_d
|
51
60
|
rescue Decredcoin::Client::Error => e
|
52
61
|
raise Peatio::Wallet::ClientError, e
|
53
62
|
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: 2.
|
4
|
+
version: 2.1.2
|
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
|