peatio-decredcoin 2.0.3 → 3.0.1
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/peatio/decredcoin/blockchain.rb +5 -8
- data/lib/peatio/decredcoin/version.rb +1 -1
- data/lib/peatio/decredcoin/wallet.rb +21 -7
- 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: ba6527e3a8120dd3f82a8ae75e287680e0c1413af2eccee5492ecdc1dc9b29e8
|
4
|
+
data.tar.gz: 5d554617a8ebfff649c71ff516b838bc3858e2a09bbfe9f249fccdf8b8db6eab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67fd7d1622e46f75c0c694cc945b8394d36da57fcb23f9a41e1eae0a62741fcc79c9a6f6438daba8f8879748ec94de0aa666f858f2af2f36e7ae38c330c7c356
|
7
|
+
data.tar.gz: cec8773eae6c3022fd45679771a19c4ad0ecd4bf28a41062ccba891cb57ef9999b2e3b23f5a15da302c52c3155a325cc571ef9b82c583e8b393d776fbdc1493e
|
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],
|
@@ -18,7 +18,7 @@ module Peatio
|
|
18
18
|
|
19
19
|
@wallet = @settings.fetch(:wallet) do
|
20
20
|
raise Peatio::Wallet::MissingSettingError, :wallet
|
21
|
-
end.slice(:uri, :address)
|
21
|
+
end.slice(:uri, :address, :passphrase)
|
22
22
|
|
23
23
|
@currency = @settings.fetch(:currency) do
|
24
24
|
raise Peatio::Wallet::MissingSettingError, :currency
|
@@ -31,14 +31,13 @@ module Peatio
|
|
31
31
|
raise Peatio::Wallet::ClientError, e
|
32
32
|
end
|
33
33
|
|
34
|
+
# create a transaction
|
34
35
|
def create_transaction!(transaction, options = {})
|
36
|
+
unlock_wallet!(options[:timeout])
|
35
37
|
txid = client.json_rpc(:sendtoaddress,
|
36
38
|
[
|
37
39
|
transaction.to_address,
|
38
|
-
transaction.amount
|
39
|
-
'',
|
40
|
-
'',
|
41
|
-
options[:subtract_fee].to_s == 'true' # subtract fee from transaction amount.
|
40
|
+
transaction.amount.to_f
|
42
41
|
])
|
43
42
|
transaction.hash = txid
|
44
43
|
transaction
|
@@ -46,15 +45,30 @@ module Peatio
|
|
46
45
|
raise Peatio::Wallet::ClientError, e
|
47
46
|
end
|
48
47
|
|
49
|
-
def load_balance!
|
50
|
-
client.json_rpc(:getbalance)
|
48
|
+
def load_balance!(account_name = 'default')
|
49
|
+
response = client.json_rpc(:getbalance)
|
50
|
+
account = response['balances'].find { |k| k['accountname'].eql? account_name }
|
51
51
|
|
52
|
+
raise Decredcoin::Client::Error.new 'account does not exists' unless account
|
53
|
+
|
54
|
+
account['total'].to_d
|
52
55
|
rescue Decredcoin::Client::Error => e
|
53
56
|
raise Peatio::Wallet::ClientError, e
|
54
57
|
end
|
55
58
|
|
56
59
|
private
|
57
60
|
|
61
|
+
# unlock wallet for 15 seconds
|
62
|
+
def unlock_wallet!(timeout = 15)
|
63
|
+
client.json_rpc(:walletpassphrase,
|
64
|
+
[
|
65
|
+
@wallet.fetch(:passphrase),
|
66
|
+
timeout
|
67
|
+
])
|
68
|
+
rescue Decredcoin::Client::Error => e
|
69
|
+
raise Peatio::Wallet::ClientError, e
|
70
|
+
end
|
71
|
+
|
58
72
|
def client
|
59
73
|
uri = @wallet.fetch(:uri) { raise Peatio::Wallet::MissingSettingError, :uri }
|
60
74
|
@client ||= Client.new(uri)
|
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.1
|
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
|
+
date: 2020-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|