cryptobank 0.1.0
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 +10 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +28 -0
- data/LICENSE.txt +21 -0
- data/README.md +67 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/cryptobank.gemspec +36 -0
- data/lib/cryptobank.rb +471 -0
- data/lib/cryptobank/error.rb +3 -0
- data/lib/cryptobank/version.rb +3 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e4fe9ccdd2658016176c4792badfffefff8034e2
|
4
|
+
data.tar.gz: 98948d1e6ba86e63f4e914b82b6186ff9a9aedcb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1abb2b7335db3416df90c26ae7679ec519417a5273b783ee226d7dbc1972d528ee4923856b7aab3189003eab6e3636c95f41a4ae70519bfdcd460c06623ad670
|
7
|
+
data.tar.gz: 39d396125dfa28cb98fd1fc355098db85d75a1bc2b7501add1de0ba6d56ace3f155620b35d2ab1cb166a4165e1c0efaf852c40aae416e45390c518850d7a98af
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at grace@gracefulco.de. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
cryptobank (0.1.0)
|
5
|
+
httparty
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
httparty (0.13.7)
|
11
|
+
json (~> 1.8)
|
12
|
+
multi_xml (>= 0.5.2)
|
13
|
+
json (1.8.6)
|
14
|
+
minitest (5.10.3)
|
15
|
+
multi_xml (0.6.0)
|
16
|
+
rake (10.5.0)
|
17
|
+
|
18
|
+
PLATFORMS
|
19
|
+
x64-mingw32
|
20
|
+
|
21
|
+
DEPENDENCIES
|
22
|
+
bundler (~> 1.16)
|
23
|
+
cryptobank!
|
24
|
+
minitest (~> 5.0)
|
25
|
+
rake (~> 10.0)
|
26
|
+
|
27
|
+
BUNDLED WITH
|
28
|
+
1.16.0
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Grace Christenbery
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# Cryptobank
|
2
|
+
|
3
|
+
Cryptobank provides Ruby wrappers for the Bitcoin API JSON-RPC.
|
4
|
+
|
5
|
+
This gem is still in development. Please feel free to contribute and make a pull request. As the gem is called 'cryptobank', it will evole into a more general toolbox for working with crypocurrencies.
|
6
|
+
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'cryptobank'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install cryptobank
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
```
|
27
|
+
class Bitcoind
|
28
|
+
extend Cryptobank
|
29
|
+
end
|
30
|
+
|
31
|
+
Bitcoind.configure do |config|
|
32
|
+
config.host = '127.0.0.1' # default: 'localhost'
|
33
|
+
config.port = 8332 # default: 8543
|
34
|
+
config.user = 'admin' # default: 'rpcuser'
|
35
|
+
config.password = 'swordfish' # default: 'rpcpassword'
|
36
|
+
end
|
37
|
+
|
38
|
+
Bitcoind.new_address #=> '14gnToPKhRKhRKXZHV4mJyu8N5EFAoFU6G'
|
39
|
+
|
40
|
+
account = "LolCat"
|
41
|
+
Bitcoind.balance(account) #=> 3.73094258
|
42
|
+
Bitcoind.get_account_addresses(account)
|
43
|
+
```
|
44
|
+
|
45
|
+
Please see lib/cryptobank/cryptobank.rb for the methods that are currently implemented.
|
46
|
+
|
47
|
+
## Development
|
48
|
+
|
49
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
50
|
+
|
51
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
52
|
+
|
53
|
+
## Contributing
|
54
|
+
|
55
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/Cryptobank. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
56
|
+
|
57
|
+
## License
|
58
|
+
|
59
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
60
|
+
|
61
|
+
## Code of Conduct
|
62
|
+
|
63
|
+
Everyone interacting in the Cryptobank project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/Cryptobank/blob/master/CODE_OF_CONDUCT.md).
|
64
|
+
|
65
|
+
## Credit
|
66
|
+
|
67
|
+
Credit goes to the gem 'Coinable' for inspiring this gem.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "cryptobank"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/cryptobank.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cryptobank/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'cryptobank'
|
8
|
+
spec.version = Cryptobank::VERSION
|
9
|
+
spec.authors = ['Grace Christenbery']
|
10
|
+
spec.email = ['grace@gracefulco.de']
|
11
|
+
spec.summary = 'A toolbox for working with cryptocurrencies. Cryptobank provides Ruby wrappers for the Bitcoin API JSON-RPC.'
|
12
|
+
spec.homepage = 'https://github.com/Grace/cryptobank'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
16
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
17
|
+
if spec.respond_to?(:metadata)
|
18
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
19
|
+
else
|
20
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
21
|
+
'public gem pushes.'
|
22
|
+
end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
25
|
+
f.match(%r{^(test|spec|features)/})
|
26
|
+
end
|
27
|
+
spec.bindir = 'exe'
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ['lib']
|
30
|
+
|
31
|
+
spec.add_runtime_dependency 'httparty'
|
32
|
+
|
33
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
34
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
35
|
+
spec.add_development_dependency 'minitest', '~> 5.0'
|
36
|
+
end
|
data/lib/cryptobank.rb
ADDED
@@ -0,0 +1,471 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'httparty'
|
3
|
+
require 'cryptobank/version'
|
4
|
+
require 'cryptobank/error'
|
5
|
+
|
6
|
+
module Cryptobank # Implements Bitcoin API JSON-RPC to communicate with bitcoind
|
7
|
+
|
8
|
+
HEADERS = {
|
9
|
+
'Content-Type' => 'application/json',
|
10
|
+
'Accept' => 'application/json'
|
11
|
+
}.freeze
|
12
|
+
|
13
|
+
attr_writer :host, :port, :user, :password
|
14
|
+
|
15
|
+
def host
|
16
|
+
@host || 'localhost'
|
17
|
+
end
|
18
|
+
|
19
|
+
def port
|
20
|
+
@port || 8332
|
21
|
+
end
|
22
|
+
|
23
|
+
def user
|
24
|
+
@user || 'rpcuser'
|
25
|
+
end
|
26
|
+
|
27
|
+
def password
|
28
|
+
@password || 'rpcpassword'
|
29
|
+
end
|
30
|
+
|
31
|
+
def configure
|
32
|
+
yield self
|
33
|
+
end
|
34
|
+
|
35
|
+
# addmultisigaddress
|
36
|
+
def add_multisig_address(minimum_number_of_sigs, key_or_addresses, account = '')
|
37
|
+
payload = {
|
38
|
+
method: 'addmultisigaddress'
|
39
|
+
}
|
40
|
+
payload[:params] = [minimum_number_of_sigs.to_int, key_or_addresses.to_string, account.to_string]
|
41
|
+
request(payload)
|
42
|
+
end
|
43
|
+
|
44
|
+
# addnode
|
45
|
+
def add_node
|
46
|
+
raise NotImplementedError
|
47
|
+
end
|
48
|
+
|
49
|
+
# backupwallet
|
50
|
+
def backup_wallet
|
51
|
+
raise NotImplementedError
|
52
|
+
end
|
53
|
+
|
54
|
+
# createmultisig
|
55
|
+
def create_multisig
|
56
|
+
raise NotImplementedError
|
57
|
+
end
|
58
|
+
|
59
|
+
# createrawtransaction
|
60
|
+
def create_raw_transaction
|
61
|
+
raise NotImplementedError
|
62
|
+
end
|
63
|
+
|
64
|
+
# decoderawtransaction
|
65
|
+
def decode_raw_transaction
|
66
|
+
raise NotImplementedError
|
67
|
+
end
|
68
|
+
|
69
|
+
# dumpprivkey
|
70
|
+
def dump_priv_key
|
71
|
+
raise NotImplementedError
|
72
|
+
end
|
73
|
+
|
74
|
+
# encryptwallet
|
75
|
+
def encrypt_wallet
|
76
|
+
raise NotImplementedError
|
77
|
+
end
|
78
|
+
|
79
|
+
# getaccount
|
80
|
+
# A P2PKH or P2SH Bitcoin address belonging either to a specific account or the default account (“”)
|
81
|
+
# returns a base58 string
|
82
|
+
def account(bitcoin_address)
|
83
|
+
payload = {
|
84
|
+
method: 'getaccount'
|
85
|
+
}
|
86
|
+
payload[:params] = [bitcoin_address.to_string]
|
87
|
+
request(payload)
|
88
|
+
end
|
89
|
+
|
90
|
+
# getaddednodeinfo
|
91
|
+
def added_node_info
|
92
|
+
raise NotImplementedError
|
93
|
+
end
|
94
|
+
|
95
|
+
# getbalance
|
96
|
+
# There are additional parameters on the RPC docs to be implemented https://bitcoin.org/en/developer-reference#getbalance
|
97
|
+
def balance(account = nil)
|
98
|
+
payload = {
|
99
|
+
method: 'getbalance'
|
100
|
+
}
|
101
|
+
payload[:params] = [account] unless account.nil?
|
102
|
+
request(payload)
|
103
|
+
end
|
104
|
+
|
105
|
+
# getbestblockhash
|
106
|
+
def best_block_hash
|
107
|
+
raise NotImplementedError
|
108
|
+
end
|
109
|
+
|
110
|
+
# getblock
|
111
|
+
def block(verbosity = nil)
|
112
|
+
payload = {
|
113
|
+
method: 'getblock'
|
114
|
+
}
|
115
|
+
payload[:params] = [template_request] unless verbosity.nil?
|
116
|
+
request(payload)
|
117
|
+
end
|
118
|
+
|
119
|
+
# getblockhash
|
120
|
+
def block_hash
|
121
|
+
payload = {
|
122
|
+
method: 'getblockhash'
|
123
|
+
}
|
124
|
+
request(payload)
|
125
|
+
end
|
126
|
+
|
127
|
+
# getblockcount
|
128
|
+
def block_count
|
129
|
+
payload = {
|
130
|
+
method: 'getblockcount'
|
131
|
+
}
|
132
|
+
request(payload)
|
133
|
+
end
|
134
|
+
|
135
|
+
# getblocktemplate
|
136
|
+
def block_template(template_request = nil)
|
137
|
+
payload = {
|
138
|
+
method: 'getblocktemplate'
|
139
|
+
}
|
140
|
+
payload[:params] = [template_request] unless template_request.nil?
|
141
|
+
request(payload)
|
142
|
+
end
|
143
|
+
|
144
|
+
# getconnectioncount
|
145
|
+
def connection_count
|
146
|
+
payload = {
|
147
|
+
method: 'getconnectioncount'
|
148
|
+
}
|
149
|
+
request(payload)
|
150
|
+
end
|
151
|
+
|
152
|
+
# getdifficulty
|
153
|
+
def difficulty
|
154
|
+
payload = {
|
155
|
+
method: 'getdifficulty'
|
156
|
+
}
|
157
|
+
request(payload)
|
158
|
+
end
|
159
|
+
|
160
|
+
# getgenerate
|
161
|
+
def generate
|
162
|
+
payload = {
|
163
|
+
method: 'getgenerate'
|
164
|
+
}
|
165
|
+
request(payload)
|
166
|
+
end
|
167
|
+
|
168
|
+
def get_account_addresses(account)
|
169
|
+
payload = {
|
170
|
+
method: 'getaddressesbyaccount'
|
171
|
+
}
|
172
|
+
payload[:params] = [account]
|
173
|
+
request(payload)
|
174
|
+
end
|
175
|
+
|
176
|
+
# gethashespersec
|
177
|
+
def hashes_per_sec
|
178
|
+
raise NotImplementedError
|
179
|
+
end
|
180
|
+
|
181
|
+
# getinfo
|
182
|
+
def info
|
183
|
+
payload = {
|
184
|
+
method: 'getwalletinfo'
|
185
|
+
}
|
186
|
+
request(payload)
|
187
|
+
end
|
188
|
+
|
189
|
+
# getmempoolinfo
|
190
|
+
def memory_pool_info
|
191
|
+
payload = {
|
192
|
+
method: 'getmempoolinfo'
|
193
|
+
}
|
194
|
+
request(payload)
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
# getmininginfo
|
199
|
+
def mining_info
|
200
|
+
payload = {
|
201
|
+
method: 'getmininginfo'
|
202
|
+
}
|
203
|
+
request(payload)
|
204
|
+
end
|
205
|
+
|
206
|
+
# getnewaddress
|
207
|
+
def new_address(account = nil)
|
208
|
+
payload = {
|
209
|
+
method: 'getnewaddress'
|
210
|
+
}
|
211
|
+
payload[:params] = [account] unless account.nil?
|
212
|
+
request(payload)
|
213
|
+
end
|
214
|
+
|
215
|
+
# getpeerinfo
|
216
|
+
def peer_info
|
217
|
+
payload = {
|
218
|
+
method: 'getpeerinfo'
|
219
|
+
}
|
220
|
+
request(payload)
|
221
|
+
end
|
222
|
+
|
223
|
+
# getrawchangeaddress
|
224
|
+
def raw_change_address
|
225
|
+
payload = {
|
226
|
+
method: 'getrawchangeaddress'
|
227
|
+
}
|
228
|
+
request(payload)
|
229
|
+
end
|
230
|
+
|
231
|
+
# getrawmempool
|
232
|
+
def raw_mem_pool(verbose_format = false)
|
233
|
+
payload = {
|
234
|
+
method: 'getrawmempool'
|
235
|
+
}
|
236
|
+
payload[:params] = [1] if verbose_format?
|
237
|
+
request(payload)
|
238
|
+
end
|
239
|
+
|
240
|
+
# getrawtransaction
|
241
|
+
# The TXID of the transaction to get, encoded as hex in RPC byte order
|
242
|
+
def raw_transaction(txid)
|
243
|
+
payload = {
|
244
|
+
method: 'getrawtransaction'
|
245
|
+
}
|
246
|
+
payload[:params] = [txid]
|
247
|
+
request(payload)
|
248
|
+
end
|
249
|
+
|
250
|
+
# getreceivedbyaddress
|
251
|
+
'''The getreceivedbyaddress RPC returns the total amount received by the specified address in transactions with the specified number of confirmations. It does not count coinbase transactions.'''
|
252
|
+
def received_by_address(address)
|
253
|
+
payload = {
|
254
|
+
method: 'getreceivedbyaddress'
|
255
|
+
}
|
256
|
+
payload[:params] = [address]
|
257
|
+
request(payload)
|
258
|
+
end
|
259
|
+
|
260
|
+
# gettransaction
|
261
|
+
def transaction(txid)
|
262
|
+
payload = {
|
263
|
+
method: 'gettransaction',
|
264
|
+
params: [txid]
|
265
|
+
}
|
266
|
+
|
267
|
+
request(payload)
|
268
|
+
end
|
269
|
+
|
270
|
+
# gettxout
|
271
|
+
def tx_out
|
272
|
+
raise NotImplementedError
|
273
|
+
end
|
274
|
+
|
275
|
+
# gettxoutsetinfo
|
276
|
+
def tx_out_set_info
|
277
|
+
raise NotImplementedError
|
278
|
+
end
|
279
|
+
|
280
|
+
# getwork
|
281
|
+
def work
|
282
|
+
raise NotImplementedError
|
283
|
+
end
|
284
|
+
|
285
|
+
# help
|
286
|
+
def help
|
287
|
+
raise NotImplementedError
|
288
|
+
end
|
289
|
+
|
290
|
+
# importprivkey
|
291
|
+
def import_priv_key
|
292
|
+
raise NotImplementedError
|
293
|
+
end
|
294
|
+
|
295
|
+
# keypoolrefill
|
296
|
+
def keypool_refill
|
297
|
+
raise NotImplementedError
|
298
|
+
end
|
299
|
+
|
300
|
+
# listaccounts
|
301
|
+
def list_accounts(minconf = nil)
|
302
|
+
payload = {
|
303
|
+
method: 'listaccounts'
|
304
|
+
}
|
305
|
+
|
306
|
+
payload[:params] = [minconf] unless minconf.nil?
|
307
|
+
|
308
|
+
request(payload)
|
309
|
+
end
|
310
|
+
|
311
|
+
# listaddressgroupings
|
312
|
+
def list_address_groupings
|
313
|
+
raise NotImplementedError
|
314
|
+
end
|
315
|
+
|
316
|
+
# listreceivedbyaccount
|
317
|
+
def list_received_by_account
|
318
|
+
raise NotImplementedError
|
319
|
+
end
|
320
|
+
|
321
|
+
# listreceivedbyaddress
|
322
|
+
def list_received_by_address
|
323
|
+
raise NotImplementedError
|
324
|
+
end
|
325
|
+
|
326
|
+
# listsinceblock
|
327
|
+
def list_since_block
|
328
|
+
raise NotImplementedError
|
329
|
+
end
|
330
|
+
|
331
|
+
# listtransactions
|
332
|
+
def list_transactions(account = nil, count = nil, from = nil)
|
333
|
+
payload = {
|
334
|
+
method: 'listtransactions'
|
335
|
+
}
|
336
|
+
unless account.nil?
|
337
|
+
payload[:params] = [account]
|
338
|
+
payload[:params] << count unless count.nil?
|
339
|
+
payload[:params] << from unless from.nil?
|
340
|
+
end
|
341
|
+
request(payload)
|
342
|
+
end
|
343
|
+
|
344
|
+
# listunspent
|
345
|
+
def list_unspent
|
346
|
+
raise NotImplementedError
|
347
|
+
end
|
348
|
+
|
349
|
+
# listlockunspent
|
350
|
+
def list_lock_unspent
|
351
|
+
raise NotImplementedError
|
352
|
+
end
|
353
|
+
|
354
|
+
# lockunspent
|
355
|
+
def lock_unspent
|
356
|
+
raise NotImplementedError
|
357
|
+
end
|
358
|
+
|
359
|
+
# move
|
360
|
+
def move
|
361
|
+
raise NotImplementedError
|
362
|
+
end
|
363
|
+
|
364
|
+
# sendfrom
|
365
|
+
def send_from
|
366
|
+
raise NotImplementedError
|
367
|
+
end
|
368
|
+
|
369
|
+
# sendmany
|
370
|
+
def send_many
|
371
|
+
raise NotImplementedError
|
372
|
+
end
|
373
|
+
|
374
|
+
# sendrawtransaction
|
375
|
+
def send_raw_transaction
|
376
|
+
raise NotImplementedError
|
377
|
+
end
|
378
|
+
|
379
|
+
# sendtoaddress
|
380
|
+
def send_to_address(address, amount, comment = nil, comment_to = nil)
|
381
|
+
payload = {
|
382
|
+
method: 'sendtoaddress',
|
383
|
+
params: [address, amount]
|
384
|
+
}
|
385
|
+
payload[:params] << comment unless comment.nil?
|
386
|
+
payload[:params] << comment_to unless comment_to.nil?
|
387
|
+
request(payload)
|
388
|
+
end
|
389
|
+
|
390
|
+
# setaccount
|
391
|
+
def account=(_)
|
392
|
+
raise NotImplementedError
|
393
|
+
end
|
394
|
+
|
395
|
+
# setgenerate
|
396
|
+
def generate=(_)
|
397
|
+
raise NotImplementedError
|
398
|
+
end
|
399
|
+
|
400
|
+
# settxfee
|
401
|
+
def tx_fee=(_)
|
402
|
+
raise NotImplementedError
|
403
|
+
end
|
404
|
+
|
405
|
+
# signmessage
|
406
|
+
def sign_message
|
407
|
+
raise NotImplementedError
|
408
|
+
end
|
409
|
+
|
410
|
+
# signrawtransaction
|
411
|
+
def sign_raw_transaction
|
412
|
+
raise NotImplementedError
|
413
|
+
end
|
414
|
+
|
415
|
+
# stop
|
416
|
+
def stop
|
417
|
+
raise NotImplementedError
|
418
|
+
end
|
419
|
+
|
420
|
+
# submitblock
|
421
|
+
def submit_block
|
422
|
+
raise NotImplementedError
|
423
|
+
end
|
424
|
+
|
425
|
+
# validateaddress
|
426
|
+
def validate_address(address)
|
427
|
+
payload = {
|
428
|
+
method: 'validateaddress',
|
429
|
+
params: [address]
|
430
|
+
}
|
431
|
+
|
432
|
+
request(payload)
|
433
|
+
end
|
434
|
+
|
435
|
+
# verifymessage
|
436
|
+
def verify_message
|
437
|
+
raise NotImplementedError
|
438
|
+
end
|
439
|
+
|
440
|
+
# walletlock
|
441
|
+
def wallet_lock
|
442
|
+
raise NotImplementedError
|
443
|
+
end
|
444
|
+
|
445
|
+
# walletpassphrase
|
446
|
+
def wallet_passphrase
|
447
|
+
raise NotImplementedError
|
448
|
+
end
|
449
|
+
|
450
|
+
# walletpassphrasechange
|
451
|
+
def wallet_passphrase_change
|
452
|
+
raise NotImplementedError
|
453
|
+
end
|
454
|
+
|
455
|
+
def valid_address?(address)
|
456
|
+
validate_address(address)['isvalid']
|
457
|
+
end
|
458
|
+
|
459
|
+
private
|
460
|
+
|
461
|
+
def request(payload)
|
462
|
+
response = HTTParty.post(url, body: payload.to_json, headers: HEADERS)
|
463
|
+
raise Error, response.message unless response.code == 200
|
464
|
+
JSON.parse(response.body)['result']
|
465
|
+
end
|
466
|
+
|
467
|
+
def url
|
468
|
+
"http://#{user}:#{password}@#{host}:#{port}"
|
469
|
+
end
|
470
|
+
# end
|
471
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cryptobank
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Grace Christenbery
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-11-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.16'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.16'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- grace@gracefulco.de
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
|
+
- CODE_OF_CONDUCT.md
|
79
|
+
- Gemfile
|
80
|
+
- Gemfile.lock
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- bin/console
|
85
|
+
- bin/setup
|
86
|
+
- cryptobank.gemspec
|
87
|
+
- lib/cryptobank.rb
|
88
|
+
- lib/cryptobank/error.rb
|
89
|
+
- lib/cryptobank/version.rb
|
90
|
+
homepage: https://github.com/Grace/cryptobank
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata:
|
94
|
+
allowed_push_host: https://rubygems.org
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.6.13
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: A toolbox for working with cryptocurrencies. Cryptobank provides Ruby wrappers
|
115
|
+
for the Bitcoin API JSON-RPC.
|
116
|
+
test_files: []
|