onchain 2.10 → 2.11

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
  SHA1:
3
- metadata.gz: 13193d3a144ac9f25ab2341bdd0496595fc0b5e5
4
- data.tar.gz: 68630a1e6e14f3dfeb114059251b8298ab451f31
3
+ metadata.gz: 37620347d276dbb06380d75daf4a64352ba4bbb5
4
+ data.tar.gz: f4324683549de22621531fa841eeadaec1bf21c1
5
5
  SHA512:
6
- metadata.gz: b900108f3ca41817c0b017f384ccc5d8f73c2214683e83d6b9d0b7f9a5f9f59d281c57e74b7927fafa20e2f93e5b60591060db9a61bdbdce238c3febe7176a6b
7
- data.tar.gz: bfe293fc99c30563e381f8969c0db4e994c367f3a28b3876c702610668efccaa116c761b689e78161de50117765f56876e8c20ff412b77031b36e96a29306cf3
6
+ metadata.gz: 6eb80d1825a3ef44c1b5b167aa35fa84f7d03d387833ecc9d95f01b7480b2f8d0185ba77d2bb6e58c389c2cceeee726779859d18ad9425c8ca5836d77ba86137
7
+ data.tar.gz: 7f2e92679a9e926a8e46f3292339fd9928d386855c6c20306a19450f99b0bb19d87044099692ad14cea013938faef2b4aedb942992b2a2d7d19eab66dc4b9199
@@ -31,15 +31,6 @@ class OnChain::BlockChain
31
31
 
32
32
  def method_missing (method_name, *args, &block)
33
33
 
34
- if ENV['CHAIN-API-KEY-ID'] != nil
35
- begin
36
- Chain.api_key_id = ENV['CHAIN-API-KEY-ID']
37
- Chain.api_key_secret = ENV['CHAIN-API-KEY-SECRET']
38
- rescue
39
- # Had problems setting this so get arou d it.
40
- end
41
- end
42
-
43
34
  network = :bitcoin
44
35
  if args.length > 0
45
36
  if args[args.length - 1] == :testnet3
@@ -133,7 +124,7 @@ class OnChain::BlockChain
133
124
  next
134
125
  end
135
126
 
136
- if supplier == :blockr and method_name.to_s == 'address_history'
127
+ if supplier == :blockrand and network == :bitcoin and method_name.to_s == 'address_history'
137
128
  next
138
129
  end
139
130
 
@@ -8,6 +8,56 @@ class OnChain::BlockChain
8
8
  return "http://tbtc.blockr.io/api/v1/"
9
9
  end
10
10
 
11
+ def blockr_address_history(address, network = :bitcoin)
12
+
13
+ json = blockr('address/txs', address, network)
14
+
15
+ return parse_address_tx(address, json, network)
16
+ end
17
+
18
+ def parse_address_tx(address, json, network)
19
+
20
+ hist = []
21
+ if json.key?('data')
22
+ txs = json['data']['txs']
23
+ txs.each do |tx|
24
+ row = {}
25
+ row[:time] = tx["time_utc"]
26
+ row[:addr] = {}
27
+ row[:outs] = {}
28
+ row[:hash] = tx["tx"]
29
+
30
+ # OK, go and get the actual transaction
31
+ tx_json = blockr('tx/info', tx["tx"], network)
32
+
33
+ inputs = tx_json['data']['trade']['vins']
34
+ val = 0
35
+ recv = "Y"
36
+ inputs.each do |input|
37
+ row[:addr][input["address"]] = input["address"]
38
+ if input["address"] == address
39
+ recv = "N"
40
+ end
41
+ end
42
+ tx_json['data']['trade']["vouts"].each do |out|
43
+ row[:outs][out["address"]] = out["address"]
44
+ if recv == "Y" and out["address"] == address
45
+ val = val + out["amount"].to_f
46
+ elsif recv == "N" and out["address"] != address
47
+ val = val + out["amount"].to_f
48
+ end
49
+ end
50
+ row[:total] = val
51
+ row[:recv] = recv
52
+ hist << row
53
+ end
54
+ return hist
55
+ else
56
+ 'Error'
57
+ end
58
+ return hist
59
+ end
60
+
11
61
  def blockr_send_tx(tx_hex, network = :bitcoin)
12
62
  uri = URI.parse(get_url(network) + "tx/push")
13
63
  http = Net::HTTP.new(uri.host, uri.port)
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: '2.10'
4
+ version: '2.11'
5
5
  platform: ruby
6
6
  authors:
7
- - Ian Purton
7
+ - Number 6
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-07 00:00:00.000000000 Z
11
+ date: 2016-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -82,7 +82,7 @@ dependencies:
82
82
  version: '0'
83
83
  description: Call 3rd party API's but also switch API's if a 3rd party is down
84
84
  email:
85
- - ian@onchain.io
85
+ - support@onchain.io
86
86
  executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []