peatio-decredcoin 2.0.1 → 2.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a6e7c138c5e6f375938b152cbb89df856f20be19821d7f3aa63b3eea91be2c5
4
- data.tar.gz: 819b6b234844c242713aaf8472c6020d6325145f348c099ec0f083d42dc75ab8
3
+ metadata.gz: bdd4576af52bb55c83e9efa792861342290f34b717255a4a166e2dfbcc025ddd
4
+ data.tar.gz: 7960d3c91a761780b13f3f4b37c2687ca4aa0d0c9968701e3a82537f0a598eb6
5
5
  SHA512:
6
- metadata.gz: c10f34b4c6762d333dbfbb77c0431702f528ef04cb20ed503eae049bdb61ec5483ffa418e93a31ea4740a3545bdd12c25f3e9eda0d5b75b03a2d1f294f4087e6
7
- data.tar.gz: bd636a00b5ddd8b5f9fadb948d4cd97d37381d5197ac68fe6d6b1d33e5c774b04f480f27163331b4675729ed06b6c1902af71a0070cf03b89e4241ad69355cde
6
+ metadata.gz: dfa5b3e27be8ea8f4709215fce0ff8024f40a87bf076532af0a82fa9156143eafbde825387f5125c645a6cf1dc684c75caa25121373b39c0c733d70641e55694
7
+ data.tar.gz: '08e8497ee99301a6f6c459350e2281245a545f0d6a796de20bf790711193299725dd99e3f0d3157deeb6d260acbd8daad5ced9cc6e725a8e6c5021a94db79a1f'
@@ -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.1".freeze
3
+ VERSION = "2.1.2".freeze
4
4
  end
5
5
  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).to_d
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.0.1
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-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