onchain 1.3.8 → 1.4.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
  SHA1:
3
- metadata.gz: 4842e854a22d1510b4299e4410d1a28340be9838
4
- data.tar.gz: 588ae51421710cf89725901bfccf7335bd4d0b8e
3
+ metadata.gz: f331e93b3b5c9a5f347417ba89075b2c8742368a
4
+ data.tar.gz: 5e18cd6bea2f7feb4ff434303152e925644cf1ac
5
5
  SHA512:
6
- metadata.gz: eed0ff672c4173c3c2c5836fbbba6fe50118530f0bae073096f03d83509fea6e3ff38f3ed86b9c733758df8ae7cd55228f45ec535152f4ebf961c0660fd9f7f1
7
- data.tar.gz: 84801fef500cd3a5cc4ae6922a17697148fd23eb2515ad27c43a279229945b5cdfabc9969760ae3871f8e3cf562577c8767369c47964136e2984cca32e44555a
6
+ metadata.gz: 3d674915a2a462c5b1879ba27504e168b45a284722935345376abc139d93b375664241435d221e7605baf079efcc8784537f37518655e2a94ab1ad728fc45e1f
7
+ data.tar.gz: d4591b69858b47db70c866fcd990831cb799cf7f3e6b40498ec2d643a193bebbe0ff436dba1c047fc1568c3a344200084744939661be2522fc8cf41acaf2df9f
@@ -75,14 +75,6 @@ class OnChain::BlockChain
75
75
  return ret
76
76
  end
77
77
 
78
- def get_history_for_addresses(addresses)
79
- history = []
80
- addresses.each do |address|
81
- history << address_history(address)
82
- end
83
- return history
84
- end
85
-
86
78
  def get_balance_satoshi(address)
87
79
  return (get_balance(address).to_f * 100000000).to_i
88
80
  end
@@ -104,6 +96,10 @@ class OnChain::BlockChain
104
96
  next
105
97
  end
106
98
 
99
+ if supplier == :blockr and method_name == 'get_history_for_addresses'
100
+ next
101
+ end
102
+
107
103
  available << supplier
108
104
  end
109
105
  end
@@ -1,12 +1,28 @@
1
1
  class OnChain::BlockChain
2
2
  class << self
3
3
 
4
+
5
+ def blockinfo_get_history_for_addresses(addresses)
6
+ history = []
7
+ addresses.each do |address|
8
+ res = blockinfo_address_history(address)
9
+ res.each do |r|
10
+ history << r
11
+ end
12
+ end
13
+ return history
14
+ end
4
15
 
5
16
  def blockinfo_address_history(address)
6
17
 
7
18
  base_url = "http://blockchain.info/address/#{address}?format=json"
8
19
  json = fetch_response(base_url, true)
9
20
 
21
+ blockinfo_parse_address_tx(address, json)
22
+ end
23
+
24
+ def blockinfo_parse_address_tx(address, json)
25
+
10
26
  hist = []
11
27
  if json.key?('txs')
12
28
  txs = json['txs']
@@ -40,6 +56,7 @@ class OnChain::BlockChain
40
56
  else
41
57
  'Error'
42
58
  end
59
+ return hist
43
60
  end
44
61
 
45
62
  def blockinfo_get_all_balances(addresses)
@@ -2,15 +2,26 @@ require 'chain'
2
2
 
3
3
  class OnChain::BlockChain
4
4
  class << self
5
-
5
+
6
+
7
+ def chaincom_get_history_for_addresses(addresses)
8
+ txs = Chain.get_addresses_transactions(addresses)
9
+
10
+ return chaincom_parse_address_tx(addresses, txs)
11
+ end
12
+
6
13
  def chaincom_address_history(address)
7
14
 
8
15
  txs = Chain.get_address_transactions(address)
9
16
 
17
+ return chaincom_parse_address_tx([address], txs)
18
+ end
19
+
20
+ def chaincom_parse_address_tx(addresses, txs)
10
21
  hist = []
11
22
  txs.each do |tx|
12
23
  row = {}
13
- row[:time] = tx["block_time"]
24
+ row[:time] = Date.parse(tx["block_time"]).to_s
14
25
  row[:addr] = {}
15
26
  row[:outs] = {}
16
27
  inputs = tx['inputs']
@@ -18,15 +29,15 @@ class OnChain::BlockChain
18
29
  recv = "Y"
19
30
  inputs.each do |input|
20
31
  row[:addr][input["addresses"][0]] = input["addresses"][0]
21
- if input["addresses"][0] == address
32
+ if addresses.include? input["addresses"][0]
22
33
  recv = "N"
23
34
  end
24
35
  end
25
36
  tx["outputs"].each do |out|
26
37
  row[:outs][out["addresses"][0] ] = out["addresses"][0]
27
- if recv == "Y" and out["addresses"][0] == address
38
+ if recv == "Y" and addresses.include? out["addresses"][0]
28
39
  val = val + out["value"].to_f / 100000000.0
29
- elsif recv == "N" and out["addresses"][0] != address
40
+ elsif recv == "N" and addresses.include? out["addresses"][0]
30
41
  val = val + out["value"].to_f / 100000000.0
31
42
  end
32
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onchain
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.8
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Purton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-05 00:00:00.000000000 Z
11
+ date: 2014-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake