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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8969169f4a0ed8a12f015d3e66cd7a4e74cf2e3e1210828370eab0dc2680b99
4
- data.tar.gz: 296a09009b913387406c1f285916b6a33ef3fd1871c07951f703e1f187937f9a
3
+ metadata.gz: 7846df06f5fbb2cae2ee00122f75f640901fc2d2d5321d810ae0848ee56c01e2
4
+ data.tar.gz: 1ff75f919747d146c038c8cdfcc2cefbbd5dbf45136a5102691740ab7224dbd2
5
5
  SHA512:
6
- metadata.gz: de21c1b789b8bc2c4671e303aa8c613fb9d6b88b9a28ba7787d82212cbda08cad277c74d2c655c14dd21e3f462ad5b9a26275da3f45fc246fa8e837d177cf743
7
- data.tar.gz: c737bc8c538266bb00c2be64c0604da1035065a6fe1a0fa094be0f6180c46ab5df9f3483d577511c45d43b215423fd0c04971e54bcfacb4f8a945c93182cace1
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', '~>9.1', require: false
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 (9.2.1)
34
+ cucumber (10.2.0)
35
+ base64 (~> 0.2)
34
36
  builder (~> 3.2)
35
- cucumber-ci-environment (> 9, < 11)
36
- cucumber-core (> 13, < 14)
37
- cucumber-cucumber-expressions (~> 17.0)
38
- cucumber-gherkin (> 24, < 28)
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.2)
45
- cucumber-ci-environment (10.0.1)
46
- cucumber-core (13.0.3)
47
- cucumber-gherkin (>= 27, < 28)
48
- cucumber-messages (>= 20, < 23)
49
- cucumber-tag-expressions (> 5, < 7)
50
- cucumber-cucumber-expressions (17.1.0)
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 (27.0.0)
53
- cucumber-messages (>= 19.1.4, < 23)
54
- cucumber-html-formatter (21.15.1)
55
- cucumber-messages (> 19, < 28)
56
- cucumber-messages (22.0.0)
57
- cucumber-tag-expressions (6.1.2)
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.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.2)
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.0)
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 (~> 9.1)
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
- E9873D79C6D87FC233AA332626A3A3FE
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 E9873D79C6D87FC233AA332626A3A3FE
50
- 1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj
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 1CC3X2gu58d6wXUWMffpuzN9JAfTUWu4Kj
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 A1:P1,A2:P2,... TARGET CHANGE
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
- (you can say `S`, `M`, `L`, or `XL` if you want it
73
- to be calculated automatically),
74
- `A1:P1,A2:P2,...` is a comma-separated list
75
- of addresses `A` and private keys `P` you are sending your coins from,
76
- `TARGET` is the address you are sending to,
77
- `CHANGE` is the address where the change will be sent to.
78
- The transaction hash will be returned.
79
- Not all [UTXOs] will be used, but only the necessary amount of them.
80
-
81
- By default, the fee will be paid on top of the payment amount you are sending.
82
- Say, you are sending 0.5 BTC and the fee is 0.0001 BTC. Totally, you will
83
- spend 0.5001. However, you can make Sibit deduct the fee from the payment
84
- amount. In this case you should provide a negative amount of the fee
85
- or one of `-S`, `-M`, `-L`, `-XL`. You can also say `+S`, if you want the
86
- opposite, which is the default.
87
-
88
- It is recommended to run it with `--dry --verbose` options first, to see
89
- what's going to be sent to the network. If everything looks correct, remove
90
- the `--dry` and run again, the transaction will be pushed to the network.
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 will be sent to
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. This may be very useful since
137
- some APIs are not reliable and others don't have all the features required.
138
- You can provide an array of objects and they
139
- will be used one by one, until a successful response is obtained:
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. If it doesn't, submit an issue and I will try to help.
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
- your pull request. You will need to have [Ruby] 2.3+ and
177
- [Bundler] installed. Then:
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
- begin
27
+ opts =
29
28
  begin
30
- opts = Slop.parse(ARGV, strict: true, help: true) do |o|
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
- price: Get current price of BTC in USD
34
- fees: Get currently recommended transaction fees
35
- latest: Get hash of the latest block
36
- generate: Generate a new private key
37
- create: Create a public Bitcoin address from the key
38
- balance: Check the balance of the Bitcoin address
39
- pay: Send a new Bitcoin transaction
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(',').map { |p| p.split(':') }.to_h,
131
+ sources.split(','),
131
132
  target, change,
132
133
  skip_utxo: opts['skip-utxo']
133
134
  )
data/lib/sibit/version.rb CHANGED
@@ -9,5 +9,5 @@
9
9
  # License:: MIT
10
10
  class Sibit
11
11
  # Current version of the library.
12
- VERSION = '0.27.0'
12
+ VERSION = '0.28.0'
13
13
  end
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 hashmap of bitcoin addresses where the coins are now, with
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sibit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.27.0
4
+ version: 0.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko