mixin_bot 0.6.8 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mixin_bot/api/multisig.rb +1 -14
- data/lib/mixin_bot/api/rpc.rb +48 -0
- data/lib/mixin_bot/api.rb +2 -0
- data/lib/mixin_bot/utils.rb +1 -1
- data/lib/mixin_bot/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e4d9bbcd0cbf08f07745ac8efa3b587b2d99c45a47958f627261d15fca38a08
|
4
|
+
data.tar.gz: 1e0cc216622ff4cae2cb3ce9c5c58c213cde40648df8f2ad1f138f27471ef65a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10cbd356be328955dc03ec9c99d5cc9b0736004b5b120f75658555b7cb332112faff6f554f7d7055dc74ceced4cc1b3fb598d6b0e49127e315b7e2196e14bb15
|
7
|
+
data.tar.gz: f49139e817460192aba74027af8228cdf97bb8a4e2d7caf71adc3e4c9838f21b5a3a1029f9b8a02ca04c84b5e8770e4d8875605aeb40e0a212e510daf8414050
|
@@ -122,19 +122,6 @@ module MixinBot
|
|
122
122
|
client.get(path, headers: { 'Authorization': authorization })
|
123
123
|
end
|
124
124
|
|
125
|
-
# send a signed transaction to main net
|
126
|
-
def send_raw_transaction(raw, access_token: nil)
|
127
|
-
path = '/external/proxy'
|
128
|
-
payload = {
|
129
|
-
method: 'sendrawtransaction',
|
130
|
-
params: [raw]
|
131
|
-
}
|
132
|
-
|
133
|
-
access_token ||= access_token('POST', path, payload.to_json)
|
134
|
-
authorization = format('Bearer %<access_token>s', access_token: access_token)
|
135
|
-
client.post(path, headers: { 'Authorization': authorization }, json: payload)
|
136
|
-
end
|
137
|
-
|
138
125
|
def build_threshold_script(threshold)
|
139
126
|
s = threshold.to_s(16)
|
140
127
|
s = s.length == 1 ? "0#{s}" : s
|
@@ -236,7 +223,7 @@ module MixinBot
|
|
236
223
|
def build_output(receivers:, index:, amount:, threshold:, hint: nil)
|
237
224
|
_output = create_output receivers: receivers, index: index, hint: hint
|
238
225
|
{
|
239
|
-
amount:
|
226
|
+
amount: amount.to_f.round(8).to_s,
|
240
227
|
script: build_threshold_script(threshold),
|
241
228
|
mask: _output['mask'],
|
242
229
|
keys: _output['keys']
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MixinBot
|
4
|
+
class API
|
5
|
+
module Rpc
|
6
|
+
def rpc_proxy(method, params = [], access_token: nil)
|
7
|
+
path = '/external/proxy'
|
8
|
+
payload = {
|
9
|
+
method: method,
|
10
|
+
params: params
|
11
|
+
}
|
12
|
+
|
13
|
+
access_token ||= access_token('POST', path, payload.to_json)
|
14
|
+
authorization = format('Bearer %<access_token>s', access_token: access_token)
|
15
|
+
client.post(path, headers: { 'Authorization': authorization }, json: payload)
|
16
|
+
end
|
17
|
+
|
18
|
+
# send a signed transaction to main net
|
19
|
+
def send_raw_transaction(raw, access_token: nil)
|
20
|
+
rpc_proxy('sendrawtransaction', [raw], access_token: access_token)
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_transaction(hash, access_token: nil)
|
24
|
+
rpc_proxy('gettransaction', [hash], access_token: nil)
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_utxo(hash, index = 0, access_token: nil)
|
28
|
+
rpc_proxy 'getutxo', [hash, index], access_token: access_token
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_snapshot(hash, access_token: nil)
|
32
|
+
rpc_proxy 'getsnapshot', [hash], access_token: access_token
|
33
|
+
end
|
34
|
+
|
35
|
+
def list_snapshots(offset = 0, count = 10, sig = false, tx = false, access_token: nil)
|
36
|
+
rpc_proxy 'listsnapshots', [offset, count, sig, tx], access_token: access_token
|
37
|
+
end
|
38
|
+
|
39
|
+
def list_mint_works(offset = 0, access_token: nil)
|
40
|
+
rpc_proxy 'listmintworks', [offset], access_token: access_token
|
41
|
+
end
|
42
|
+
|
43
|
+
def list_mint_distributions(offset = 0, count = 10, tx = false, access_token: nil)
|
44
|
+
rpc_proxy 'listmintdistributions', [offset, count, tx], access_token: access_token
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/mixin_bot/api.rb
CHANGED
@@ -13,6 +13,7 @@ require_relative './api/message'
|
|
13
13
|
require_relative './api/multisig'
|
14
14
|
require_relative './api/payment'
|
15
15
|
require_relative './api/pin'
|
16
|
+
require_relative './api/rpc'
|
16
17
|
require_relative './api/snapshot'
|
17
18
|
require_relative './api/transaction'
|
18
19
|
require_relative './api/transfer'
|
@@ -86,6 +87,7 @@ module MixinBot
|
|
86
87
|
include MixinBot::API::Multisig
|
87
88
|
include MixinBot::API::Payment
|
88
89
|
include MixinBot::API::Pin
|
90
|
+
include MixinBot::API::Rpc
|
89
91
|
include MixinBot::API::Snapshot
|
90
92
|
include MixinBot::API::Transaction
|
91
93
|
include MixinBot::API::Transfer
|
data/lib/mixin_bot/utils.rb
CHANGED
@@ -358,7 +358,7 @@ module MixinBot
|
|
358
358
|
bytes += [0x00, type]
|
359
359
|
|
360
360
|
# amount
|
361
|
-
amount_bytes = bytes_of (output['amount'].to_f * 1e8).
|
361
|
+
amount_bytes = bytes_of (output['amount'].to_f * 1e8).round
|
362
362
|
bytes += encode_int amount_bytes.size
|
363
363
|
bytes += amount_bytes
|
364
364
|
|
data/lib/mixin_bot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mixin_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- an-lee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -286,6 +286,7 @@ files:
|
|
286
286
|
- lib/mixin_bot/api/multisig.rb
|
287
287
|
- lib/mixin_bot/api/payment.rb
|
288
288
|
- lib/mixin_bot/api/pin.rb
|
289
|
+
- lib/mixin_bot/api/rpc.rb
|
289
290
|
- lib/mixin_bot/api/snapshot.rb
|
290
291
|
- lib/mixin_bot/api/transaction.rb
|
291
292
|
- lib/mixin_bot/api/transfer.rb
|