dogecoin-client 0.0.3
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 +7 -0
- data/.gitignore +5 -0
- data/.travis.yml +18 -0
- data/Gemfile +13 -0
- data/README.rdoc +71 -0
- data/Rakefile +8 -0
- data/dogecoin-client.gemspec +28 -0
- data/lib/dogecoin/api.rb +33 -0
- data/lib/dogecoin/client.rb +279 -0
- data/lib/dogecoin/dsl.rb +270 -0
- data/lib/dogecoin/errors.rb +4 -0
- data/lib/dogecoin/request.rb +35 -0
- data/lib/dogecoin/rpc.rb +51 -0
- data/lib/dogecoin/version.rb +12 -0
- data/lib/dogecoin-client.rb +1 -0
- data/lib/dogecoin.rb +19 -0
- data/spec/fixtures/backupwallet_without_params.json +8 -0
- data/spec/fixtures/build_fixture.rb +19 -0
- data/spec/fixtures/getbalance.json +8 -0
- data/spec/fixtures/getbestblockhash.json +8 -0
- data/spec/fixtures/getblock.json +8 -0
- data/spec/fixtures/getblockcount.json +8 -0
- data/spec/fixtures/getblockhash.json +8 -0
- data/spec/fixtures/getblocknumber.json +8 -0
- data/spec/fixtures/getconnectioncount.json +8 -0
- data/spec/fixtures/getdifficulty.json +8 -0
- data/spec/fixtures/getgenerate.json +8 -0
- data/spec/fixtures/gethashespersec.json +8 -0
- data/spec/fixtures/getinfo.json +8 -0
- data/spec/fixtures/getmininginfo.json +8 -0
- data/spec/fixtures/help.json +8 -0
- data/spec/fixtures/listreceivedbyaddress_with_minconf_0.json +8 -0
- data/spec/fixtures/listreceivedbyaddress_with_minconf_0_and_includeempty_true.json +7 -0
- data/spec/fixtures/listreceivedbyaddress_without_params.json +7 -0
- data/spec/fixtures/setaccount.json +8 -0
- data/spec/fixtures/signmessage_invalid_address.json +8 -0
- data/spec/fixtures/signmessage_success.json +8 -0
- data/spec/fixtures/verifymessage_failure.json +8 -0
- data/spec/fixtures/verifymessage_success.json +8 -0
- data/spec/lib/dogecoin/api_spec.rb +28 -0
- data/spec/lib/dogecoin/client_spec.rb +196 -0
- data/spec/lib/dogecoin/request_spec.rb +19 -0
- data/spec/lib/dogecoin_spec.rb +34 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/support/fixtures_helper.rb +5 -0
- data/spec/support/rpc_service_helper.rb +34 -0
- metadata +173 -0
data/lib/dogecoin/dsl.rb
ADDED
@@ -0,0 +1,270 @@
|
|
1
|
+
module Dogecoin::DSL
|
2
|
+
def dogecoin
|
3
|
+
if self.class.respond_to?(:dogecoin)
|
4
|
+
@client ||= Dogecoin::Client.new(self.class.dogecoin.user, self.class.dogecoin.pass, self.class.dogecoin.options)
|
5
|
+
else
|
6
|
+
@client ||= Dogecoin::Client.new(nil, nil)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def username=(value)
|
11
|
+
dogecoin.user = value
|
12
|
+
end
|
13
|
+
|
14
|
+
def password=(value)
|
15
|
+
dogecoin.pass = value
|
16
|
+
end
|
17
|
+
|
18
|
+
def host=(value)
|
19
|
+
dogecoin.host = value
|
20
|
+
end
|
21
|
+
|
22
|
+
def port=(value)
|
23
|
+
dogecoin.port = value
|
24
|
+
end
|
25
|
+
|
26
|
+
def ssl=(value)
|
27
|
+
dogecoin.ssl = value
|
28
|
+
end
|
29
|
+
|
30
|
+
def username(value = nil)
|
31
|
+
value ? dogecoin.user = value : dogecoin.user
|
32
|
+
end
|
33
|
+
|
34
|
+
def password(value = nil)
|
35
|
+
value ? dogecoin.pass = value : dogecoin.pass
|
36
|
+
end
|
37
|
+
|
38
|
+
def host(value = nil)
|
39
|
+
value ? dogecoin.host = value : dogecoin.host
|
40
|
+
end
|
41
|
+
|
42
|
+
def port(value = nil)
|
43
|
+
value ? dogecoin.port = value : dogecoin.port
|
44
|
+
end
|
45
|
+
|
46
|
+
def ssl(value = nil)
|
47
|
+
value.nil? ? dogecoin.ssl : dogecoin.ssl = value
|
48
|
+
end
|
49
|
+
|
50
|
+
def ssl?
|
51
|
+
dogecoin.ssl?
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
# Safely copies wallet.dat to destination, which can be a directory or a path with filename.
|
56
|
+
def backupwallet(destination)
|
57
|
+
dogecoin.backupwallet destination
|
58
|
+
end
|
59
|
+
|
60
|
+
# Returns the account associated with the given address.
|
61
|
+
def getaccount(dogecoinaddress)
|
62
|
+
dogecoin.getaccount dogecoinaddress
|
63
|
+
end
|
64
|
+
|
65
|
+
# Returns the current dogecoin address for receiving payments to this account.
|
66
|
+
def getaccountaddress(account)
|
67
|
+
dogecoin.getaccountaddress account
|
68
|
+
end
|
69
|
+
|
70
|
+
# Returns the list of addresses for the given account.
|
71
|
+
def getaddressesbyaccount(account)
|
72
|
+
dogecoin.getaddressesbyaccount account
|
73
|
+
end
|
74
|
+
|
75
|
+
# If +account+ is not specified, returns the server's total available balance.
|
76
|
+
# If +account+ is specified, returns the balance in the account.
|
77
|
+
def getbalance(account = nil, minconf = 1)
|
78
|
+
dogecoin.getbalance account, minconf
|
79
|
+
end
|
80
|
+
|
81
|
+
# Dumps the block existing at specified height.
|
82
|
+
# Note: this is not available in the official release
|
83
|
+
def getblockbycount(height)
|
84
|
+
dogecoin.getblockbycount height
|
85
|
+
end
|
86
|
+
|
87
|
+
# Dumps the block existing with specified hash.
|
88
|
+
def getblock(hash)
|
89
|
+
dogecoin.getblock hash
|
90
|
+
end
|
91
|
+
|
92
|
+
# Returns the number of blocks in the longest block chain.
|
93
|
+
def getblockcount
|
94
|
+
dogecoin.getblockcount
|
95
|
+
end
|
96
|
+
|
97
|
+
# Returns the block number of the latest block in the longest block chain.
|
98
|
+
def getblocknumber
|
99
|
+
dogecoin.getblocknumber
|
100
|
+
end
|
101
|
+
|
102
|
+
# Returns the number of connections to other nodes.
|
103
|
+
def getconnectioncount
|
104
|
+
dogecoin.getconnectioncount
|
105
|
+
end
|
106
|
+
|
107
|
+
# Returns the proof-of-work difficulty as a multiple of the minimum difficulty.
|
108
|
+
def getdifficulty
|
109
|
+
dogecoin.getdifficulty
|
110
|
+
end
|
111
|
+
|
112
|
+
# Returns true or false whether dogecoind is currently generating hashes
|
113
|
+
def getgenerate
|
114
|
+
dogecoin.getgenerate
|
115
|
+
end
|
116
|
+
|
117
|
+
# Returns a recent hashes per second performance measurement while generating.
|
118
|
+
def gethashespersec
|
119
|
+
dogecoin.gethashespersec
|
120
|
+
end
|
121
|
+
|
122
|
+
# Returns an object containing various state info.
|
123
|
+
def getinfo
|
124
|
+
dogecoin.getinfo
|
125
|
+
end
|
126
|
+
|
127
|
+
# Returns an object containing various mining info.
|
128
|
+
def getmininginfo
|
129
|
+
dogecoin.getmininginfo
|
130
|
+
end
|
131
|
+
|
132
|
+
# Returns a new dogecoin address for receiving payments. If +account+ is specified (recommended),
|
133
|
+
# it is added to the address book so payments received with the address will be credited to +account+.
|
134
|
+
def getnewaddress(account = nil)
|
135
|
+
dogecoin.getnewaddress account
|
136
|
+
end
|
137
|
+
|
138
|
+
# Returns the total amount received by addresses with +account+ in transactions
|
139
|
+
# with at least +minconf+ confirmations.
|
140
|
+
def getreceivedbyaccount(account, minconf = 1)
|
141
|
+
dogecoin.getreceivedbyaccount account, minconf
|
142
|
+
end
|
143
|
+
|
144
|
+
# Returns the total amount received by +dogecoinaddress+ in transactions with at least +minconf+ confirmations.
|
145
|
+
def getreceivedbyaddress(dogecoinaddress, minconf = 1)
|
146
|
+
dogecoin.getreceivedbyaddress dogecoinaddress, minconf
|
147
|
+
end
|
148
|
+
|
149
|
+
# Get detailed information about +txid+
|
150
|
+
def gettransaction(txid)
|
151
|
+
dogecoin.gettransaction txid
|
152
|
+
end
|
153
|
+
|
154
|
+
# If +data+ is not specified, returns formatted hash data to work on:
|
155
|
+
#
|
156
|
+
# :midstate => precomputed hash state after hashing the first half of the data
|
157
|
+
# :data => block data
|
158
|
+
# :hash1 => formatted hash buffer for second hash
|
159
|
+
# :target => little endian hash target
|
160
|
+
#
|
161
|
+
# If +data+ is specified, tries to solve the block and returns true if it was successful.
|
162
|
+
def getwork(data = nil)
|
163
|
+
dogecoin.getwork data
|
164
|
+
end
|
165
|
+
|
166
|
+
# List commands, or get help for a command.
|
167
|
+
def help(command = nil)
|
168
|
+
dogecoin.help command
|
169
|
+
end
|
170
|
+
|
171
|
+
# Returns Object that has account names as keys, account balances as values.
|
172
|
+
def listaccounts(minconf = 1)
|
173
|
+
dogecoin.listaccounts minconf
|
174
|
+
end
|
175
|
+
|
176
|
+
# Returns an array of objects containing:
|
177
|
+
#
|
178
|
+
# :account => the account of the receiving addresses
|
179
|
+
# :amount => total amount received by addresses with this account
|
180
|
+
# :confirmations => number of confirmations of the most recent transaction included
|
181
|
+
#
|
182
|
+
def listreceivedbyaccount(minconf = 1, includeempty = false)
|
183
|
+
dogecoin.listreceivedbyaccount minconf, includeempty
|
184
|
+
end
|
185
|
+
|
186
|
+
# Returns an array of objects containing:
|
187
|
+
#
|
188
|
+
# :address => receiving address
|
189
|
+
# :account => the account of the receiving address
|
190
|
+
# :amount => total amount received by the address
|
191
|
+
# :confirmations => number of confirmations of the most recent transaction included
|
192
|
+
#
|
193
|
+
# To get a list of accounts on the system, execute dogecoind listreceivedbyaddress 0 true
|
194
|
+
def listreceivedbyaddress(minconf = 1, includeempty = false)
|
195
|
+
dogecoin.listreceivedbyaddress minconf, includeempty
|
196
|
+
end
|
197
|
+
|
198
|
+
# Returns up to +count+ most recent transactions for account +account+.
|
199
|
+
def listtransactions(account, count = 10)
|
200
|
+
dogecoin.listtransactions account, count
|
201
|
+
end
|
202
|
+
|
203
|
+
# Move from one account in your wallet to another.
|
204
|
+
def move(fromaccount, toaccount, amount, minconf = 1, comment = nil)
|
205
|
+
dogecoin.move fromaccount, toaccount, amount, minconf, comment
|
206
|
+
end
|
207
|
+
|
208
|
+
# +amount+ is a real and is rounded to 8 decimal places. Returns the transaction ID if successful.
|
209
|
+
def sendfrom(fromaccount, todogecoinaddress, amount, minconf = 1, comment = nil, comment_to = nil)
|
210
|
+
dogecoin.sendfrom fromaccount, todogecoinaddress, amount, minconf, comment, comment_to
|
211
|
+
end
|
212
|
+
|
213
|
+
# +amount+ is a real and is rounded to 8 decimal places
|
214
|
+
def sendtoaddress(dogecoinaddress, amount, comment = nil, comment_to = nil)
|
215
|
+
dogecoin.sendtoaddress dogecoinaddress, amount, comment, comment_to
|
216
|
+
end
|
217
|
+
|
218
|
+
# Sets the account associated with the given address.
|
219
|
+
def setaccount(dogecoinaddress, account)
|
220
|
+
dogecoin.setaccount dogecoinaddress, account
|
221
|
+
end
|
222
|
+
|
223
|
+
# +generate+ is true or false to turn generation on or off.
|
224
|
+
# Generation is limited to +genproclimit+ processors, -1 is unlimited.
|
225
|
+
def setgenerate(generate, genproclimit = -1)
|
226
|
+
dogecoin.setgenerate generate, genproclimit
|
227
|
+
end
|
228
|
+
|
229
|
+
# Stop dogecoin server.
|
230
|
+
def stop
|
231
|
+
dogecoin.stop
|
232
|
+
end
|
233
|
+
|
234
|
+
# Return information about +dogecoinaddress+.
|
235
|
+
def validateaddress(dogecoinaddress)
|
236
|
+
dogecoin.validateaddress
|
237
|
+
end
|
238
|
+
|
239
|
+
alias account getaccount
|
240
|
+
alias account_address getaccountaddress
|
241
|
+
alias addresses_by_account getaddressesbyaccount
|
242
|
+
alias balance getbalance
|
243
|
+
alias block_by_count getblockbycount
|
244
|
+
alias block_count getblockcount
|
245
|
+
alias block_number getblocknumber
|
246
|
+
alias connection_count getconnectioncount
|
247
|
+
alias difficulty getdifficulty
|
248
|
+
alias generate? getgenerate
|
249
|
+
alias hashes_per_sec gethashespersec
|
250
|
+
alias info getinfo
|
251
|
+
alias mininginfo getmininginfo
|
252
|
+
alias new_address getnewaddress
|
253
|
+
alias received_by_account getreceivedbyaccount
|
254
|
+
alias received_by_address getreceivedbyaddress
|
255
|
+
alias transaction gettransaction
|
256
|
+
alias work getwork
|
257
|
+
alias get_work getwork
|
258
|
+
alias accounts listaccounts
|
259
|
+
alias list_received_by_account listreceivedbyaccount
|
260
|
+
alias list_received_by_address listreceivedbyaddress
|
261
|
+
alias transactions listtransactions
|
262
|
+
alias list_transactions listtransactions
|
263
|
+
alias send_from sendfrom
|
264
|
+
alias send_to_address sendtoaddress
|
265
|
+
alias account= setaccount
|
266
|
+
alias set_account setaccount
|
267
|
+
alias generate= setgenerate
|
268
|
+
alias set_generate setgenerate
|
269
|
+
alias validate_address validateaddress
|
270
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
class Dogecoin::Request
|
4
|
+
attr_reader :service_name, :params
|
5
|
+
|
6
|
+
def initialize(service_name, params = [])
|
7
|
+
@service_name = service_name
|
8
|
+
@params = params.dup
|
9
|
+
|
10
|
+
# dogecoin rejects null values even for optional params. Since
|
11
|
+
# even params following those may have default non-nil values,
|
12
|
+
# we'll assume the first non-nil value marks a set of optional
|
13
|
+
# params, and drop it and everything following it.
|
14
|
+
#
|
15
|
+
# ex:
|
16
|
+
# [nil] => []
|
17
|
+
# [1,nil,nil] => [1]
|
18
|
+
# [1,nil,nil,1] => [1]
|
19
|
+
if index = @params.index(nil)
|
20
|
+
@params = @params[0...index]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_hash
|
25
|
+
{
|
26
|
+
:method => service_name,
|
27
|
+
:params => params,
|
28
|
+
:id => "jsonrpc"
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_post_data
|
33
|
+
to_hash.to_json
|
34
|
+
end
|
35
|
+
end
|
data/lib/dogecoin/rpc.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'rest_client'
|
2
|
+
|
3
|
+
class Dogecoin::RPC
|
4
|
+
def initialize(options)
|
5
|
+
@user, @pass = options[:user], options[:pass]
|
6
|
+
@host, @port = options[:host], options[:port]
|
7
|
+
@ssl = options[:ssl]
|
8
|
+
end
|
9
|
+
|
10
|
+
def credentials
|
11
|
+
if @user
|
12
|
+
"#{@user}:#{@pass}"
|
13
|
+
else
|
14
|
+
nil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def service_url
|
19
|
+
url = @ssl ? "https://" : "http://"
|
20
|
+
url.concat "#{credentials}@" if c = credentials
|
21
|
+
url.concat "#{@host}:#{@port}"
|
22
|
+
url
|
23
|
+
end
|
24
|
+
|
25
|
+
def dispatch(request)
|
26
|
+
RestClient.post(service_url, request.to_post_data, content_type: :json) do |respdata, request, result|
|
27
|
+
response = JSON.parse(respdata)
|
28
|
+
raise Dogecoin::Errors::RPCError, response['error'] if response['error']
|
29
|
+
response['result']
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
def symbolize_keys(hash)
|
35
|
+
case hash
|
36
|
+
when Hash
|
37
|
+
hash.inject({}) do |result, (key, value)|
|
38
|
+
key = key.to_sym if key.kind_of?(String)
|
39
|
+
value = symbolize_keys(value)
|
40
|
+
result[key] = value
|
41
|
+
result
|
42
|
+
end
|
43
|
+
when Array
|
44
|
+
hash.collect do |ele|
|
45
|
+
symbolize_keys(ele)
|
46
|
+
end
|
47
|
+
else
|
48
|
+
hash
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require File.expand_path("dogecoin", File.dirname(__FILE__))
|
data/lib/dogecoin.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Dogecoin
|
2
|
+
autoload :Client, 'dogecoin/client'
|
3
|
+
autoload :API, 'dogecoin/api'
|
4
|
+
autoload :Request,'dogecoin/request'
|
5
|
+
autoload :RPC, 'dogecoin/rpc'
|
6
|
+
autoload :Errors, 'dogecoin/errors'
|
7
|
+
autoload :Version,'dogecoin/version'
|
8
|
+
autoload :VERSION,'dogecoin/version'
|
9
|
+
autoload :DSL, 'dogecoin/dsl'
|
10
|
+
|
11
|
+
def self.included(base)
|
12
|
+
base.send(:include, Dogecoin::DSL)
|
13
|
+
base.send(:extend, Dogecoin::DSL)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def Dogecoin(user, pass, options = {})
|
18
|
+
::Dogecoin::Client.new(user, pass, options)
|
19
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
HTTP/1.1 500 Internal Server Error
|
2
|
+
Date: Sun, 21 Aug 2011 22:53:05 +0000
|
3
|
+
Connection: close
|
4
|
+
Content-Length: 183
|
5
|
+
Content-Type: application/json
|
6
|
+
Server: dogecoin-json-rpc/0.3.24-beta
|
7
|
+
|
8
|
+
{"result":null,"error":{"code":-1,"message":"backupwallet <destination>\nSafely copies wallet.dat to destination, which can be a directory or a path with filename."},"id":"curltest"}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
service_name = ARGV[0]
|
7
|
+
file_name = (ARGV[1] || service_name).dup
|
8
|
+
params = ARGV[2..-1].collect { |y| y == '_nil' ? nil : YAML::load(y) }
|
9
|
+
|
10
|
+
file_name << ".json" unless file_name =~ /\.json$/
|
11
|
+
|
12
|
+
data = { 'jsonrpc' => '1.0', 'id' => 'curltest', 'method' => service_name, 'params' => params }
|
13
|
+
command = "curl --user LovleOdnu:NajOij6DriWokEjEinaw --data-binary '#{data.to_json}' -H 'content-type: text/plain;' http://127.0.0.1:22555/ -i"
|
14
|
+
|
15
|
+
puts command, nil
|
16
|
+
result = %x[#{command}]
|
17
|
+
puts result, nil
|
18
|
+
File.open(file_name, "w") { |f| f.print result }
|
19
|
+
|
@@ -0,0 +1,8 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Date: Mon, 10 Jun 2013 08:36:04 +0000
|
3
|
+
Connection: keep-alive
|
4
|
+
Content-Length: 1657
|
5
|
+
Content-Type: application/json
|
6
|
+
Server: dogecoin-json-rpc/v0.8.1-beta
|
7
|
+
|
8
|
+
{"result":"185b973f3db7102fe722b6499f22c4097b2529b520ce532911b6437ad791b15f","error":null,"id":"curltest"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Date: Mon, 10 Jun 2013 08:36:04 +0000
|
3
|
+
Connection: keep-alive
|
4
|
+
Content-Length: 1657
|
5
|
+
Content-Type: application/json
|
6
|
+
Server: dogecoin-json-rpc/v0.8.1-beta
|
7
|
+
|
8
|
+
{"result":{"hash":"0000000000000002e004985f39f929d001448623b312185bf5e4ab50e5a8e60a","confirmations":19,"size":5227,"height":240707,"version":2,"merkleroot":"18b914e2d6bd4c3118a936af75afbd230611edb6929a607302c0d591ef49b24e","tx":["cutforsimplicity","27f99033bdcea87b07f8eea4279d7ce24e479fcb49e9f54e9ffb3721e29838ed"],"time":1370842803,"nonce":3937756309,"bits":"1a011337","difficulty":15605632.68128593,"previousblockhash":"000000000000003fa76b2abdd3036d183d7e24cfb6b543781d59cdca289f6053","nextblockhash":"0000000000000087a1e962f618f757393930e58a745165033fc9d281b7bb568a"},"error":null,"id":"curltest"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Date: Mon, 10 Jun 2013 08:36:04 +0000
|
3
|
+
Connection: keep-alive
|
4
|
+
Content-Length: 1657
|
5
|
+
Content-Type: application/json
|
6
|
+
Server: dogecoin-json-rpc/v0.8.1-beta
|
7
|
+
|
8
|
+
{"result":"63a8ab7a46ff31236366de071e72513f8aa7abfee3d23923e3de4ac5c835e0c4","error":null,"id":"curltest"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Date: Sun, 21 Aug 2011 20:24:03 +0000
|
3
|
+
Connection: close
|
4
|
+
Content-Length: 281
|
5
|
+
Content-Type: application/json
|
6
|
+
Server: dogecoin-json-rpc/0.3.24-beta
|
7
|
+
|
8
|
+
{"result":{"version":32400,"balance":0.00100000,"blocks":141957,"connections":8,"proxy":"","generate":false,"genproclimit":-1,"difficulty":1805700.83619367,"hashespersec":0,"testnet":false,"keypoololdest":1313766189,"paytxfee":0.00000000,"errors":""},"error":null,"id":"curltest"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Date: Mon, 10 Jun 2013 07:49:23 +0000
|
3
|
+
Connection: keep-alive
|
4
|
+
Content-Length: 222
|
5
|
+
Content-Type: application/json
|
6
|
+
Server: dogecoin-json-rpc/v0.8.1-beta
|
7
|
+
|
8
|
+
{"result":{"blocks":237338,"currentblocksize":0,"currentblocktx":0,"difficulty":11187257.46136079,"errors":"","generate":false,"genproclimit":-1,"hashespersec":0,"pooledtx":0,"testnet":false},"error":null,"id":"curltest"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Date: Sun, 21 Aug 2011 23:20:10 +0000
|
3
|
+
Connection: close
|
4
|
+
Content-Length: 1078
|
5
|
+
Content-Type: application/json
|
6
|
+
Server: dogecoin-json-rpc/0.3.24-beta
|
7
|
+
|
8
|
+
{"result":"backupwallet <destination>\ngetaccount <dogecoinaddress>\ngetaccountaddress <account>\ngetaddressesbyaccount <account>\ngetbalance [account] [minconf=1]\ngetblockcount\ngetblocknumber\ngetconnectioncount\ngetdifficulty\ngetgenerate\ngethashespersec\ngetinfo\ngetnewaddress [account]\ngetreceivedbyaccount <account> [minconf=1]\ngetreceivedbyaddress <dogecoinaddress> [minconf=1]\ngettransaction <txid>\ngetwork [data]\nhelp [command]\nlistaccounts [minconf=1]\nlistreceivedbyaccount [minconf=1] [includeempty=false]\nlistreceivedbyaddress [minconf=1] [includeempty=false]\nlisttransactions [account] [count=10] [from=0]\nmove <fromaccount> <toaccount> <amount> [minconf=1] [comment]\nsendfrom <fromaccount> <todogecoinaddress> <amount> [minconf=1] [comment] [comment-to]\nsendmany <fromaccount> {address:amount,...} [minconf=1] [comment]\nsendtoaddress <dogecoinaddress> <amount> [comment] [comment-to]\nsetaccount <dogecoinaddress> <account>\nsetgenerate <generate> [genproclimit]\nsettxfee <amount>\nstop\nvalidateaddress <dogecoinaddress>","error":null,"id":"curltest"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Date: Sun, 21 Aug 2011 23:04:42 +0000
|
3
|
+
Connection: close
|
4
|
+
Content-Length: 155
|
5
|
+
Content-Type: application/json
|
6
|
+
Server: dogecoin-json-rpc/0.3.24-beta
|
7
|
+
|
8
|
+
{"result":[{"address":"1234","account":"","label":"","amount":0.00100000,"confirmations":180}],"error":null,"id":"curltest"}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Date: Sun, 21 Aug 2011 23:15:11 +0000
|
3
|
+
Connection: close
|
4
|
+
Content-Type: application/json
|
5
|
+
Server: dogecoin-json-rpc/0.3.24-beta
|
6
|
+
|
7
|
+
{"result":[{"address":"1234","account":"","label":"","amount":0.00100000,"confirmations":180}],"error":null,"id":"curltest"}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Date: Sun, 21 Aug 2011 22:54:36 +0000
|
3
|
+
Connection: close
|
4
|
+
Content-Type: application/json
|
5
|
+
Server: dogecoin-json-rpc/0.3.24-beta
|
6
|
+
|
7
|
+
{"result":[{"address":"1234","account":"","label":"","amount":0.00100000,"confirmations":180}],"error":null,"id":"curltest"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
HTTP/1.1 500 Internal Server Error
|
2
|
+
Date: Sun, 26 Aug 2012 23:58:59 +0000
|
3
|
+
Connection: close
|
4
|
+
Content-Length: 80
|
5
|
+
Content-Type: application/json
|
6
|
+
Server: dogecoin-json-rpc/v0.6.3-beta
|
7
|
+
|
8
|
+
{"result":null,"error":{"code":-3,"message":"Invalid address"},"id":"curltest"}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Dogecoin::API do
|
4
|
+
subject { Dogecoin::API.new(:user => $user, :pass => $pass) }
|
5
|
+
|
6
|
+
it "should have default host, port, ssl" do
|
7
|
+
subject.host.should == 'localhost'
|
8
|
+
subject.port.should == 22555
|
9
|
+
subject.ssl?.should be_false
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should accept host, port, ssl options" do
|
13
|
+
req = Dogecoin::API.new(:user => $user, :pass => $pass, :host => 'example.com', :port => 1234, :ssl => true)
|
14
|
+
req.host.should == 'example.com'
|
15
|
+
req.port.should == 1234
|
16
|
+
req.ssl?.should be_true
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should build an options hash" do
|
20
|
+
subject.to_hash.should == {
|
21
|
+
:user => $user,
|
22
|
+
:pass => $pass,
|
23
|
+
:host => 'localhost',
|
24
|
+
:port => 22555,
|
25
|
+
:ssl => false,
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|