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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c36d1210e5f6d8a64f5d0bb4afc34a495224f8f881e5cd73185999499d480d2e
4
- data.tar.gz: 82669f2e9ec354a6dbc856e16b80386540f7361e529276086d2edec1999c7a61
3
+ metadata.gz: a29cfc88f36b57a5541a40f2870e49ce4dfbf941ab162e143b878db47d6fdf2e
4
+ data.tar.gz: 703d9426bb8a02ed9f163421cf6dd7760329a972533765122d7e41eabaec3087
5
5
  SHA512:
6
- metadata.gz: d45e974d265dc09aa4255c98f48c0b2011806c67c9ec670b44e7709c1099f1a3265c3310e02fe26e55fbada0b86d1022220948787317d51ad0bb23312fa5f87f
7
- data.tar.gz: 51d3bfa1ed6ff1b0135ae9d453506a156f526f22b6570bba7bf7bdb54ba7e07250443927e9ca4d5dc2d140a406f60dc85d6cc688f2a0b45caa481ab9b76466a2
6
+ metadata.gz: aa8874c7a3afc6bfb0ed5dbae2b282470685df738a2e2d2e2258dd47966341a0da5e718cadaea6d4975d8e5b233f5e1532ab4c05a6de9d0304db8a027ef89d57
7
+ data.tar.gz: 7e763b8ffd44599f93fc1cc0a85035adc65d9801e3b5b4b8bf56c5984fc158d0be38eed564db3253a084711c4418a40ed26313d8dfa8971e69638ca168a6279b
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- peatio-decredcoin (2.0.1)
4
+ peatio-decredcoin (2.1.1)
5
5
  activesupport (~> 5.2.3)
6
6
  better-faraday (~> 1.0.5)
7
7
  faraday (~> 0.17)
@@ -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, 2])
23
- .fetch('tx').each_with_object([]) do |tx, txs_array|
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
- .select do |entry|
58
- entry.fetch('value').to_d > 0 &&
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 :net_http_persistent, pool_size: 5
52
+ f.adapter :net_http, pool_size: 5
52
53
  f.ssl[:verify] = @is_secure
53
54
  end.tap do |connection|
54
- unless @json_rpc_endpoint.user.blank?
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
@@ -1,5 +1,5 @@
1
1
  module Peatio
2
2
  module Decredcoin
3
- VERSION = "2.0.2".freeze
3
+ VERSION = "3.0.0".freeze
4
4
  end
5
5
  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).to_d
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: 2.0.2
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-25 00:00:00.000000000 Z
11
+ date: 2020-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport