blockchain 1.0.2 → 1.1.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 +4 -4
- data/README.md +57 -57
- data/docs/blockexplorer.md +117 -117
- data/docs/createwallet.md +20 -20
- data/docs/exchangerates.md +31 -31
- data/docs/pushtx.md +18 -18
- data/docs/receive.md +57 -19
- data/docs/statistics.md +15 -15
- data/docs/wallet.md +148 -148
- data/lib/blockchain.rb +2 -1
- data/lib/blockchain/blockexplorer.rb +297 -297
- data/lib/blockchain/createwallet.rb +38 -38
- data/lib/blockchain/exchangerates.rb +46 -46
- data/lib/blockchain/pushtx.rb +15 -15
- data/lib/blockchain/receive.rb +85 -31
- data/lib/blockchain/statistics.rb +59 -59
- data/lib/blockchain/util.rb +34 -33
- data/lib/blockchain/version.rb +1 -1
- data/lib/blockchain/wallet.rb +166 -166
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e743573eea586a756a9be86dd0520a3ef75731ac
|
4
|
+
data.tar.gz: b0e4df9dcaadddbd4ea608ad52a7e7488ddb4372
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 776d8f47c6ab6880fc3597990d034f433b0a54075585cd936f8b068a98c9b48407fd14021a8108784dd75ca064efcb9d276af7684f8e1cdfb647e0fa72ab3c6d
|
7
|
+
data.tar.gz: 5b4ef222ccaabc04bdc9cbcd227b32ff1b3a1f5dcd684e7775cb30ee448b597c68f1d76302d1d549c5eb6003d76808b1298576429f6276e892708cd5dab2dc86
|
data/README.md
CHANGED
@@ -1,57 +1,57 @@
|
|
1
|
-
#Blockchain API library (Ruby, v1)
|
2
|
-
|
3
|
-
An official Ruby gem for interacting with the Blockchain.info API.
|
4
|
-
|
5
|
-
###Getting started
|
6
|
-
|
7
|
-
Installation via RubyGems:
|
8
|
-
|
9
|
-
```
|
10
|
-
$ gem install blockchain
|
11
|
-
```
|
12
|
-
|
13
|
-
Manual installation:
|
14
|
-
```
|
15
|
-
$ git clone https://github.com/blockchain/api-v1-client-ruby
|
16
|
-
$ cd api-v1-client-ruby
|
17
|
-
$ rake install
|
18
|
-
```
|
19
|
-
|
20
|
-
The gem consists of the following functionality:
|
21
|
-
|
22
|
-
* `blockexplorer` ([docs](docs/blockexplorer.md)) ([api/blockchain_api][api1])
|
23
|
-
* `createwallet` ([docs](docs/createwallet.md)) ([api/create_wallet][api2])
|
24
|
-
* `exchangerates` ([docs](docs/exchangerates.md)) ([api/exchange\_rates\_api][api3])
|
25
|
-
* `pushtx` ([docs](docs/pushtx.md)) ([pushtx][api7])
|
26
|
-
* `receive` ([docs](docs/receive.md)) ([api/api_receive][api4])
|
27
|
-
* `statistics` ([docs](docs/statistics.md)) ([api/charts_api][api5])
|
28
|
-
* `wallet` ([docs](docs/wallet.md)) ([api/blockchain\_wallet\_api][api6])
|
29
|
-
|
30
|
-
The main module is called `Blockchain`
|
31
|
-
|
32
|
-
###Error handling
|
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.
|
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
|
-
|
45
|
-
###Request limits and API keys
|
46
|
-
|
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).
|
48
|
-
|
49
|
-
The same API key can be used to bypass the request limiter.
|
50
|
-
|
51
|
-
[api1]: https://blockchain.info/api/blockchain_api
|
52
|
-
[api2]: https://blockchain.info/api/create_wallet
|
53
|
-
[api3]: https://blockchain.info/api/exchange_rates_api
|
54
|
-
[api4]: https://blockchain.info/api/api_receive
|
55
|
-
[api5]: https://blockchain.info/api/charts_api
|
56
|
-
[api6]: https://blockchain.info/api/blockchain_wallet_api
|
57
|
-
[api7]: https://blockchain.info/pushtx
|
1
|
+
#Blockchain API library (Ruby, v1)
|
2
|
+
|
3
|
+
An official Ruby gem for interacting with the Blockchain.info API.
|
4
|
+
|
5
|
+
###Getting started
|
6
|
+
|
7
|
+
Installation via RubyGems:
|
8
|
+
|
9
|
+
```
|
10
|
+
$ gem install blockchain
|
11
|
+
```
|
12
|
+
|
13
|
+
Manual installation:
|
14
|
+
```
|
15
|
+
$ git clone https://github.com/blockchain/api-v1-client-ruby
|
16
|
+
$ cd api-v1-client-ruby
|
17
|
+
$ rake install
|
18
|
+
```
|
19
|
+
|
20
|
+
The gem consists of the following functionality:
|
21
|
+
|
22
|
+
* `blockexplorer` ([docs](docs/blockexplorer.md)) ([api/blockchain_api][api1])
|
23
|
+
* `createwallet` ([docs](docs/createwallet.md)) ([api/create_wallet][api2])
|
24
|
+
* `exchangerates` ([docs](docs/exchangerates.md)) ([api/exchange\_rates\_api][api3])
|
25
|
+
* `pushtx` ([docs](docs/pushtx.md)) ([pushtx][api7])
|
26
|
+
* `receive` ([docs](docs/receive.md)) ([api/api_receive][api4])
|
27
|
+
* `statistics` ([docs](docs/statistics.md)) ([api/charts_api][api5])
|
28
|
+
* `wallet` ([docs](docs/wallet.md)) ([api/blockchain\_wallet\_api][api6])
|
29
|
+
|
30
|
+
The main module is called `Blockchain`
|
31
|
+
|
32
|
+
###Error handling
|
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.
|
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
|
+
|
45
|
+
###Request limits and API keys
|
46
|
+
|
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).
|
48
|
+
|
49
|
+
The same API key can be used to bypass the request limiter.
|
50
|
+
|
51
|
+
[api1]: https://blockchain.info/api/blockchain_api
|
52
|
+
[api2]: https://blockchain.info/api/create_wallet
|
53
|
+
[api3]: https://blockchain.info/api/exchange_rates_api
|
54
|
+
[api4]: https://blockchain.info/api/api_receive
|
55
|
+
[api5]: https://blockchain.info/api/charts_api
|
56
|
+
[api6]: https://blockchain.info/api/blockchain_wallet_api
|
57
|
+
[api7]: https://blockchain.info/pushtx
|
data/docs/blockexplorer.md
CHANGED
@@ -1,117 +1,117 @@
|
|
1
|
-
##Block explorer functionality
|
2
|
-
|
3
|
-
All functions support an optional parameter called `api_code`. It won't be listed with every function description.
|
4
|
-
|
5
|
-
####`get_block`
|
6
|
-
Get a single block based on a block index or hash. Returns a `Block` object.
|
7
|
-
|
8
|
-
Params:
|
9
|
-
```
|
10
|
-
block_id : str - block index or hash
|
11
|
-
```
|
12
|
-
|
13
|
-
Usage:
|
14
|
-
```ruby
|
15
|
-
require 'blockchain'
|
16
|
-
|
17
|
-
block = Blockchain::get_block('000000000000000016f9a2c3e0f4c1245ff24856a79c34806969f5084f410680')
|
18
|
-
```
|
19
|
-
|
20
|
-
####`get_tx`
|
21
|
-
Get a single transaction based on a transaction index or hash. Returns a `Transaction` object.
|
22
|
-
|
23
|
-
Params:
|
24
|
-
```
|
25
|
-
tx_id : str - transaction index or hash
|
26
|
-
```
|
27
|
-
|
28
|
-
Usage:
|
29
|
-
```ruby
|
30
|
-
tx = Blockchain::get_tx('d4af240386cdacab4ca666d178afc88280b620ae308ae8d2585e9ab8fc664a94')
|
31
|
-
```
|
32
|
-
|
33
|
-
####`get_block_height`
|
34
|
-
Get an array of blocks at the specified height. Returns an array of `Block` objects.
|
35
|
-
|
36
|
-
Params:
|
37
|
-
```
|
38
|
-
height : int - block height
|
39
|
-
```
|
40
|
-
|
41
|
-
Usage:
|
42
|
-
```ruby
|
43
|
-
blocks = Blockchain::get_block_height(2570)
|
44
|
-
```
|
45
|
-
|
46
|
-
####`get_address`
|
47
|
-
Get a single address and its transactions. Returns an `Address` object.
|
48
|
-
|
49
|
-
Params:
|
50
|
-
```
|
51
|
-
address : str - address in the base58 or hash160 format
|
52
|
-
```
|
53
|
-
|
54
|
-
Usage:
|
55
|
-
```ruby
|
56
|
-
address = Blockchain::get_address('1HS9RLmKvJ7D1ZYgfPExJZQZA1DMU3DEVd')
|
57
|
-
```
|
58
|
-
|
59
|
-
####`get_unspent_outputs`
|
60
|
-
Get an array of unspent outputs for an address. Returns an array of `UnspentOutput` objects.
|
61
|
-
|
62
|
-
Params:
|
63
|
-
```
|
64
|
-
address : str - address in the base58 or hash160 format
|
65
|
-
```
|
66
|
-
|
67
|
-
Usage:
|
68
|
-
```ruby
|
69
|
-
outs = Blockchain::get_unspent_outputs('1HS9RLmKvJ7D1ZYgfPExJZQZA1DMU3DEVd')
|
70
|
-
```
|
71
|
-
|
72
|
-
####`get_latest_block`
|
73
|
-
Get the latest block on the main chain. Returns a `LatestBlock` object.
|
74
|
-
|
75
|
-
Usage:
|
76
|
-
```ruby
|
77
|
-
latest_block = Blockchain::get_latest_block()
|
78
|
-
```
|
79
|
-
|
80
|
-
####`get_unconfirmed_tx`
|
81
|
-
Get a list of currently unconfirmed transactions. Returns an array of `Transaction` objects.
|
82
|
-
|
83
|
-
Usage:
|
84
|
-
```ruby
|
85
|
-
txs = Blockchain::get_unconfirmed_tx()
|
86
|
-
```
|
87
|
-
|
88
|
-
####`get_blocks`
|
89
|
-
Get a list of blocks for a specific day or mining pool. Returns an array of `SimpleBlock` objects.
|
90
|
-
|
91
|
-
Params:
|
92
|
-
```
|
93
|
-
time : int - unix time in ms (optional)
|
94
|
-
pool_name : str - pool name (optional)
|
95
|
-
```
|
96
|
-
At least one parameter is required.
|
97
|
-
|
98
|
-
Usage:
|
99
|
-
```ruby
|
100
|
-
blocks = Blockchain::get_blocks(pool_name = 'Discus Fish')
|
101
|
-
```
|
102
|
-
|
103
|
-
####`get_inventory_data`
|
104
|
-
Get inventory data for recent blocks and addresses (up to 1 hour old). Returns an `InventoryData` object.
|
105
|
-
|
106
|
-
Params:
|
107
|
-
```
|
108
|
-
hash : str - tx or block hash
|
109
|
-
```
|
110
|
-
|
111
|
-
Usage:
|
112
|
-
```ruby
|
113
|
-
inv = Blockchain::get_inventory_data('d4af240386cdacab4ca666d178afc88280b620ae308ae8d2585e9ab8fc664a94')
|
114
|
-
```
|
115
|
-
|
116
|
-
Note regarding `Input` objects: if coinbase transaction, only `script` and `script_siq` will be populated.
|
117
|
-
|
1
|
+
##Block explorer functionality
|
2
|
+
|
3
|
+
All functions support an optional parameter called `api_code`. It won't be listed with every function description.
|
4
|
+
|
5
|
+
####`get_block`
|
6
|
+
Get a single block based on a block index or hash. Returns a `Block` object.
|
7
|
+
|
8
|
+
Params:
|
9
|
+
```
|
10
|
+
block_id : str - block index or hash
|
11
|
+
```
|
12
|
+
|
13
|
+
Usage:
|
14
|
+
```ruby
|
15
|
+
require 'blockchain'
|
16
|
+
|
17
|
+
block = Blockchain::get_block('000000000000000016f9a2c3e0f4c1245ff24856a79c34806969f5084f410680')
|
18
|
+
```
|
19
|
+
|
20
|
+
####`get_tx`
|
21
|
+
Get a single transaction based on a transaction index or hash. Returns a `Transaction` object.
|
22
|
+
|
23
|
+
Params:
|
24
|
+
```
|
25
|
+
tx_id : str - transaction index or hash
|
26
|
+
```
|
27
|
+
|
28
|
+
Usage:
|
29
|
+
```ruby
|
30
|
+
tx = Blockchain::get_tx('d4af240386cdacab4ca666d178afc88280b620ae308ae8d2585e9ab8fc664a94')
|
31
|
+
```
|
32
|
+
|
33
|
+
####`get_block_height`
|
34
|
+
Get an array of blocks at the specified height. Returns an array of `Block` objects.
|
35
|
+
|
36
|
+
Params:
|
37
|
+
```
|
38
|
+
height : int - block height
|
39
|
+
```
|
40
|
+
|
41
|
+
Usage:
|
42
|
+
```ruby
|
43
|
+
blocks = Blockchain::get_block_height(2570)
|
44
|
+
```
|
45
|
+
|
46
|
+
####`get_address`
|
47
|
+
Get a single address and its transactions. Returns an `Address` object.
|
48
|
+
|
49
|
+
Params:
|
50
|
+
```
|
51
|
+
address : str - address in the base58 or hash160 format
|
52
|
+
```
|
53
|
+
|
54
|
+
Usage:
|
55
|
+
```ruby
|
56
|
+
address = Blockchain::get_address('1HS9RLmKvJ7D1ZYgfPExJZQZA1DMU3DEVd')
|
57
|
+
```
|
58
|
+
|
59
|
+
####`get_unspent_outputs`
|
60
|
+
Get an array of unspent outputs for an address. Returns an array of `UnspentOutput` objects.
|
61
|
+
|
62
|
+
Params:
|
63
|
+
```
|
64
|
+
address : str - address in the base58 or hash160 format
|
65
|
+
```
|
66
|
+
|
67
|
+
Usage:
|
68
|
+
```ruby
|
69
|
+
outs = Blockchain::get_unspent_outputs('1HS9RLmKvJ7D1ZYgfPExJZQZA1DMU3DEVd')
|
70
|
+
```
|
71
|
+
|
72
|
+
####`get_latest_block`
|
73
|
+
Get the latest block on the main chain. Returns a `LatestBlock` object.
|
74
|
+
|
75
|
+
Usage:
|
76
|
+
```ruby
|
77
|
+
latest_block = Blockchain::get_latest_block()
|
78
|
+
```
|
79
|
+
|
80
|
+
####`get_unconfirmed_tx`
|
81
|
+
Get a list of currently unconfirmed transactions. Returns an array of `Transaction` objects.
|
82
|
+
|
83
|
+
Usage:
|
84
|
+
```ruby
|
85
|
+
txs = Blockchain::get_unconfirmed_tx()
|
86
|
+
```
|
87
|
+
|
88
|
+
####`get_blocks`
|
89
|
+
Get a list of blocks for a specific day or mining pool. Returns an array of `SimpleBlock` objects.
|
90
|
+
|
91
|
+
Params:
|
92
|
+
```
|
93
|
+
time : int - unix time in ms (optional)
|
94
|
+
pool_name : str - pool name (optional)
|
95
|
+
```
|
96
|
+
At least one parameter is required.
|
97
|
+
|
98
|
+
Usage:
|
99
|
+
```ruby
|
100
|
+
blocks = Blockchain::get_blocks(pool_name = 'Discus Fish')
|
101
|
+
```
|
102
|
+
|
103
|
+
####`get_inventory_data`
|
104
|
+
Get inventory data for recent blocks and addresses (up to 1 hour old). Returns an `InventoryData` object.
|
105
|
+
|
106
|
+
Params:
|
107
|
+
```
|
108
|
+
hash : str - tx or block hash
|
109
|
+
```
|
110
|
+
|
111
|
+
Usage:
|
112
|
+
```ruby
|
113
|
+
inv = Blockchain::get_inventory_data('d4af240386cdacab4ca666d178afc88280b620ae308ae8d2585e9ab8fc664a94')
|
114
|
+
```
|
115
|
+
|
116
|
+
Note regarding `Input` objects: if coinbase transaction, only `script` and `script_siq` will be populated.
|
117
|
+
|
data/docs/createwallet.md
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
##Create Wallet functionality
|
2
|
-
|
3
|
-
####`create_wallet`
|
4
|
-
Create a new Blockchain.info wallet. It can be created containing a pre-generated private key or will otherwise generate a new private key. Returns a `CreateWalletResponse` instance.
|
5
|
-
|
6
|
-
Params:
|
7
|
-
```
|
8
|
-
password : str - password for the new wallet. At least 10 characters.
|
9
|
-
api_code : str - API code with the create wallets permission
|
10
|
-
priv : str - private key to add to the wallet (optional, keyword)
|
11
|
-
label : str - label for the first address in the wallet (optional, keyword)
|
12
|
-
email : str - email to associate with the new wallet (optional, keyword)
|
13
|
-
```
|
14
|
-
|
15
|
-
Usage:
|
16
|
-
```ruby
|
17
|
-
require 'blockchain'
|
18
|
-
|
19
|
-
wallet = Blockchain::create_wallet('1234password', '58ck39ajuiw', label: 'Test wallet')
|
20
|
-
```
|
1
|
+
##Create Wallet functionality
|
2
|
+
|
3
|
+
####`create_wallet`
|
4
|
+
Create a new Blockchain.info wallet. It can be created containing a pre-generated private key or will otherwise generate a new private key. Returns a `CreateWalletResponse` instance.
|
5
|
+
|
6
|
+
Params:
|
7
|
+
```
|
8
|
+
password : str - password for the new wallet. At least 10 characters.
|
9
|
+
api_code : str - API code with the create wallets permission
|
10
|
+
priv : str - private key to add to the wallet (optional, keyword)
|
11
|
+
label : str - label for the first address in the wallet (optional, keyword)
|
12
|
+
email : str - email to associate with the new wallet (optional, keyword)
|
13
|
+
```
|
14
|
+
|
15
|
+
Usage:
|
16
|
+
```ruby
|
17
|
+
require 'blockchain'
|
18
|
+
|
19
|
+
wallet = Blockchain::create_wallet('1234password', '58ck39ajuiw', label: 'Test wallet')
|
20
|
+
```
|
data/docs/exchangerates.md
CHANGED
@@ -1,32 +1,32 @@
|
|
1
|
-
##Exchange rates functionality
|
2
|
-
|
3
|
-
All functions support an optional parameter called `api_code`. It won't be listed with every function description.
|
4
|
-
|
5
|
-
####`get_ticker`
|
6
|
-
Call the 'ticker' method and return a dictionary of `Currency` objects. Keys are currency symbols (str) and values are `Currency` objects.
|
7
|
-
|
8
|
-
|
9
|
-
Usage:
|
10
|
-
```ruby
|
11
|
-
require 'blockchain'
|
12
|
-
|
13
|
-
ticker = Blockchain::get_ticker()
|
14
|
-
#print the 15 min price for every currency
|
15
|
-
ticker.keys.each do |key|
|
16
|
-
puts ticker[key].p15min
|
17
|
-
end
|
18
|
-
```
|
19
|
-
|
20
|
-
####`to_btc`
|
21
|
-
Call the 'tobtc' method and convert x value in the provided currency to BTC. Returns a `float`.
|
22
|
-
|
23
|
-
Params:
|
24
|
-
```
|
25
|
-
ccy : str - currency code
|
26
|
-
value : float
|
27
|
-
```
|
28
|
-
|
29
|
-
Usage:
|
30
|
-
```ruby
|
31
|
-
btc_amount = Blockchain::to_btc('USD', 4342.11)
|
1
|
+
##Exchange rates functionality
|
2
|
+
|
3
|
+
All functions support an optional parameter called `api_code`. It won't be listed with every function description.
|
4
|
+
|
5
|
+
####`get_ticker`
|
6
|
+
Call the 'ticker' method and return a dictionary of `Currency` objects. Keys are currency symbols (str) and values are `Currency` objects.
|
7
|
+
|
8
|
+
|
9
|
+
Usage:
|
10
|
+
```ruby
|
11
|
+
require 'blockchain'
|
12
|
+
|
13
|
+
ticker = Blockchain::get_ticker()
|
14
|
+
#print the 15 min price for every currency
|
15
|
+
ticker.keys.each do |key|
|
16
|
+
puts ticker[key].p15min
|
17
|
+
end
|
18
|
+
```
|
19
|
+
|
20
|
+
####`to_btc`
|
21
|
+
Call the 'tobtc' method and convert x value in the provided currency to BTC. Returns a `float`.
|
22
|
+
|
23
|
+
Params:
|
24
|
+
```
|
25
|
+
ccy : str - currency code
|
26
|
+
value : float
|
27
|
+
```
|
28
|
+
|
29
|
+
Usage:
|
30
|
+
```ruby
|
31
|
+
btc_amount = Blockchain::to_btc('USD', 4342.11)
|
32
32
|
```
|