Module: MixinBot::API::LegacyOutput

Included in:
MixinBot::API
Defined in:
lib/mixin_bot/api/legacy_output.rb

Instance Method Summary collapse

Instance Method Details

#build_output(receivers:, index:, amount:, threshold:, hint: nil) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/mixin_bot/api/legacy_output.rb', line 39

def build_output(receivers:, index:, amount:, threshold:, hint: nil)
  _output = create_output(receivers:, index:, hint:)
  {
    amount: format('%.8f', amount.to_d.to_r),
    script: build_threshold_script(threshold),
    mask: _output['mask'],
    keys: _output['keys']
  }
end

#create_output(receivers:, index:, hint: nil, access_token: nil) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/mixin_bot/api/legacy_output.rb', line 29

def create_output(receivers:, index:, hint: nil, access_token: nil)
  path = '/outputs'
  payload = {
    receivers:,
    index:,
    hint:
  }
  client.post path, **payload, access_token:
end

#legacy_outputs(**kwargs) ⇒ Object Also known as: multisigs, multisig_outputs



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/mixin_bot/api/legacy_output.rb', line 6

def legacy_outputs(**kwargs)
  limit = kwargs[:limit] || 100
  offset = kwargs[:offset] || ''
  state = kwargs[:state] || ''
  members = kwargs[:members] || []
  threshold = kwargs[:threshold] || ''
  access_token = kwargs[:access_token]
  members = SHA3::Digest::SHA256.hexdigest(members&.sort&.join)

  path = '/multisigs/outputs'
  params = {
    limit:,
    offset:,
    state:,
    members:,
    threshold:
  }.compact_blank

  client.get path, **params, access_token:
end