blockchain 1.0.0 → 1.0.1

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: 018e78fa4e59f75c5e786819ca080b696ef6dd33
4
- data.tar.gz: 02d086845dd8c96c335e4cbb358c7ba9648b3149
3
+ metadata.gz: fc351556b8fbc069d8c3024ea36034b80d6725fc
4
+ data.tar.gz: 975e1a63714a15938e09eda0d933b1ce4005e905
5
5
  SHA512:
6
- metadata.gz: 51da40ee452dd3107775d4fad95c76983bf29976e25e0abd420ae3dbf0740f3e9d7e958e57681e178903cd950812dff5b2efc311f593f1c2c28fb94894726ebf
7
- data.tar.gz: 7a6ff5c6980ece9c49d1b1165ec830e02b37b56f559f7e70ea15bdc69d4da15dec3a303e3f6873cb391cec3314497203f70ade6679b105c74669eb0deaf3f968
6
+ metadata.gz: 10bb6cef898174112505925c8c77e51f5a76e2a35d7397ef1217c3682f80be1fff9f5f22e51154346b40fa8c840ad11f621d091a92dfdc26d57e54195180dd7b
7
+ data.tar.gz: 8c7837196f1bf6ccbfa54011ab1256314915b20661ae278df3da2e5ed25e59ead967d097828b90d2e40c8e37cc37a95e1479d254f0b24201c42b62c528325a27
data/README.md CHANGED
@@ -22,6 +22,7 @@ The gem consists of the following functionality:
22
22
  * `blockexplorer` ([docs](docs/blockexplorer.md)) ([api/blockchain_api][api1])
23
23
  * `createwallet` ([docs](docs/createwallet.md)) ([api/create_wallet][api2])
24
24
  * `exchangerates` ([docs](docs/exchangerates.md)) ([api/exchange\_rates\_api][api3])
25
+ * `pushtx` ([docs](docs/pushtx.md)) ([pushtx][api7])
25
26
  * `receive` ([docs](docs/receive.md)) ([api/api_receive][api4])
26
27
  * `statistics` ([docs](docs/statistics.md)) ([api/charts_api][api5])
27
28
  * `wallet` ([docs](docs/wallet.md)) ([api/blockchain\_wallet\_api][api6])
@@ -32,6 +33,15 @@ The main module is called `Blockchain`
32
33
 
33
34
  All functions may raise exceptions caused by incorrectly passed parameters or other problems. If a call is rejected server-side, the `APIException` exception will be raised.
34
35
 
36
+ ###Connection timeouts
37
+
38
+ It is possible to set arbitrary connection timeouts.
39
+
40
+ ```ruby
41
+ require 'blockchain'
42
+ Blockchain::TIMEOUT_SECONDS = 5 #time out after 5 seconds
43
+ ```
44
+
35
45
  ###Request limits and API keys
36
46
 
37
47
  In order to prevent abuse some API methods require an API key approved with some basic contact information and a description of its intended use. Please request an API key [here](https://blockchain.info/api/api_create_code).
@@ -43,4 +53,5 @@ The same API key can be used to bypass the request limiter.
43
53
  [api3]: https://blockchain.info/api/exchange_rates_api
44
54
  [api4]: https://blockchain.info/api/api_receive
45
55
  [api5]: https://blockchain.info/api/charts_api
46
- [api6]: https://blockchain.info/api/blockchain_wallet_api
56
+ [api6]: https://blockchain.info/api/blockchain_wallet_api
57
+ [api7]: https://blockchain.info/pushtx
@@ -0,0 +1,18 @@
1
+ ##Push transaction functionality
2
+
3
+ ####`pushtx`
4
+ Call the pushtx endpoint and broadcast a hex encoded transaction. The method does not return anything upon success, but will raise exceptions if the transaction is malformed.
5
+
6
+ Params:
7
+ ```
8
+ tx : str (hex encoded)
9
+ api_code : str (optional)
10
+ ```
11
+
12
+ Usage:
13
+ ```ruby
14
+ require 'blockchain'
15
+
16
+ Blockchain::pushtx( '0100000001fd468e431cf5797b108e4d22724e1e055b3ecec59af4ef17b063afd36d3c5cf6010000008c4930460221009918eee8be186035be8ca573b7a4ef7bc672c59430785e5390cc375329a2099702210085b86387e3e15d68c847a1bdf786ed0fdbc87ab3b7c224f3c5490ac19ff4e756014104fe2cfcf0733e559cbf28d7b1489a673c0d7d6de8470d7ff3b272e7221afb051b777b5f879dd6a8908f459f950650319f0e83a5cf1d7c1dfadf6458f09a84ba80ffffffff01185d2033000000001976a9144be9a6a5f6fb75765145d9c54f1a4929e407d2ec88ac00000000')
17
+
18
+ ```
@@ -2,6 +2,7 @@ require "blockchain/version"
2
2
  require "blockchain/blockexplorer"
3
3
  require "blockchain/createwallet"
4
4
  require "blockchain/exchangerates"
5
+ require "blockchain/pushtx"
5
6
  require "blockchain/receive"
6
7
  require "blockchain/statistics"
7
8
  require "blockchain/wallet"
@@ -0,0 +1,16 @@
1
+ require 'json'
2
+ require_relative 'util'
3
+
4
+ module Blockchain
5
+
6
+ def self.pushtx(tx, api_code = nil)
7
+ params = { 'tx' => tx }
8
+
9
+ if !api_code.nil?
10
+ params['api_code'] = api_code
11
+ end
12
+
13
+ Blockchain::call_api('pushtx', method: 'post', data: params)
14
+ end
15
+
16
+ end
@@ -6,11 +6,13 @@ module Blockchain
6
6
  end
7
7
 
8
8
  BASE_URL = "https://blockchain.info/"
9
-
9
+ TIMEOUT_SECONDS = 10
10
+
10
11
  def self.call_api(resource, method: 'get', data: nil)
11
12
  url = URI.parse(BASE_URL + resource)
12
13
  http = Net::HTTP.new(url.host, url.port)
13
14
  http.use_ssl = true
15
+ http.read_timeout = TIMEOUT_SECONDS
14
16
 
15
17
  request = nil
16
18
  if method == 'get'
@@ -1,3 +1,3 @@
1
1
  module Blockchain
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blockchain
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blockchain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-03 00:00:00.000000000 Z
11
+ date: 2014-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -54,6 +54,7 @@ files:
54
54
  - docs/blockexplorer.md
55
55
  - docs/createwallet.md
56
56
  - docs/exchangerates.md
57
+ - docs/pushtx.md
57
58
  - docs/receive.md
58
59
  - docs/statistics.md
59
60
  - docs/wallet.md
@@ -61,6 +62,7 @@ files:
61
62
  - lib/blockchain/blockexplorer.rb
62
63
  - lib/blockchain/createwallet.rb
63
64
  - lib/blockchain/exchangerates.rb
65
+ - lib/blockchain/pushtx.rb
64
66
  - lib/blockchain/receive.rb
65
67
  - lib/blockchain/statistics.rb
66
68
  - lib/blockchain/util.rb