txcatcher 0.1.72 → 0.1.73
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/VERSION +1 -1
- data/lib/txcatcher/bitcoin_rpc.rb +10 -2
- data/lib/txcatcher/server.rb +7 -1
- data/txcatcher.gemspec +2 -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: 483593f92c1e8b650fe1a3d2ec4ba03a0b49c5f1
|
4
|
+
data.tar.gz: 496f1a17eda64bfd6c3741847f970f55167c7d2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8717aeb9dbf47aec7b505864c815d1638f88e2a7e7281ca8bbc4eca727b120f77b9850d280907b1866089d13aa9d12710558e88f01d7e5931365869d1bfba2c
|
7
|
+
data.tar.gz: b4b5bd85583e4c8b8f4ee5a9f6c0f0c4c9fc3d7422e3fa116b5daf7ab73d69271c04e979053a73c2b4b506d846a46581a3c613a51aea62ed656dca00accbb71d
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.73
|
@@ -6,6 +6,7 @@ require 'uri'
|
|
6
6
|
require 'json'
|
7
7
|
|
8
8
|
class BitcoinRPC
|
9
|
+
|
9
10
|
def initialize(service_url)
|
10
11
|
@uri = URI.parse(service_url)
|
11
12
|
end
|
@@ -13,7 +14,7 @@ class BitcoinRPC
|
|
13
14
|
def method_missing(name, *args)
|
14
15
|
post_body = { 'method' => name, 'params' => args, 'id' => 'jsonrpc' }.to_json
|
15
16
|
resp = JSON.parse( http_post_request(post_body) )
|
16
|
-
raise JSONRPCError
|
17
|
+
raise JSONRPCError.new(resp['error'].merge({ "method" => name.to_s })) if resp['error']
|
17
18
|
resp['result']
|
18
19
|
end
|
19
20
|
|
@@ -26,5 +27,12 @@ class BitcoinRPC
|
|
26
27
|
http.request(request).body
|
27
28
|
end
|
28
29
|
|
29
|
-
class JSONRPCError < RuntimeError
|
30
|
+
class JSONRPCError < RuntimeError
|
31
|
+
attr_accessor :data
|
32
|
+
def initialize(data)
|
33
|
+
super(data.to_s)
|
34
|
+
self.data = data
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
30
38
|
end
|
data/lib/txcatcher/server.rb
CHANGED
@@ -6,7 +6,13 @@ module TxCatcher
|
|
6
6
|
|
7
7
|
def response(env)
|
8
8
|
uri = env["REQUEST_URI"]
|
9
|
-
|
9
|
+
begin
|
10
|
+
return route_for(uri)
|
11
|
+
rescue BitcoinRPC::JSONRPCError => e
|
12
|
+
return [400, {}, { error: e.data }.to_json]
|
13
|
+
rescue Exception => e
|
14
|
+
return [500, {}, { error: e.to_s }.to_json]
|
15
|
+
end
|
10
16
|
end
|
11
17
|
|
12
18
|
def route_for(path)
|
data/txcatcher.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: txcatcher 0.1.
|
5
|
+
# stub: txcatcher 0.1.73 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "txcatcher"
|
9
|
-
s.version = "0.1.
|
9
|
+
s.version = "0.1.73"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: txcatcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.73
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roman Snitko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: goliath
|