mixin_bot 0.6.2 → 0.6.3
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/lib/mixin_bot/api/multisig.rb +44 -45
- data/lib/mixin_bot/version.rb +1 -1
- 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: '0482fa8ed14e5435679aba1bd40e8f9d13a4db3c4f96f2b7fe97f2639d7d55d1'
|
|
4
|
+
data.tar.gz: 506032e530c347644b878d1f1ba7a520208ca9c5ee1450351657291af46c9153
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b855af1cda16ae26a7b224593adabadc5f9636f364ad36bccbcba4117ad631a38ff70abc35c3cac05df81a6bf14235d923029699df8256c8f05b59a0c697d46a
|
|
7
|
+
data.tar.gz: 7cd57b5eabe7726b5fe4d751e85ad1a4a36754b8b547a0a27baad26ccffff16a7731dc0dd3151be011e872b79a34444a6bd74b22ec550d4e567231a0b85a8552
|
|
@@ -156,16 +156,20 @@ module MixinBot
|
|
|
156
156
|
def build_raw_transaction(**kwargs)
|
|
157
157
|
raise ArgumentError, "#{RAW_TRANSACTION_ARGUMENTS.join(', ')} are needed for build raw transaction" unless RAW_TRANSACTION_ARGUMENTS.all? { |param| kwargs.keys.include? param }
|
|
158
158
|
|
|
159
|
-
senders
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
159
|
+
senders = kwargs[:senders]
|
|
160
|
+
threshold = kwargs[:threshold]
|
|
161
|
+
receivers = kwargs[:receivers]
|
|
162
|
+
receivers_threshold = kwargs[:receivers_threshold]
|
|
163
|
+
amount = kwargs[:amount]
|
|
164
|
+
threshold = kwargs[:threshold]
|
|
165
|
+
asset_id = kwargs[:asset_id]
|
|
166
|
+
asset_mixin_id = kwargs[:asset_mixin_id]
|
|
167
|
+
utxos = kwargs[:utxos]
|
|
168
|
+
memo = kwargs[:memo]
|
|
169
|
+
extra = kwargs[:extra]
|
|
170
|
+
access_token = kwargs[:access_token]
|
|
171
|
+
outputs = kwargs[:outputs] || []
|
|
172
|
+
hint = kwargs[:hint]
|
|
169
173
|
|
|
170
174
|
raise 'access_token required!' if access_token.nil? && !senders.include?(client_id)
|
|
171
175
|
|
|
@@ -193,23 +197,27 @@ module MixinBot
|
|
|
193
197
|
}
|
|
194
198
|
)
|
|
195
199
|
|
|
196
|
-
outputs
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
200
|
+
if outputs.empty?
|
|
201
|
+
receivers_threshold = 1 if receivers.size == 1
|
|
202
|
+
output0 = build_output(
|
|
203
|
+
receivers: receivers,
|
|
204
|
+
index: 0,
|
|
205
|
+
amount: amount,
|
|
206
|
+
threshold: receivers_threshold,
|
|
207
|
+
hint: hint
|
|
208
|
+
)
|
|
209
|
+
outputs.push output0
|
|
204
210
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
211
|
+
if input_amount > amount
|
|
212
|
+
output1 = build_output(
|
|
213
|
+
receivers: senders,
|
|
214
|
+
index: 1,
|
|
215
|
+
amount: (input_amount - amount),
|
|
216
|
+
threshold: threshold,
|
|
217
|
+
hint: hint
|
|
218
|
+
)
|
|
219
|
+
outputs.push output1
|
|
220
|
+
end
|
|
213
221
|
end
|
|
214
222
|
|
|
215
223
|
extra = extra || Digest.hexencode(memo.to_s.slice(0, 140))
|
|
@@ -225,31 +233,22 @@ module MixinBot
|
|
|
225
233
|
tx.to_json
|
|
226
234
|
end
|
|
227
235
|
|
|
236
|
+
def build_output(receivers:, index:, amount:, threshold:, hint: nil)
|
|
237
|
+
_output = create_output receivers: receivers, index: index, hint: hint
|
|
238
|
+
{
|
|
239
|
+
amount: format('%.8f', amount.to_f),
|
|
240
|
+
script: build_threshold_script(threshold),
|
|
241
|
+
mask: _output['mask'],
|
|
242
|
+
keys: _output['keys']
|
|
243
|
+
}
|
|
244
|
+
end
|
|
245
|
+
|
|
228
246
|
def str_to_bin(str)
|
|
229
247
|
return if str.nil?
|
|
230
248
|
|
|
231
249
|
str.scan(/../).map(&:hex).pack('c*')
|
|
232
250
|
end
|
|
233
251
|
|
|
234
|
-
def build_inputs(inputs)
|
|
235
|
-
res = []
|
|
236
|
-
prototype = {
|
|
237
|
-
'Hash' => nil,
|
|
238
|
-
'Index' => nil,
|
|
239
|
-
'Genesis' => nil,
|
|
240
|
-
'Deposit' => nil,
|
|
241
|
-
'Mint' => nil
|
|
242
|
-
}
|
|
243
|
-
inputs.each do |input|
|
|
244
|
-
struc = prototype.dup
|
|
245
|
-
struc['Hash'] = str_to_bin input['hash']
|
|
246
|
-
struc['Index'] = input['index']
|
|
247
|
-
res << struc
|
|
248
|
-
end
|
|
249
|
-
|
|
250
|
-
res
|
|
251
|
-
end
|
|
252
|
-
|
|
253
252
|
def generate_trace_from_hash(hash, output_index = 0)
|
|
254
253
|
MixinBot::Utils.generate_trace_from_hash hash, output_index
|
|
255
254
|
end
|
data/lib/mixin_bot/version.rb
CHANGED