Module: MixinBot::API::Tip

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

Constant Summary collapse

TIP_ACTIONS =
%w[
  TIP:VERIFY:
  TIP:ADDRESS:ADD:
  TIP:ADDRESS:REMOVE:
  TIP:USER:DEACTIVATE:
  TIP:EMERGENCY:CONTACT:CREATE:
  TIP:EMERGENCY:CONTACT:READ:
  TIP:EMERGENCY:CONTACT:REMOVE:
  TIP:PHONE:NUMBER:UPDATE:
  TIP:MULTISIG:REQUEST:SIGN:
  TIP:MULTISIG:REQUEST:UNLOCK:
  TIP:COLLECTIBLE:REQUEST:SIGN:
  TIP:COLLECTIBLE:REQUEST:UNLOCK:
  TIP:TRANSFER:CREATE:
  TIP:WITHDRAWAL:CREATE:
  TIP:TRANSACTION:CREATE:
  TIP:OAUTH:APPROVE:
  TIP:PROVISIONING:UPDATE:
  TIP:APP:OWNERSHIP:TRANSFER:
  SEQUENCER:REGISTER:
].freeze

Instance Method Summary collapse

Instance Method Details

#encrypt_tip_pin(pin, action, *params) ⇒ Object

Raises:



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/mixin_bot/api/tip.rb', line 28

def encrypt_tip_pin(pin, action, *params)
  raise ArgumentError, 'invalid action' unless TIP_ACTIONS.include? action

  pin_key = MixinBot.utils.decode_key pin

  msg = action + params.flatten.map(&:to_s).join

  msg = Digest::SHA256.digest(msg) unless action == 'TIP:VERIFY:'

  signature = JOSE::JWA::Ed25519.sign msg, pin_key

  encrypt_pin signature
end