sibit 0.27.1 → 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.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +33 -31
  3. data/bin/sibit +12 -10
  4. data/lib/sibit/version.rb +1 -1
  5. data/lib/sibit.rb +2 -2
  6. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 731731c7fc499008d0a0fd713a84f8b416d55163674e6c2e45783436a283720d
4
- data.tar.gz: f4b5d3b5119381ffdf4c764a1f4e82b4eb06f3b66135070b33ebffc43e523ec3
3
+ metadata.gz: 7846df06f5fbb2cae2ee00122f75f640901fc2d2d5321d810ae0848ee56c01e2
4
+ data.tar.gz: 1ff75f919747d146c038c8cdfcc2cefbbd5dbf45136a5102691740ab7224dbd2
5
5
  SHA512:
6
- metadata.gz: f4b72bfda3a91eeb48eaf97b1badaba49d0cceaf4e935fe3b3ee983217b920602ad9935f1b2f70b881b08c9ed0f946b11be93abd606642d293846657f359c473
7
- data.tar.gz: 2e4e84c22a4be9f275d53c5003ccbf5feaba4813546624c590cf853938e958b7e934c60d2924c9ed4e8f8ed301923df89edf337676fb4a231bb0f9ebe2b3c9c9
6
+ metadata.gz: 892d1c222af88708788f791a8508c7622f3e148190c7aa2cf4a8c6fbb3a47fdd2dd78ebd0190512fb11c0a512ac4d474153c2467bf54a4cb4f7afa260d732b1f
7
+ data.tar.gz: b9d78f193a4e81d5c9659528927c6526f6d2413f65303bd016b6fdd220c0afac25c0555f05ddeaf34ab5e0d9fd257ba8d0f5f70b31667eeb1ebc549cab232bc6
data/README.md CHANGED
@@ -61,33 +61,34 @@ $ sibit balance 1PfsYNygsuVL8fvBarJNQnHytkg4rGih1U
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'
@@ -168,13 +170,13 @@ gem install sibit
168
170
  ```
169
171
 
170
172
  It should work.
171
- If it doesn't, submit an issue and I will try to help.
173
+ If it doesn't, submit an issue and I can try to help.
172
174
 
173
175
  ## How to contribute
174
176
 
175
177
  Read [these guidelines].
176
- Make sure your build is green before you contribute
177
- your pull request. You will need to have [Ruby] 2.3+ and [Bundler] installed.
178
+ Make sure your build is green before you contribute your pull request.
179
+ You need to have [Ruby] 2.3+ and [Bundler] installed.
178
180
  Then:
179
181
 
180
182
  ```bash
data/bin/sibit CHANGED
@@ -24,18 +24,18 @@ require_relative '../lib/sibit/fake'
24
24
  require_relative '../lib/sibit/firstof'
25
25
  require_relative '../lib/sibit/version'
26
26
 
27
- begin
27
+ opts =
28
28
  begin
29
- opts = Slop.parse(ARGV, strict: true, help: true) do |o|
29
+ Slop.parse(ARGV, strict: true, help: true) do |o|
30
30
  o.banner = "Usage (#{Sibit::VERSION}): sibit [options] command [args]
31
31
  Commands are:
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
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
39
39
  Options are:"
40
40
  o.string '--proxy', 'HTTPS proxy for all requests, e.g. "localhost:3128"'
41
41
  o.integer(
@@ -63,6 +63,8 @@ Options are:"
63
63
  rescue Slop::Error => e
64
64
  raise e.message
65
65
  end
66
+
67
+ begin
66
68
  raise 'Try --help' if opts.arguments.empty?
67
69
  log = opts[:verbose] ? Loog::VERBOSE : Loog::NULL
68
70
  http = opts[:proxy] ? Sibit::HttpProxy.new(opts[:proxy]) : Sibit::Http.new
@@ -126,7 +128,7 @@ Options are:"
126
128
  raise 'Change argument is required' if change.nil?
127
129
  puts sibit.pay(
128
130
  amount, fee,
129
- sources.split(',').map { |p| p.split(':') }.to_h,
131
+ sources.split(','),
130
132
  target, change,
131
133
  skip_utxo: opts['skip-utxo']
132
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.1'
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.1
4
+ version: 0.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko