sibit 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 +7 -0
- data/.0pdd.yml +9 -0
- data/.gitattributes +7 -0
- data/.gitignore +7 -0
- data/.pdd +7 -0
- data/.rubocop.yml +25 -0
- data/.rultor.yml +32 -0
- data/.simplecov +38 -0
- data/.travis.yml +13 -0
- data/Gemfile +25 -0
- data/LICENSE.txt +21 -0
- data/README.md +105 -0
- data/Rakefile +77 -0
- data/appveyor.yml +21 -0
- data/bin/sibit +71 -0
- data/cucumber.yml +3 -0
- data/features/cli.feature +19 -0
- data/features/gem_package.feature +24 -0
- data/features/step_definitions/steps.rb +94 -0
- data/features/support/env.rb +24 -0
- data/lib/sibit/version.rb +30 -0
- data/lib/sibit.rb +62 -0
- data/sibit.gemspec +64 -0
- data/test/test__helper.rb +33 -0
- data/test/test_sibit.rb +51 -0
- metadata +248 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 85eea5a6116c95e319c46e4bb3bcaa9a5578d0d0e96395e4a9395cc4b7546e7b
|
|
4
|
+
data.tar.gz: 0de27c41f5e7ea62ef116f06504839e3bfa45da2cc01ac9c87352853e95fb41a
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: e656fa1439cc031cf41c69e8ec14fcb929a92bbb839657ee78ef2d52f0b715f9dd4939ee4a0567b21aaa7c8dd6da5d91c0bd2fd148847de37db8e79689b873d9
|
|
7
|
+
data.tar.gz: d0cdb4e5c6a3b4bf1cfa5c08aba92d77cc1920aaf45033ca6845d57e7b2c26782b9a0587794db11a7bf615cce51328bcb2327d29b20765c844346d59d63ebd15
|
data/.0pdd.yml
ADDED
data/.gitattributes
ADDED
data/.gitignore
ADDED
data/.pdd
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
Exclude:
|
|
3
|
+
- 'bin/**/*'
|
|
4
|
+
- 'assets/**/*'
|
|
5
|
+
DisplayCopNames: true
|
|
6
|
+
TargetRubyVersion: 2.3
|
|
7
|
+
|
|
8
|
+
Layout/EndOfLine:
|
|
9
|
+
EnforcedStyle: lf
|
|
10
|
+
Metrics/CyclomaticComplexity:
|
|
11
|
+
Max: 20
|
|
12
|
+
Metrics/MethodLength:
|
|
13
|
+
Enabled: false
|
|
14
|
+
Layout/MultilineMethodCallIndentation:
|
|
15
|
+
Enabled: false
|
|
16
|
+
Metrics/AbcSize:
|
|
17
|
+
Enabled: false
|
|
18
|
+
Metrics/BlockLength:
|
|
19
|
+
Max: 100
|
|
20
|
+
Metrics/PerceivedComplexity:
|
|
21
|
+
Max: 20
|
|
22
|
+
Style/MultilineTernaryOperator:
|
|
23
|
+
Enabled: false
|
|
24
|
+
Layout/EmptyLineAfterGuardClause:
|
|
25
|
+
Enabled: false
|
data/.rultor.yml
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
assets:
|
|
2
|
+
rubygems.yml: zerocracy/home#assets/rubygems.yml
|
|
3
|
+
s3cfg: zerocracy/home#assets/s3cfg
|
|
4
|
+
install: |
|
|
5
|
+
export GEM_HOME=~/.ruby
|
|
6
|
+
export GEM_PATH=$GEM_HOME:$GEM_PATH
|
|
7
|
+
sudo apt-get -y update
|
|
8
|
+
sudo gem install pdd
|
|
9
|
+
release:
|
|
10
|
+
script: |-
|
|
11
|
+
bundle install
|
|
12
|
+
rake
|
|
13
|
+
rm -rf *.gem
|
|
14
|
+
sed -i "s/1\.0\.snapshot/${tag}/g" lib/sibit/version.rb
|
|
15
|
+
git add lib/sibit/version.rb
|
|
16
|
+
git commit -m "version set to ${tag}"
|
|
17
|
+
gem build sibit.gemspec
|
|
18
|
+
chmod 0600 ../rubygems.yml
|
|
19
|
+
gem push *.gem --config-file ../rubygems.yml
|
|
20
|
+
commanders:
|
|
21
|
+
- yegor256
|
|
22
|
+
architect:
|
|
23
|
+
- yegor256
|
|
24
|
+
merge:
|
|
25
|
+
script: |-
|
|
26
|
+
bundle install
|
|
27
|
+
rake
|
|
28
|
+
pdd
|
|
29
|
+
deploy:
|
|
30
|
+
script: |-
|
|
31
|
+
echo "There is nothing to deploy"
|
|
32
|
+
exit -1
|
data/.simplecov
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Copyright (c) 2019 Yegor Bugayenko
|
|
2
|
+
#
|
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
# furnished to do so, subject to the following conditions:
|
|
9
|
+
#
|
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
# copies or substantial portions of the Software.
|
|
12
|
+
#
|
|
13
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
# SOFTWARE.
|
|
20
|
+
|
|
21
|
+
if Gem.win_platform? then
|
|
22
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
|
23
|
+
SimpleCov::Formatter::HTMLFormatter
|
|
24
|
+
]
|
|
25
|
+
SimpleCov.start do
|
|
26
|
+
add_filter "/test/"
|
|
27
|
+
add_filter "/features/"
|
|
28
|
+
end
|
|
29
|
+
else
|
|
30
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
|
|
31
|
+
[SimpleCov::Formatter::HTMLFormatter]
|
|
32
|
+
)
|
|
33
|
+
SimpleCov.start do
|
|
34
|
+
add_filter "/test/"
|
|
35
|
+
add_filter "/features/"
|
|
36
|
+
minimum_coverage 60
|
|
37
|
+
end
|
|
38
|
+
end
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2019 Yegor Bugayenko
|
|
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 all
|
|
13
|
+
# 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 THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
|
|
23
|
+
source 'https://rubygems.org'
|
|
24
|
+
ruby '~>2.3'
|
|
25
|
+
gemspec
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
(The MIT License)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Yegor Bugayenko
|
|
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 all
|
|
13
|
+
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 THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
[](http://www.elegantobjects.org)
|
|
2
|
+
[](https://www.0crat.com/p/C3RFVLU72)
|
|
3
|
+
[](http://www.rultor.com/p/yegor256/sibit)
|
|
4
|
+
[](https://www.jetbrains.com/ruby/)
|
|
5
|
+
|
|
6
|
+
[](https://travis-ci.org/yegor256/sibit)
|
|
7
|
+
[](https://ci.appveyor.com/project/yegor256/sibit)
|
|
8
|
+
[](http://www.0pdd.com/p?name=yegor256/sibit)
|
|
9
|
+
[](http://badge.fury.io/rb/sibit)
|
|
10
|
+
[](https://codeclimate.com/github/yegor256/sibit/maintainability)
|
|
11
|
+
[](https://codecov.io/github/yegor256/sibit?branch=master)
|
|
12
|
+
|
|
13
|
+
To understand how Bitcoin protocol works, I recommend you watching
|
|
14
|
+
this [short video](https://www.youtube.com/watch?v=IV9pRBq5A4g).
|
|
15
|
+
|
|
16
|
+
This is a simple Bitcoin client, to use from the command line
|
|
17
|
+
or from your Ruby app. You don't need to run any Bitcoin software,
|
|
18
|
+
no need to install anything, and so on. All you need is just a command line
|
|
19
|
+
and [Ruby](https://www.ruby-lang.org/en/) 2.3+.
|
|
20
|
+
|
|
21
|
+
This is Ruby gem, install it first:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
$ gem install sibit
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Run it and read its output:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
$ sibit --help
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Then, you generate a [private key](https://en.bitcoin.it/wiki/Private_key):
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
$ sibit generate
|
|
37
|
+
E9873D79C6D87FC233AA332626A3A3FE
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Next, you create a new [address](https://en.bitcoin.it/wiki/Address),
|
|
41
|
+
using your private key:
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
$ sibit create E9873D79C6D87FC233AA332626A3A3FE
|
|
45
|
+
1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
To check the balance at the address (the result is in
|
|
49
|
+
[satoshi](https://en.bitcoin.it/wiki/Satoshi_%28unit%29)):
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
$ sibit balance 1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj
|
|
53
|
+
80988977
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
To send a payment from a few addresses to a new address:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
$ sibit pay KEY AMOUNT FEE FROM1,FROM2,... TO
|
|
60
|
+
1CC3X2gu58d6wXUWjslPuzN9JAfTUWu4Kg
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Here,
|
|
64
|
+
`KEY` is the private key,
|
|
65
|
+
`AMOUNT` is the amount of [satoshi](https://en.bitcoin.it/wiki/Satoshi_%28unit%29) you are sending,
|
|
66
|
+
`FEE` is the [miner fee](https://en.bitcoin.it/wiki/Miner_fees) you are ready to spend to make this transaction delivered
|
|
67
|
+
(you can say `S`, `M`, `L`, or `XL` if you want it to be calculated automatically),
|
|
68
|
+
`FROM1,FROM2,...` is a comma-separated list of addresses you are sending your coins from,
|
|
69
|
+
`TO` is the address you are sending to.
|
|
70
|
+
The address returned will contain the residual coins after the transaction is made.
|
|
71
|
+
|
|
72
|
+
All operations are performed through the
|
|
73
|
+
[Blockchain API](https://www.blockchain.com/api/blockchain_api).
|
|
74
|
+
Transactions are pushed to the Bitcoin network via
|
|
75
|
+
[this relay](https://www.blockchain.com/btc/pushtx).
|
|
76
|
+
|
|
77
|
+
## Ruby SDK
|
|
78
|
+
|
|
79
|
+
You can do the same from your Ruby app:
|
|
80
|
+
|
|
81
|
+
```ruby
|
|
82
|
+
require 'sibit'
|
|
83
|
+
sibit = Sibit.new
|
|
84
|
+
pkey = sibit.generate
|
|
85
|
+
address = sibit.create(pkey)
|
|
86
|
+
balance = sibit.balance(address)
|
|
87
|
+
out = sibit.pay(pkey, 10_000_000, 'XL', address, target)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Should work.
|
|
91
|
+
|
|
92
|
+
## How to contribute
|
|
93
|
+
|
|
94
|
+
Read [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
|
|
95
|
+
Make sure your build is green before you contribute
|
|
96
|
+
your pull request. You will need to have [Ruby](https://www.ruby-lang.org/en/) 2.3+ and
|
|
97
|
+
[Bundler](https://bundler.io/) installed. Then:
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
$ bundle update
|
|
101
|
+
$ rake
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
If it's clean and you don't see any error messages, submit your pull request.
|
|
105
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2019 Yegor Bugayenko
|
|
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 all
|
|
13
|
+
# 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 THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
|
|
23
|
+
require 'rubygems'
|
|
24
|
+
require 'rake'
|
|
25
|
+
require 'rdoc'
|
|
26
|
+
require 'rake/clean'
|
|
27
|
+
|
|
28
|
+
def name
|
|
29
|
+
@name ||= File.basename(Dir['*.gemspec'].first, '.*')
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def version
|
|
33
|
+
Gem::Specification.load(Dir['*.gemspec'].first).version
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
task default: %i[clean test features rubocop copyright]
|
|
37
|
+
|
|
38
|
+
require 'rake/testtask'
|
|
39
|
+
desc 'Run all unit tests'
|
|
40
|
+
Rake::TestTask.new(:test) do |test|
|
|
41
|
+
Rake::Cleaner.cleanup_files(['coverage'])
|
|
42
|
+
test.libs << 'lib' << 'test'
|
|
43
|
+
test.pattern = 'test/**/test_*.rb'
|
|
44
|
+
test.verbose = false
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
require 'rdoc/task'
|
|
48
|
+
desc 'Build RDoc documentation'
|
|
49
|
+
Rake::RDocTask.new do |rdoc|
|
|
50
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
51
|
+
rdoc.title = "#{name} #{version}"
|
|
52
|
+
rdoc.rdoc_files.include('README*')
|
|
53
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
require 'rubocop/rake_task'
|
|
57
|
+
desc 'Run RuboCop on all directories'
|
|
58
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
|
59
|
+
task.fail_on_error = true
|
|
60
|
+
task.requires << 'rubocop-rspec'
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
require 'cucumber/rake/task'
|
|
64
|
+
Cucumber::Rake::Task.new(:features) do
|
|
65
|
+
Rake::Cleaner.cleanup_files(['coverage'])
|
|
66
|
+
end
|
|
67
|
+
Cucumber::Rake::Task.new(:'features:html') do |t|
|
|
68
|
+
t.profile = 'html_report'
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
task :copyright do
|
|
72
|
+
sh "grep -q -r '#{Date.today.strftime('%Y')}' \
|
|
73
|
+
--include '*.rb' \
|
|
74
|
+
--include '*.txt' \
|
|
75
|
+
--include 'Rakefile' \
|
|
76
|
+
."
|
|
77
|
+
end
|
data/appveyor.yml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
version: '{build}'
|
|
2
|
+
skip_tags: true
|
|
3
|
+
clone_depth: 10
|
|
4
|
+
branches:
|
|
5
|
+
only:
|
|
6
|
+
- master
|
|
7
|
+
except:
|
|
8
|
+
- gh-pages
|
|
9
|
+
os: Windows Server 2012
|
|
10
|
+
install:
|
|
11
|
+
- cmd: SET PATH=C:\Ruby23-x64\bin;%PATH%
|
|
12
|
+
- cmd: ruby --version
|
|
13
|
+
- cmd: git --version
|
|
14
|
+
build_script:
|
|
15
|
+
- bundle update
|
|
16
|
+
- bundle install
|
|
17
|
+
test_script:
|
|
18
|
+
- rake
|
|
19
|
+
cache:
|
|
20
|
+
- C:\Ruby200\bin -> sibit.gemspec
|
|
21
|
+
- C:\Ruby200\lib\ruby\gems\2.0.0 -> sibit.gemspec
|
data/bin/sibit
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# Copyright (c) 2019 Yegor Bugayenko
|
|
3
|
+
#
|
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
# furnished to do so, subject to the following conditions:
|
|
10
|
+
#
|
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
# copies or substantial portions of the Software.
|
|
13
|
+
#
|
|
14
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
# SOFTWARE.
|
|
21
|
+
|
|
22
|
+
STDOUT.sync = true
|
|
23
|
+
|
|
24
|
+
require 'slop'
|
|
25
|
+
require 'backtrace'
|
|
26
|
+
require_relative '../lib/sibit'
|
|
27
|
+
|
|
28
|
+
begin
|
|
29
|
+
begin
|
|
30
|
+
opts = Slop.parse(ARGV, strict: true, help: true) do |o|
|
|
31
|
+
o.banner = "Usage (#{Sibit::VERSION}): sibit [options]"
|
|
32
|
+
o.bool '--help', 'Read this: https://github.com/yegor256/sibit' do
|
|
33
|
+
puts o
|
|
34
|
+
exit
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
rescue Slop::Error => ex
|
|
38
|
+
raise "#{ex.message}"
|
|
39
|
+
end
|
|
40
|
+
sibit = Sibit.new
|
|
41
|
+
case opts.arguments[0]
|
|
42
|
+
when 'generate'
|
|
43
|
+
puts sibit.generate
|
|
44
|
+
when 'create'
|
|
45
|
+
pvt = opts.arguments[1]
|
|
46
|
+
raise 'Private key argument is required' if pvt.nil?
|
|
47
|
+
puts sibit.create(pvt)
|
|
48
|
+
when 'balance'
|
|
49
|
+
address = opts.arguments[1]
|
|
50
|
+
raise 'Address argument is required' if address.nil?
|
|
51
|
+
puts sibit.balance(address)
|
|
52
|
+
when 'pay'
|
|
53
|
+
pvt = opts.arguments[1]
|
|
54
|
+
raise 'Private key argument is required' if pvt.nil?
|
|
55
|
+
amount = opts.arguments[2]
|
|
56
|
+
raise 'Amount argument is required' if amount.nil?
|
|
57
|
+
fee = opts.arguments[3]
|
|
58
|
+
raise 'Miners fee argument is required' if fee.nil?
|
|
59
|
+
sources = opts.arguments[4]
|
|
60
|
+
raise 'Addresses argument is required' if sources.nil?
|
|
61
|
+
target = opts.arguments[5]
|
|
62
|
+
raise 'Target argument is required' if target.nil?
|
|
63
|
+
puts sibit.pay(pvt, amount, fee, sources.split(','), target)
|
|
64
|
+
else
|
|
65
|
+
raise "Command #{opts.arguments[0]} is not supported"
|
|
66
|
+
end
|
|
67
|
+
rescue StandardError => ex
|
|
68
|
+
puts "ERROR: #{ex.message}"
|
|
69
|
+
# puts Backtrace.new(ex).to_s
|
|
70
|
+
exit(255)
|
|
71
|
+
end
|
data/cucumber.yml
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Feature: Command Line Processing
|
|
2
|
+
As a newsletter author I want to be able to send a newsletter
|
|
3
|
+
|
|
4
|
+
Scenario: Help can be printed
|
|
5
|
+
When I run bin/sibit with "--help"
|
|
6
|
+
Then Exit code is zero
|
|
7
|
+
And Stdout contains "--help"
|
|
8
|
+
|
|
9
|
+
Scenario: Bitcoin private key can be generated
|
|
10
|
+
When I run bin/sibit with "generate"
|
|
11
|
+
Then Exit code is zero
|
|
12
|
+
|
|
13
|
+
Scenario: Bitcoin address can be created
|
|
14
|
+
When I run bin/sibit with "create 46feba063e9b59a8ae0dba68abd39a3cb8f52089e776576d6eb1bb5bfec123d1"
|
|
15
|
+
Then Exit code is zero
|
|
16
|
+
|
|
17
|
+
Scenario: Bitcoin balance can be checked
|
|
18
|
+
When I run bin/sibit with "balance 1MZT1fa6y8H9UmbZV6HqKF4UY41o9MGT5f"
|
|
19
|
+
Then Exit code is zero
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Feature: Gem Package
|
|
2
|
+
As a source code writer I want to be able to
|
|
3
|
+
package the Gem into .gem file
|
|
4
|
+
|
|
5
|
+
Scenario: Gem can be packaged
|
|
6
|
+
Given It is Unix
|
|
7
|
+
Given I have a "execs.rb" file with content:
|
|
8
|
+
"""
|
|
9
|
+
#!/usr/bin/env ruby
|
|
10
|
+
require 'rubygems'
|
|
11
|
+
spec = Gem::Specification::load('./spec.rb')
|
|
12
|
+
if spec.executables.empty?
|
|
13
|
+
fail 'no executables: ' + File.read('./spec.rb')
|
|
14
|
+
end
|
|
15
|
+
"""
|
|
16
|
+
When I run bash with:
|
|
17
|
+
"""
|
|
18
|
+
cd sibit
|
|
19
|
+
gem build sibit.gemspec
|
|
20
|
+
gem specification --ruby sibit-*.gem > ../spec.rb
|
|
21
|
+
cd ..
|
|
22
|
+
ruby execs.rb
|
|
23
|
+
"""
|
|
24
|
+
Then Exit code is zero
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2019 Yegor Bugayenko
|
|
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 all
|
|
13
|
+
# 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 NONINFINGEMENT. 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 THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
|
|
23
|
+
require 'nokogiri'
|
|
24
|
+
require 'tmpdir'
|
|
25
|
+
require 'slop'
|
|
26
|
+
require 'English'
|
|
27
|
+
require_relative '../../lib/sibit'
|
|
28
|
+
|
|
29
|
+
Before do
|
|
30
|
+
@cwd = Dir.pwd
|
|
31
|
+
@dir = Dir.mktmpdir('test')
|
|
32
|
+
FileUtils.mkdir_p(@dir) unless File.exist?(@dir)
|
|
33
|
+
Dir.chdir(@dir)
|
|
34
|
+
@opts = Slop.parse ['-v', '-s', @dir] do |o|
|
|
35
|
+
o.bool '-v', '--verbose'
|
|
36
|
+
o.string '-s', '--source'
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
After do
|
|
41
|
+
Dir.chdir(@cwd)
|
|
42
|
+
FileUtils.rm_rf(@dir) if File.exist?(@dir)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
Given(/^I have a "([^"]*)" file with content:$/) do |file, text|
|
|
46
|
+
FileUtils.mkdir_p(File.dirname(file)) unless File.exist?(file)
|
|
47
|
+
File.open(file, 'w') do |f|
|
|
48
|
+
f.write(text.gsub(/\\xFF/, 0xFF.chr))
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
When(%r{^I run bin/sibit with "([^"]*)"$}) do |arg|
|
|
53
|
+
home = File.join(File.dirname(__FILE__), '../..')
|
|
54
|
+
@stdout = `ruby -I#{home}/lib #{home}/bin/sibit #{arg}`
|
|
55
|
+
@exitstatus = $CHILD_STATUS.exitstatus
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
Then(/^Stdout contains "([^"]*)"$/) do |txt|
|
|
59
|
+
unless @stdout.include?(txt)
|
|
60
|
+
raise "STDOUT doesn't contain '#{txt}':\n#{@stdout}"
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
Then(/^Stdout is empty$/) do
|
|
65
|
+
raise "STDOUT is not empty:\n#{@stdout}" unless @stdout == ''
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
Then(/^Exit code is zero$/) do
|
|
69
|
+
raise "Non-zero exit #{@exitstatus}:\n#{@stdout}" unless @exitstatus.zero?
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
Then(/^Exit code is not zero$/) do
|
|
73
|
+
raise 'Zero exit code' if @exitstatus.zero?
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
When(/^I run bash with "([^"]*)"$/) do |text|
|
|
77
|
+
FileUtils.copy_entry(@cwd, File.join(@dir, 'sibit'))
|
|
78
|
+
@stdout = `#{text}`
|
|
79
|
+
@exitstatus = $CHILD_STATUS.exitstatus
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
When(/^I run bash with:$/) do |text|
|
|
83
|
+
FileUtils.copy_entry(@cwd, File.join(@dir, 'sibit'))
|
|
84
|
+
@stdout = `#{text}`
|
|
85
|
+
@exitstatus = $CHILD_STATUS.exitstatus
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
Given(/^It is Unix$/) do
|
|
89
|
+
pending if Gem.win_platform?
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
Given(/^It is Windows$/) do
|
|
93
|
+
pending unless Gem.win_platform?
|
|
94
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2019 Yegor Bugayenko
|
|
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 all
|
|
13
|
+
# 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 NONINFINGEMENT. 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 THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
|
|
23
|
+
require 'simplecov'
|
|
24
|
+
require_relative '../../lib/sibit'
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2019 Yegor Bugayenko
|
|
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 all
|
|
13
|
+
# 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 NONINFINGEMENT. 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 THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
|
|
23
|
+
# Sibit main class.
|
|
24
|
+
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
25
|
+
# Copyright:: Copyright (c) 2019 Yegor Bugayenko
|
|
26
|
+
# License:: MIT
|
|
27
|
+
class Sibit
|
|
28
|
+
# Current version of the library.
|
|
29
|
+
VERSION = '0.0.1'
|
|
30
|
+
end
|
data/lib/sibit.rb
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2019 Yegor Bugayenko
|
|
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 all
|
|
13
|
+
# 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 NONINFINGEMENT. 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 THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
|
|
23
|
+
require 'bitcoin'
|
|
24
|
+
require 'typhoeus'
|
|
25
|
+
require 'json'
|
|
26
|
+
|
|
27
|
+
# Sibit main class.
|
|
28
|
+
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
29
|
+
# Copyright:: Copyright (c) 2019 Yegor Bugayenko
|
|
30
|
+
# License:: MIT
|
|
31
|
+
class Sibit
|
|
32
|
+
# Generate new Bitcon private key.
|
|
33
|
+
def generate
|
|
34
|
+
key = Bitcoin::Key.generate
|
|
35
|
+
key.priv
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Create Bitcon address using the private key.
|
|
39
|
+
def create(pvt)
|
|
40
|
+
key = Bitcoin::Key.new
|
|
41
|
+
key.priv = pvt
|
|
42
|
+
key.addr
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Get the balance of the address, in satoshi.
|
|
46
|
+
def balance(address)
|
|
47
|
+
request = Typhoeus::Request.new(
|
|
48
|
+
"https://blockchain.info/rawaddr/#{address}",
|
|
49
|
+
method: :get,
|
|
50
|
+
headers: {}
|
|
51
|
+
)
|
|
52
|
+
request.run
|
|
53
|
+
response = request.response
|
|
54
|
+
json = JSON.parse(response.body)
|
|
55
|
+
json['final_balance']
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Send a payment.
|
|
59
|
+
def pay(_pvt, _amount, _fee, _sources, _target)
|
|
60
|
+
raise 'Not implemented yet'
|
|
61
|
+
end
|
|
62
|
+
end
|
data/sibit.gemspec
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2019 Yegor Bugayenko
|
|
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 all
|
|
13
|
+
# 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 THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
|
|
23
|
+
require 'English'
|
|
24
|
+
|
|
25
|
+
lib = File.expand_path('lib', __dir__)
|
|
26
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
27
|
+
require_relative 'lib/sibit/version'
|
|
28
|
+
Gem::Specification.new do |s|
|
|
29
|
+
s.specification_version = 2 if s.respond_to? :specification_version=
|
|
30
|
+
if s.respond_to? :required_rubygems_version=
|
|
31
|
+
s.required_rubygems_version = Gem::Requirement.new('>= 0')
|
|
32
|
+
end
|
|
33
|
+
s.rubygems_version = '2.2'
|
|
34
|
+
s.required_ruby_version = '>= 2.3'
|
|
35
|
+
s.name = 'sibit'
|
|
36
|
+
s.version = Sibit::VERSION
|
|
37
|
+
s.license = 'MIT'
|
|
38
|
+
s.summary = 'Simple Bitcoin Client'
|
|
39
|
+
s.description = 'This is a simple Bitcoin client, to use from command line \
|
|
40
|
+
or from your Ruby app. You don\'t need to run any Bitcoin software, \
|
|
41
|
+
no need to install anything, etc. All you need is just a command line \
|
|
42
|
+
and Ruby 2.3+.'
|
|
43
|
+
s.authors = ['Yegor Bugayenko']
|
|
44
|
+
s.email = 'yegor256@gmail.com'
|
|
45
|
+
s.homepage = 'http://github.com/yegor256/sibit'
|
|
46
|
+
s.files = `git ls-files`.split($RS)
|
|
47
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
48
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
|
49
|
+
s.rdoc_options = ['--charset=UTF-8']
|
|
50
|
+
s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
|
|
51
|
+
s.add_runtime_dependency 'backtrace', '0.3.0'
|
|
52
|
+
s.add_runtime_dependency 'bitcoin', '0.2.0'
|
|
53
|
+
s.add_runtime_dependency 'json', '2.2.0'
|
|
54
|
+
s.add_runtime_dependency 'slop', '4.6.2'
|
|
55
|
+
s.add_runtime_dependency 'typhoeus', '1.3.1'
|
|
56
|
+
s.add_development_dependency 'codecov', '0.1.10'
|
|
57
|
+
s.add_development_dependency 'cucumber', '1.3.17'
|
|
58
|
+
s.add_development_dependency 'minitest', '5.5.0'
|
|
59
|
+
s.add_development_dependency 'rake', '12.0.0'
|
|
60
|
+
# s.add_development_dependency 'rdoc', '4.2.0'
|
|
61
|
+
s.add_development_dependency 'rspec-rails', '3.1.0'
|
|
62
|
+
s.add_development_dependency 'rubocop', '0.61.0'
|
|
63
|
+
s.add_development_dependency 'rubocop-rspec', '1.31.0'
|
|
64
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2019 Yegor Bugayenko
|
|
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 all
|
|
13
|
+
# 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 NONINFINGEMENT. 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 THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
|
|
23
|
+
STDOUT.sync = true
|
|
24
|
+
|
|
25
|
+
require 'simplecov'
|
|
26
|
+
SimpleCov.start
|
|
27
|
+
if ENV['CI'] == 'true'
|
|
28
|
+
require 'codecov'
|
|
29
|
+
SimpleCov.formatter = SimpleCov::Formatter::Codecov
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
require 'minitest/autorun'
|
|
33
|
+
require_relative '../lib/sibit'
|
data/test/test_sibit.rb
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2019 Yegor Bugayenko
|
|
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 all
|
|
13
|
+
# 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 NONINFINGEMENT. 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 THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
|
|
23
|
+
require 'minitest/autorun'
|
|
24
|
+
require_relative '../lib/sibit'
|
|
25
|
+
|
|
26
|
+
# Sibit.
|
|
27
|
+
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
28
|
+
# Copyright:: Copyright (c) 2019 Yegor Bugayenko
|
|
29
|
+
# License:: MIT
|
|
30
|
+
class TestSibit < Minitest::Test
|
|
31
|
+
def test_generate_key
|
|
32
|
+
sibit = Sibit.new
|
|
33
|
+
pkey = sibit.generate
|
|
34
|
+
assert(!pkey.nil?)
|
|
35
|
+
assert(/^[0-9a-f]{64}$/.match?(pkey))
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_create_address
|
|
39
|
+
sibit = Sibit.new
|
|
40
|
+
pkey = sibit.generate
|
|
41
|
+
address = sibit.create(pkey)
|
|
42
|
+
assert(!address.nil?)
|
|
43
|
+
assert(/^1[0-9a-zA-Z]+$/.match?(address))
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def test_gets_balance
|
|
47
|
+
sibit = Sibit.new
|
|
48
|
+
balance = sibit.balance('1MZT1fa6y8H9UmbZV6HqKF4UY41o9MGT5f')
|
|
49
|
+
assert(balance.is_a?(Integer))
|
|
50
|
+
end
|
|
51
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: sibit
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Yegor Bugayenko
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2019-04-08 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: backtrace
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - '='
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 0.3.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.3.0
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: bitcoin
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - '='
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 0.2.0
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - '='
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: 0.2.0
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: json
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - '='
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: 2.2.0
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - '='
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: 2.2.0
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: slop
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - '='
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 4.6.2
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - '='
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: 4.6.2
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: typhoeus
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - '='
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: 1.3.1
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - '='
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: 1.3.1
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: codecov
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - '='
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: 0.1.10
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - '='
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: 0.1.10
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: cucumber
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - '='
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: 1.3.17
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - '='
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: 1.3.17
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: minitest
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - '='
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: 5.5.0
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - '='
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: 5.5.0
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: rake
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - '='
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: 12.0.0
|
|
132
|
+
type: :development
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - '='
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: 12.0.0
|
|
139
|
+
- !ruby/object:Gem::Dependency
|
|
140
|
+
name: rspec-rails
|
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
|
142
|
+
requirements:
|
|
143
|
+
- - '='
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: 3.1.0
|
|
146
|
+
type: :development
|
|
147
|
+
prerelease: false
|
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
149
|
+
requirements:
|
|
150
|
+
- - '='
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: 3.1.0
|
|
153
|
+
- !ruby/object:Gem::Dependency
|
|
154
|
+
name: rubocop
|
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
|
156
|
+
requirements:
|
|
157
|
+
- - '='
|
|
158
|
+
- !ruby/object:Gem::Version
|
|
159
|
+
version: 0.61.0
|
|
160
|
+
type: :development
|
|
161
|
+
prerelease: false
|
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
163
|
+
requirements:
|
|
164
|
+
- - '='
|
|
165
|
+
- !ruby/object:Gem::Version
|
|
166
|
+
version: 0.61.0
|
|
167
|
+
- !ruby/object:Gem::Dependency
|
|
168
|
+
name: rubocop-rspec
|
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
|
170
|
+
requirements:
|
|
171
|
+
- - '='
|
|
172
|
+
- !ruby/object:Gem::Version
|
|
173
|
+
version: 1.31.0
|
|
174
|
+
type: :development
|
|
175
|
+
prerelease: false
|
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
177
|
+
requirements:
|
|
178
|
+
- - '='
|
|
179
|
+
- !ruby/object:Gem::Version
|
|
180
|
+
version: 1.31.0
|
|
181
|
+
description: |-
|
|
182
|
+
This is a simple Bitcoin client, to use from command line \
|
|
183
|
+
or from your Ruby app. You don't need to run any Bitcoin software, \
|
|
184
|
+
no need to install anything, etc. All you need is just a command line \
|
|
185
|
+
and Ruby 2.3+.
|
|
186
|
+
email: yegor256@gmail.com
|
|
187
|
+
executables:
|
|
188
|
+
- sibit
|
|
189
|
+
extensions: []
|
|
190
|
+
extra_rdoc_files:
|
|
191
|
+
- README.md
|
|
192
|
+
- LICENSE.txt
|
|
193
|
+
files:
|
|
194
|
+
- ".0pdd.yml"
|
|
195
|
+
- ".gitattributes"
|
|
196
|
+
- ".gitignore"
|
|
197
|
+
- ".pdd"
|
|
198
|
+
- ".rubocop.yml"
|
|
199
|
+
- ".rultor.yml"
|
|
200
|
+
- ".simplecov"
|
|
201
|
+
- ".travis.yml"
|
|
202
|
+
- Gemfile
|
|
203
|
+
- LICENSE.txt
|
|
204
|
+
- README.md
|
|
205
|
+
- Rakefile
|
|
206
|
+
- appveyor.yml
|
|
207
|
+
- bin/sibit
|
|
208
|
+
- cucumber.yml
|
|
209
|
+
- features/cli.feature
|
|
210
|
+
- features/gem_package.feature
|
|
211
|
+
- features/step_definitions/steps.rb
|
|
212
|
+
- features/support/env.rb
|
|
213
|
+
- lib/sibit.rb
|
|
214
|
+
- lib/sibit/version.rb
|
|
215
|
+
- sibit.gemspec
|
|
216
|
+
- test/test__helper.rb
|
|
217
|
+
- test/test_sibit.rb
|
|
218
|
+
homepage: http://github.com/yegor256/sibit
|
|
219
|
+
licenses:
|
|
220
|
+
- MIT
|
|
221
|
+
metadata: {}
|
|
222
|
+
post_install_message:
|
|
223
|
+
rdoc_options:
|
|
224
|
+
- "--charset=UTF-8"
|
|
225
|
+
require_paths:
|
|
226
|
+
- lib
|
|
227
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
228
|
+
requirements:
|
|
229
|
+
- - ">="
|
|
230
|
+
- !ruby/object:Gem::Version
|
|
231
|
+
version: '2.3'
|
|
232
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
233
|
+
requirements:
|
|
234
|
+
- - ">="
|
|
235
|
+
- !ruby/object:Gem::Version
|
|
236
|
+
version: '0'
|
|
237
|
+
requirements: []
|
|
238
|
+
rubygems_version: 3.0.1
|
|
239
|
+
signing_key:
|
|
240
|
+
specification_version: 2
|
|
241
|
+
summary: Simple Bitcoin Client
|
|
242
|
+
test_files:
|
|
243
|
+
- features/cli.feature
|
|
244
|
+
- features/gem_package.feature
|
|
245
|
+
- features/step_definitions/steps.rb
|
|
246
|
+
- features/support/env.rb
|
|
247
|
+
- test/test__helper.rb
|
|
248
|
+
- test/test_sibit.rb
|