sibit 0.7.5 → 0.7.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sibit/version.rb +1 -1
- data/lib/sibit.rb +25 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45ecd94da9a09da7f98b1997ec5a4bc809586fd0df18ffc5e83f3868fb57cf1d
|
4
|
+
data.tar.gz: bc0cbf54e5606685cf7c6729c49b5eadbc6b5590d7942cd880e4fd82daa5c1d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2049ad467b90e2b87d7f4149aa5d79d86810fc3b0fa56b278e17a7de3c9e3613c38eb53fb82fe3f5d8a68184921fadc04c9d3e3433c912034afe411e3509cd22
|
7
|
+
data.tar.gz: 3e15a316137cb4d01c8b9a1dd3339865920fe7006fdd52e31bf79ea284160eaeda73283414f75eeaad6805d27933b3b1538cdf71eda4566e7233da92ccf7ec6a
|
data/lib/sibit/version.rb
CHANGED
data/lib/sibit.rb
CHANGED
@@ -128,7 +128,8 @@ class Sibit
|
|
128
128
|
utxos = get_json(
|
129
129
|
"/unspent?active=#{sources.keys.join('|')}&limit=1000"
|
130
130
|
)['unspent_outputs']
|
131
|
-
info("#{utxos.count} UTXOs found
|
131
|
+
info("#{utxos.count} UTXOs found, these will be used \
|
132
|
+
(value/confirmations at tx_hash):")
|
132
133
|
utxos.each do |utxo|
|
133
134
|
unspent += utxo['value']
|
134
135
|
builder.input do |i|
|
@@ -139,22 +140,33 @@ class Sibit
|
|
139
140
|
i.signature_key(key(sources[address]))
|
140
141
|
end
|
141
142
|
size += 180
|
142
|
-
info(" #{utxo['value']}/#{utxo['confirmations']} at #{utxo['tx_hash_big_endian']}")
|
143
|
+
info(" #{num(utxo['value'])}/#{utxo['confirmations']} at #{utxo['tx_hash_big_endian']}")
|
143
144
|
break if unspent > satoshi
|
144
145
|
end
|
145
|
-
|
146
|
+
if unspent < satoshi
|
147
|
+
raise Error, "Not enough funds to send #{num(amount)}, only #{num(unspent)} left"
|
148
|
+
end
|
146
149
|
builder.output(satoshi, target)
|
147
150
|
f = mfee(fee, size)
|
148
151
|
tx = builder.tx(
|
149
152
|
input_value: unspent,
|
150
|
-
leave_fee:
|
153
|
+
leave_fee: true,
|
154
|
+
extra_fee: f - Bitcoin.network[:min_tx_fee],
|
151
155
|
change_address: change
|
152
156
|
)
|
153
|
-
info("A new Bitcoin transaction #{tx.hash} prepared
|
154
|
-
#{tx.
|
155
|
-
|
156
|
-
#{tx.
|
157
|
-
|
157
|
+
info("A new Bitcoin transaction #{tx.hash} prepared:
|
158
|
+
#{tx.in.count} input#{tx.in.count > 1 ? 's' : ''}:
|
159
|
+
#{tx.inputs.map { |i| " in: #{i.prev_out.bth}:#{i.prev_out_index}" }.join("\n ")}
|
160
|
+
#{tx.out.count} output#{tx.out.count > 1 ? 's' : ''}:
|
161
|
+
#{tx.outputs.map { |o| "out: #{o.script.bth} / #{num(o.value)}" }.join("\n ")}
|
162
|
+
Fee required: #{num(f)} satoshi
|
163
|
+
Min tx fee: #{num(Bitcoin.network[:min_tx_fee])} satoshi
|
164
|
+
Fee left: #{num(unspent - tx.outputs.map(&:value).inject(&:+))} satoshi
|
165
|
+
Tx size: #{num(size)} bytes
|
166
|
+
Unspent: #{num(unspent)} satoshi
|
167
|
+
Amount: #{num(satoshi)} satoshi
|
168
|
+
Target address: #{target}
|
169
|
+
Change address is #{change}")
|
158
170
|
post_tx(tx.to_payload.bth)
|
159
171
|
tx.hash
|
160
172
|
end
|
@@ -177,6 +189,10 @@ amount is #{satoshi}; target address is #{target}; change address is #{change}:
|
|
177
189
|
|
178
190
|
private
|
179
191
|
|
192
|
+
def num(int)
|
193
|
+
int.to_s.gsub(/\d(?=(...)+$)/, '\0,')
|
194
|
+
end
|
195
|
+
|
180
196
|
# Convert text to amount.
|
181
197
|
def satoshi(amount)
|
182
198
|
return amount if amount.is_a?(Integer)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sibit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|