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.
- checksums.yaml +4 -4
- data/README.md +33 -31
- data/bin/sibit +12 -10
- 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/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
|
|
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'
|
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
27
|
+
opts =
|
|
28
28
|
begin
|
|
29
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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(',')
|
|
131
|
+
sources.split(','),
|
|
130
132
|
target, change,
|
|
131
133
|
skip_utxo: opts['skip-utxo']
|
|
132
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
|