sibit 0.27.0 → 0.28.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 +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +25 -24
- data/README.md +40 -37
- data/bin/sibit +12 -11
- data/lib/sibit/version.rb +1 -1
- data/lib/sibit.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7846df06f5fbb2cae2ee00122f75f640901fc2d2d5321d810ae0848ee56c01e2
|
|
4
|
+
data.tar.gz: 1ff75f919747d146c038c8cdfcc2cefbbd5dbf45136a5102691740ab7224dbd2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 892d1c222af88708788f791a8508c7622f3e148190c7aa2cf4a8c6fbb3a47fdd2dd78ebd0190512fb11c0a512ac4d474153c2467bf54a4cb4f7afa260d732b1f
|
|
7
|
+
data.tar.gz: b9d78f193a4e81d5c9659528927c6526f6d2413f65303bd016b6fdd220c0afac25c0555f05ddeaf34ab5e0d9fd257ba8d0f5f70b31667eeb1ebc549cab232bc6
|
data/Gemfile
CHANGED
|
@@ -9,7 +9,7 @@ gemspec
|
|
|
9
9
|
# gem 'debase', '0.2.4.1', require: false
|
|
10
10
|
|
|
11
11
|
gem 'aruba', '~>2.2', require: false
|
|
12
|
-
gem 'cucumber', '~>
|
|
12
|
+
gem 'cucumber', '~>10.0', require: false
|
|
13
13
|
gem 'logger', '~>1.7', require: false
|
|
14
14
|
gem 'minitest', '~>6.0', require: false
|
|
15
15
|
gem 'minitest-reporters', '~>1.7', require: false
|
data/Gemfile.lock
CHANGED
|
@@ -24,37 +24,38 @@ GEM
|
|
|
24
24
|
thor (~> 1.0)
|
|
25
25
|
ast (2.4.3)
|
|
26
26
|
backtrace (0.4.1)
|
|
27
|
+
base64 (0.3.0)
|
|
27
28
|
bigdecimal (4.0.1)
|
|
28
29
|
builder (3.3.0)
|
|
29
30
|
contracts (0.17.3)
|
|
30
31
|
crack (1.0.1)
|
|
31
32
|
bigdecimal
|
|
32
33
|
rexml
|
|
33
|
-
cucumber (
|
|
34
|
+
cucumber (10.2.0)
|
|
35
|
+
base64 (~> 0.2)
|
|
34
36
|
builder (~> 3.2)
|
|
35
|
-
cucumber-ci-environment (> 9, <
|
|
36
|
-
cucumber-core (>
|
|
37
|
-
cucumber-cucumber-expressions (
|
|
38
|
-
cucumber-
|
|
39
|
-
cucumber-html-formatter (> 20.3, < 22)
|
|
40
|
-
cucumber-messages (> 19, < 25)
|
|
37
|
+
cucumber-ci-environment (> 9, < 12)
|
|
38
|
+
cucumber-core (> 15, < 17)
|
|
39
|
+
cucumber-cucumber-expressions (> 17, < 20)
|
|
40
|
+
cucumber-html-formatter (> 21, < 23)
|
|
41
41
|
diff-lcs (~> 1.5)
|
|
42
|
+
logger (~> 1.6)
|
|
42
43
|
mini_mime (~> 1.1)
|
|
43
44
|
multi_test (~> 1.1)
|
|
44
|
-
sys-uname (~> 1.
|
|
45
|
-
cucumber-ci-environment (
|
|
46
|
-
cucumber-core (
|
|
47
|
-
cucumber-gherkin (
|
|
48
|
-
cucumber-messages (
|
|
49
|
-
cucumber-tag-expressions (>
|
|
50
|
-
cucumber-cucumber-expressions (
|
|
45
|
+
sys-uname (~> 1.3)
|
|
46
|
+
cucumber-ci-environment (11.0.0)
|
|
47
|
+
cucumber-core (16.1.1)
|
|
48
|
+
cucumber-gherkin (> 36, < 40)
|
|
49
|
+
cucumber-messages (> 31, < 33)
|
|
50
|
+
cucumber-tag-expressions (> 6, < 9)
|
|
51
|
+
cucumber-cucumber-expressions (18.0.1)
|
|
51
52
|
bigdecimal
|
|
52
|
-
cucumber-gherkin (
|
|
53
|
-
cucumber-messages (>=
|
|
54
|
-
cucumber-html-formatter (
|
|
55
|
-
cucumber-messages (>
|
|
56
|
-
cucumber-messages (
|
|
57
|
-
cucumber-tag-expressions (
|
|
53
|
+
cucumber-gherkin (37.0.1)
|
|
54
|
+
cucumber-messages (>= 31, < 32)
|
|
55
|
+
cucumber-html-formatter (22.3.0)
|
|
56
|
+
cucumber-messages (> 23, < 33)
|
|
57
|
+
cucumber-messages (31.1.0)
|
|
58
|
+
cucumber-tag-expressions (8.1.0)
|
|
58
59
|
date (3.5.1)
|
|
59
60
|
diff-lcs (1.6.2)
|
|
60
61
|
docile (1.4.1)
|
|
@@ -71,7 +72,7 @@ GEM
|
|
|
71
72
|
logger (~> 1.0)
|
|
72
73
|
memoist3 (1.0.0)
|
|
73
74
|
mini_mime (1.1.5)
|
|
74
|
-
minitest (6.0.
|
|
75
|
+
minitest (6.0.1)
|
|
75
76
|
prism (~> 1.5)
|
|
76
77
|
minitest-reporters (1.7.1)
|
|
77
78
|
ansi
|
|
@@ -96,7 +97,7 @@ GEM
|
|
|
96
97
|
racc (1.8.1)
|
|
97
98
|
rainbow (3.1.1)
|
|
98
99
|
rake (13.3.1)
|
|
99
|
-
rdoc (7.0.
|
|
100
|
+
rdoc (7.0.3)
|
|
100
101
|
erb
|
|
101
102
|
psych (>= 4.0.0)
|
|
102
103
|
tsort
|
|
@@ -109,7 +110,7 @@ GEM
|
|
|
109
110
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
110
111
|
rspec-support (~> 3.13.0)
|
|
111
112
|
rspec-support (3.13.6)
|
|
112
|
-
rubocop (1.82.
|
|
113
|
+
rubocop (1.82.1)
|
|
113
114
|
json (~> 2.3)
|
|
114
115
|
language_server-protocol (~> 3.17.0.2)
|
|
115
116
|
lint_roller (~> 1.1.0)
|
|
@@ -167,7 +168,7 @@ PLATFORMS
|
|
|
167
168
|
|
|
168
169
|
DEPENDENCIES
|
|
169
170
|
aruba (~> 2.2)
|
|
170
|
-
cucumber (~>
|
|
171
|
+
cucumber (~> 10.0)
|
|
171
172
|
logger (~> 1.7)
|
|
172
173
|
minitest (~> 6.0)
|
|
173
174
|
minitest-reporters (~> 1.7)
|
data/README.md
CHANGED
|
@@ -38,56 +38,57 @@ gem install sibit
|
|
|
38
38
|
Then, you generate a [private key]:
|
|
39
39
|
|
|
40
40
|
```bash
|
|
41
|
-
sibit generate
|
|
42
|
-
|
|
41
|
+
$ sibit generate
|
|
42
|
+
1461cc61c3b09d01d5c02b901577c9d052264e77043bddd3d222ab8a6f7e0db0
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
Next, you create a new [address],
|
|
46
46
|
using your private key:
|
|
47
47
|
|
|
48
48
|
```bash
|
|
49
|
-
sibit create
|
|
50
|
-
|
|
49
|
+
$ sibit create 1461cc61c3b09d01d5c02b901577c9d052264e77043bddd3d222ab8a6f7e0db0
|
|
50
|
+
1PfsYNygsuVL8fvBarJNQnHytkg4rGih1U
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
To check the balance at the address (the result is in
|
|
54
54
|
[satoshi]):
|
|
55
55
|
|
|
56
56
|
```bash
|
|
57
|
-
sibit balance
|
|
57
|
+
$ sibit balance 1PfsYNygsuVL8fvBarJNQnHytkg4rGih1U
|
|
58
58
|
80988977
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
To send a payment from a few addresses to a new address:
|
|
62
62
|
|
|
63
63
|
```bash
|
|
64
|
-
sibit pay AMOUNT FEE
|
|
64
|
+
$ sibit pay AMOUNT FEE P1,P2,... TARGET CHANGE
|
|
65
65
|
e87f138c9ebf5986151667719825c28458a28cc66f69fed4f1032a93b399fdf8
|
|
66
66
|
```
|
|
67
67
|
|
|
68
68
|
Here,
|
|
69
|
-
`AMOUNT` is the amount of [satoshi] you are sending,
|
|
70
|
-
`FEE` is the [miner fee] you are ready to spend to get
|
|
71
|
-
this transaction delivered
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
`
|
|
75
|
-
|
|
76
|
-
`
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
or one of `-S`, `-M`, `-L`, `-XL`.
|
|
86
|
-
opposite, which is the default.
|
|
87
|
-
|
|
88
|
-
It is recommended to run it with `--dry --verbose` options first,
|
|
89
|
-
what's going to be sent to the network.
|
|
90
|
-
the `--dry` and run again,
|
|
69
|
+
`AMOUNT` is the amount of [satoshi] you are sending,
|
|
70
|
+
`FEE` is the [miner fee] you are ready to spend to get
|
|
71
|
+
this transaction delivered (you can say `S`, `M`, `L`, or `XL` if you want it
|
|
72
|
+
to be calculated automatically),
|
|
73
|
+
`P1,P2,...` is a comma-separated list
|
|
74
|
+
of private keys `P` you are sending your coins from,
|
|
75
|
+
`TARGET` is the address you are sending to,
|
|
76
|
+
`CHANGE` is the address where the change goes.
|
|
77
|
+
The transaction hash is returned.
|
|
78
|
+
Not all [UTXOs] may be used, but only the necessary amount of them.
|
|
79
|
+
|
|
80
|
+
By default, the fee is paid on top of the payment amount you are sending.
|
|
81
|
+
Say, you are sending 0.5 BTC and the fee is 0.0001 BTC.
|
|
82
|
+
Totally, you spend 0.5001.
|
|
83
|
+
However, you can make Sibit deduct the fee from the payment amount.
|
|
84
|
+
In this case you should provide a negative amount
|
|
85
|
+
of the fee or one of `-S`, `-M`, `-L`, `-XL`.
|
|
86
|
+
You can also say `+S`, if you want the opposite, which is the default.
|
|
87
|
+
|
|
88
|
+
It is recommended to run it with `--dry --verbose` options first,
|
|
89
|
+
to see what's going to be sent to the network.
|
|
90
|
+
If everything looks correct, remove the `--dry` and run again,
|
|
91
|
+
the transaction is pushed to the network.
|
|
91
92
|
|
|
92
93
|
All operations are performed through the
|
|
93
94
|
[Blockchain API].
|
|
@@ -105,7 +106,7 @@ pkey = sibit.generate
|
|
|
105
106
|
address = sibit.create(pkey)
|
|
106
107
|
balance = sibit.balance(address)
|
|
107
108
|
target = sibit.create(pkey) # where to send coins to
|
|
108
|
-
change = sibit.create(pkey) # where the change
|
|
109
|
+
change = sibit.create(pkey) # where the change goes
|
|
109
110
|
tx = sibit.pay(10_000_000, 'XL', { address => pkey }, target, change)
|
|
110
111
|
```
|
|
111
112
|
|
|
@@ -133,10 +134,11 @@ require 'sibit/btc'
|
|
|
133
134
|
sibit = Sibit.new(api: Sibit::Btc.new)
|
|
134
135
|
```
|
|
135
136
|
|
|
136
|
-
You may also use a combination of APIs.
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
You may also use a combination of APIs.
|
|
138
|
+
This may be very useful since some APIs are not reliable
|
|
139
|
+
and others don't have all the features required.
|
|
140
|
+
You can provide an array of objects and they are used one by one,
|
|
141
|
+
until a successful response is obtained:
|
|
140
142
|
|
|
141
143
|
```ruby
|
|
142
144
|
require 'sibit'
|
|
@@ -167,14 +169,15 @@ gem install rake --no-document
|
|
|
167
169
|
gem install sibit
|
|
168
170
|
```
|
|
169
171
|
|
|
170
|
-
It should work.
|
|
172
|
+
It should work.
|
|
173
|
+
If it doesn't, submit an issue and I can try to help.
|
|
171
174
|
|
|
172
175
|
## How to contribute
|
|
173
176
|
|
|
174
177
|
Read [these guidelines].
|
|
175
|
-
Make sure your build is green before you contribute
|
|
176
|
-
|
|
177
|
-
|
|
178
|
+
Make sure your build is green before you contribute your pull request.
|
|
179
|
+
You need to have [Ruby] 2.3+ and [Bundler] installed.
|
|
180
|
+
Then:
|
|
178
181
|
|
|
179
182
|
```bash
|
|
180
183
|
bundle update
|
data/bin/sibit
CHANGED
|
@@ -9,7 +9,6 @@ $stdout.sync = true
|
|
|
9
9
|
# see https://stackoverflow.com/a/6048451/187141
|
|
10
10
|
require 'openssl'
|
|
11
11
|
OpenSSL::SSL::VERIFY_PEER ||= OpenSSL::SSL::VERIFY_NONE
|
|
12
|
-
puts OpenSSL::X509::DEFAULT_CERT_FILE
|
|
13
12
|
|
|
14
13
|
require 'backtrace'
|
|
15
14
|
require 'loog'
|
|
@@ -25,18 +24,18 @@ require_relative '../lib/sibit/fake'
|
|
|
25
24
|
require_relative '../lib/sibit/firstof'
|
|
26
25
|
require_relative '../lib/sibit/version'
|
|
27
26
|
|
|
28
|
-
|
|
27
|
+
opts =
|
|
29
28
|
begin
|
|
30
|
-
|
|
29
|
+
Slop.parse(ARGV, strict: true, help: true) do |o|
|
|
31
30
|
o.banner = "Usage (#{Sibit::VERSION}): sibit [options] command [args]
|
|
32
31
|
Commands are:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
price: Get current price of BTC in USD
|
|
33
|
+
fees: Get currently recommended transaction fees
|
|
34
|
+
latest: Get hash of the latest block
|
|
35
|
+
generate: Generate a new private key
|
|
36
|
+
create: Create a public Bitcoin address from the key
|
|
37
|
+
balance: Check the balance of the Bitcoin address
|
|
38
|
+
pay: Send a new Bitcoin transaction
|
|
40
39
|
Options are:"
|
|
41
40
|
o.string '--proxy', 'HTTPS proxy for all requests, e.g. "localhost:3128"'
|
|
42
41
|
o.integer(
|
|
@@ -64,6 +63,8 @@ Options are:"
|
|
|
64
63
|
rescue Slop::Error => e
|
|
65
64
|
raise e.message
|
|
66
65
|
end
|
|
66
|
+
|
|
67
|
+
begin
|
|
67
68
|
raise 'Try --help' if opts.arguments.empty?
|
|
68
69
|
log = opts[:verbose] ? Loog::VERBOSE : Loog::NULL
|
|
69
70
|
http = opts[:proxy] ? Sibit::HttpProxy.new(opts[:proxy]) : Sibit::Http.new
|
|
@@ -127,7 +128,7 @@ Options are:"
|
|
|
127
128
|
raise 'Change argument is required' if change.nil?
|
|
128
129
|
puts sibit.pay(
|
|
129
130
|
amount, fee,
|
|
130
|
-
sources.split(',')
|
|
131
|
+
sources.split(','),
|
|
131
132
|
target, change,
|
|
132
133
|
skip_utxo: opts['skip-utxo']
|
|
133
134
|
)
|
data/lib/sibit/version.rb
CHANGED
data/lib/sibit.rb
CHANGED
|
@@ -94,12 +94,12 @@ class Sibit
|
|
|
94
94
|
#
|
|
95
95
|
# +amount+: the amount either in satoshis or ending with 'BTC', like '0.7BTC'
|
|
96
96
|
# +fee+: the miners fee in satoshis (as integer) or S/M/X/XL as a string
|
|
97
|
-
# +sources+: the
|
|
98
|
-
# their addresses as keys and private keys as values
|
|
97
|
+
# +sources+: the list of private bitcoin keys where the coins are now
|
|
99
98
|
# +target+: the target address to send to
|
|
100
99
|
# +change+: the address where the change has to be sent to
|
|
101
100
|
def pay(amount, fee, sources, target, change, skip_utxo: [])
|
|
102
101
|
p = price('USD')
|
|
102
|
+
sources = sources.map { |k| [Bitcoin::Key.new(k).addr, k] }.to_h
|
|
103
103
|
satoshi = satoshi(amount)
|
|
104
104
|
builder = Bitcoin::TxBuilder.new
|
|
105
105
|
unspent = 0
|