middlecoin 0.0.0 → 0.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 +4 -4
- data/README.markdown +9 -2
- data/lib/middlecoin.rb +2 -1
- data/lib/middlecoin/cli/application.rb +13 -10
- data/lib/middlecoin/core.rb +1 -1
- data/lib/middlecoin/core/bitcoinaddress.rb +1 -0
- data/lib/middlecoin/core/middlecoinapi.rb +10 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aab9760328e43432963c743c2e4ac83022f423d2
|
4
|
+
data.tar.gz: be7f9504ca60609c0908b16eafd4b27dea301218
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21610ec1e049d4ec0f646ca0f99a8c077ef6660103898390f18ed6b1ebf6be6a774b78208d07cc7a1c03114c2ea2ed5f07e315b7eb249a0847ed143f26fdfca5
|
7
|
+
data.tar.gz: abdf345f1380586a0792be560c320cd152de9525eb775086b60ee5f83624cf8fbf5426b6dfc9d8e2b0b2e6257c255aa43327af9ad0c11fb6ba125bac8cf95bf9
|
data/README.markdown
CHANGED
@@ -8,14 +8,21 @@ A rubygem for interacting with middlecoin.com JSON web api.
|
|
8
8
|
|
9
9
|
# Usage
|
10
10
|
|
11
|
-
%
|
11
|
+
% middlecoin 1Cfd5G6rJmSBrNcTHxEgE4uYgH7XZJPY7Z
|
12
|
+
|
13
|
+
% middlecoin 1Cfd5G6rJmSBrNcTHxEgE4uYgH7XZJPY7Z 1Cfd5G6rJmSBrNcTHxEgE4uYgH7XZJPY7Z
|
12
14
|
|
13
15
|
# Contributing
|
14
|
-
|
16
|
+
|
17
|
+
If you would like to contribute bug fixes/etc to the project. The easiest way is to fork the project on [github](http://github.com/hammackj/middlecoin) and make the changes in your fork and the submit a pull request to the project.
|
15
18
|
|
16
19
|
# Issues
|
20
|
+
|
17
21
|
If you have any problems, bugs or feature requests please use the [github issue tracker](http://github.com/hammackj/middlecoin/issues).
|
18
22
|
|
23
|
+
# Donations / tips
|
24
|
+
Feel free to donate or tip to BTC: 1Cfd5G6rJmSBrNcTHxEgE4uYgH7XZJPY7Z
|
25
|
+
|
19
26
|
# Contact
|
20
27
|
You can reach me at jacob[.]hammack[@]hammackj[.]com.
|
21
28
|
|
data/lib/middlecoin.rb
CHANGED
@@ -21,13 +21,14 @@
|
|
21
21
|
|
22
22
|
module Middlecoin
|
23
23
|
APP_NAME = "middlecoin"
|
24
|
-
VERSION = "0.0.
|
24
|
+
VERSION = "0.0.1"
|
25
25
|
GITHUB = "http://github.com/hammackj/middlecoin"
|
26
26
|
EMAIL = "jacob.hammack@hammackj.com"
|
27
27
|
MIDDLECOIN_URL = "http://middlecoin.com"
|
28
28
|
|
29
29
|
class Error < StandardError; end
|
30
30
|
class InvalidBitcoinAddressError < Error; end
|
31
|
+
class MiddlecoinAPIError < Error; end
|
31
32
|
end
|
32
33
|
|
33
34
|
require 'json'
|
@@ -84,16 +84,19 @@ module Middlecoin
|
|
84
84
|
next
|
85
85
|
end
|
86
86
|
|
87
|
-
puts "
|
88
|
-
puts "
|
89
|
-
puts "
|
90
|
-
puts "
|
91
|
-
puts "
|
92
|
-
puts "
|
93
|
-
puts "
|
94
|
-
puts "
|
95
|
-
puts "
|
96
|
-
|
87
|
+
puts "Address: #{result[:address]}"
|
88
|
+
puts "Megahash/s: #{result[:megahashesPerSecond]}"
|
89
|
+
puts "Rejected MHs: #{result[:rejectedMegahashesPerSecond]}"
|
90
|
+
puts "Last hour shares: #{result[:lastHourShares]}"
|
91
|
+
puts "Last hour rejected shares: #{result[:lastHourRejectedShares]}"
|
92
|
+
puts "Immature Balance: #{result[:immatureBalance]}"
|
93
|
+
puts "Unexchanged Balance: #{result[:unexchangedBalance]}"
|
94
|
+
puts "Bitcoin Balance: #{result[:bitcoinBalance]}"
|
95
|
+
puts "Total paid out: #{result[:paidOut]}\n"
|
96
|
+
|
97
|
+
rescue Middlecoin::MiddlecoinAPIError => a
|
98
|
+
puts "[!] Error: #{i.message}"
|
99
|
+
break
|
97
100
|
rescue Middlecoin::InvalidBitcoinAddressError => i
|
98
101
|
puts "[!] Error: #{i.message}"
|
99
102
|
next
|
data/lib/middlecoin/core.rb
CHANGED
@@ -25,6 +25,7 @@ module Middlecoin
|
|
25
25
|
# Bitcoin Address
|
26
26
|
class BitcoinAddress
|
27
27
|
|
28
|
+
# Does some simple validation of a BTC address to make sure its sane
|
28
29
|
def self.validate address
|
29
30
|
if address[0] != "1" && address[0] != "3"
|
30
31
|
raise Middlecoin::InvalidBitcoinAddressError, "Bitcoin addresses must start with 1 or 3"
|
@@ -30,6 +30,7 @@ module Middlecoin
|
|
30
30
|
class MiddlecoinAPI
|
31
31
|
attr_accessor :report
|
32
32
|
|
33
|
+
# Simple function for following redirects, found it on stackexchange
|
33
34
|
def fetch(uri_str, limit = 10)
|
34
35
|
raise ArgumentError, 'HTTP redirect too deep' if limit == 0
|
35
36
|
|
@@ -50,11 +51,18 @@ module Middlecoin
|
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
54
|
+
# Downloads and caches the report JSON from middlecoin.com
|
53
55
|
def fetch_report
|
54
|
-
|
55
|
-
|
56
|
+
begin
|
57
|
+
report = fetch("#{Middlecoin::MIDDLECOIN_URL}/json")
|
58
|
+
@report = JSON.parse(report.body)["report"]
|
59
|
+
rescue => e
|
60
|
+
raise Middlecoin::MiddlecoinAPIError, "Unable to collect JSON report from middlecoin.com"
|
61
|
+
end
|
56
62
|
end
|
57
63
|
|
64
|
+
# Looks up a specific btc address in the JSON report from
|
65
|
+
# middlecoin.com
|
58
66
|
def lookup btc_address
|
59
67
|
@report.each do |address|
|
60
68
|
if address[0].eql?(btc_address)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middlecoin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacob Hammack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: middlecoin is a parser/status checker for middlecoin.com
|
14
14
|
email: jacob.hammack@hammackj.com
|