onchain 2.9 → 2.10

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: 3037153f95c9742df2811795da1e6c88c21d2657
4
- data.tar.gz: 8bf7f316f57ad0d061e1dee71dc1650a5a7a54b3
3
+ metadata.gz: 13193d3a144ac9f25ab2341bdd0496595fc0b5e5
4
+ data.tar.gz: 68630a1e6e14f3dfeb114059251b8298ab451f31
5
5
  SHA512:
6
- metadata.gz: c039e25ab8f7b4c9410e79fbd0dfb39f287966c061cffa4e94a3f46bfd0c5d1522363a81e8b7df3617670788d375ba8f06a8a3c664360bc4c3c3964272717ce3
7
- data.tar.gz: 47901d42debef2730f8d2a4a90a0fb4d571d400da491ef36a092e209ca242dc8f3f769ec69facf4d4f31c70149eca54f5785fc537a0b1f3225d55b3a7ae9d7da
6
+ metadata.gz: b900108f3ca41817c0b017f384ccc5d8f73c2214683e83d6b9d0b7f9a5f9f59d281c57e74b7927fafa20e2f93e5b60591060db9a61bdbdce238c3febe7176a6b
7
+ data.tar.gz: bfe293fc99c30563e381f8969c0db4e994c367f3a28b3876c702610668efccaa116c761b689e78161de50117765f56876e8c20ff412b77031b36e96a29306cf3
@@ -50,6 +50,7 @@ class OnChain::BlockChain
50
50
  end
51
51
  row[:total] = val
52
52
  row[:recv] = recv
53
+ row[:hash] = tx["hash"]
53
54
  hist << row
54
55
  end
55
56
  return hist
data/lib/onchain.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'onchain/block_chain.rb'
2
2
  require 'onchain/providers/blockchaininfo_api.rb'
3
3
  require 'onchain/providers/blockr_api.rb'
4
- require 'onchain/providers/chaincom_api.rb'
5
4
  require 'onchain/sweeper.rb'
6
5
  require 'onchain/payments.rb'
7
6
  require 'onchain/transaction.rb'
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.9'
4
+ version: '2.10'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Purton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-18 00:00:00.000000000 Z
11
+ date: 2016-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: chain-ruby
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 2.0.1
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: 2.0.1
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: httparty
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -106,7 +92,6 @@ files:
106
92
  - lib/onchain/payments.rb
107
93
  - lib/onchain/providers/blockchaininfo_api.rb
108
94
  - lib/onchain/providers/blockr_api.rb
109
- - lib/onchain/providers/chaincom_api.rb
110
95
  - lib/onchain/sweeper.rb
111
96
  - lib/onchain/transaction.rb
112
97
  homepage: https://github.com/onchain/onchain-gem
@@ -128,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
113
  version: '0'
129
114
  requirements: []
130
115
  rubyforge_project:
131
- rubygems_version: 2.4.3
116
+ rubygems_version: 2.5.1
132
117
  signing_key:
133
118
  specification_version: 4
134
119
  summary: Ruby wrapper for various 3rd-party bitcoin APIs
@@ -1,134 +0,0 @@
1
- require 'chain'
2
- require 'time'
3
-
4
- # No longer works as Chain.com pivoted into a blockchain company.
5
- class OnChain::BlockChain
6
- class << self
7
-
8
-
9
- def chaincom_get_history_for_addresses(addresses)
10
- txs = Chain.get_addresses_transactions(addresses)
11
-
12
- return chaincom_parse_address_tx(addresses, txs)
13
- end
14
-
15
- def chaincom_address_history(address)
16
-
17
- txs = Chain.get_address_transactions(address)
18
-
19
- return chaincom_parse_address_tx([address], txs)
20
- end
21
-
22
- def chaincom_parse_address_tx(addresses, txs)
23
- hist = []
24
- txs.each do |tx|
25
- row = {}
26
- row[:time] = Time.parse(tx["block_time"]).to_i
27
- row[:addr] = {}
28
- row[:outs] = {}
29
-
30
- inputs = tx['inputs']
31
- val = 0
32
- recv = "Y"
33
- inputs.each do |input|
34
- row[:addr][input["addresses"][0]] = input["addresses"][0]
35
- if addresses.include? input["addresses"][0]
36
- recv = "N"
37
- end
38
- end
39
- tx["outputs"].each do |out|
40
- row[:outs][out["addresses"][0] ] = out["addresses"][0]
41
- if recv == "Y" and addresses.include? out["addresses"][0]
42
- val = val + out["value"].to_f / 100000000.0
43
- elsif recv == "N" and addresses.include? out["addresses"][0]
44
- val = val + out["value"].to_f / 100000000.0
45
- end
46
- end
47
- row[:total] = val
48
- row[:recv] = recv
49
- hist << row
50
- end
51
- return hist
52
- end
53
-
54
- def chaincom_send_tx(tx_hex)
55
-
56
- begin
57
- tx = Chain.send_transaction(tx_hex)
58
- tx_hash = tx["transaction_hash"]
59
- ret = "{\"status\":\"success\",\"data\":\"#{tx_hash}\",\"code\":200,\"message\":\"\"}"
60
- return JSON.parse(ret)
61
- rescue => e
62
- ret = "{\"status\":\"failure\",\"data\":\"#{tx_hash}\",\"code\":200,\"message\":\"#{e.to_s}\"}"
63
- return JSON.parse(ret)
64
- end
65
- end
66
-
67
- def chaincom_get_balance(address)
68
- if cache_read(address) == nil
69
-
70
- addr = Chain.get_address(address)
71
- if addr.count > 0
72
- bal = addr[0]["total"]["balance"].to_i / 100000000.0
73
- cache_write(address, bal, BALANCE_CACHE_FOR)
74
- end
75
-
76
- end
77
- return cache_read(address)
78
- end
79
-
80
- def chaincom_get_transactions(address)
81
-
82
- txs = Chain.get_address_transactions(address)
83
-
84
- unspent = []
85
-
86
- txs.each do |data|
87
- line = []
88
- line << data['hash']
89
- line << data["outputs"][0]["value"] / 100000000.0
90
- unspent << line
91
- end
92
-
93
- return unspent
94
- end
95
-
96
- def chaincom_get_unspent_outs(address)
97
-
98
- uns = Chain.get_address_unspents(address)
99
-
100
- unspent = []
101
-
102
- uns.each do |data|
103
- line = []
104
- line << data['transaction_hash']
105
- line << data['output_index']
106
- line << data['script_hex']
107
- line << data['value']
108
- unspent << line
109
- end
110
-
111
- return unspent
112
- end
113
-
114
- def chaincom_get_all_balances(addresses)
115
-
116
- addr = get_uncached_addresses(addresses)
117
-
118
- if addr.length == 0
119
- return
120
- end
121
-
122
- res = Chain.get_addresses(addr)
123
-
124
- if ! res.kind_of?(Array)
125
- res = [res]
126
- end
127
-
128
- res.each do |address|
129
- bal = address["total"]["balance"] / 100000000.0
130
- cache_write(address["address"], bal, BALANCE_CACHE_FOR)
131
- end
132
- end
133
- end
134
- end