Class: Bytom::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/bytom/api/message.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Message

Returns a new instance of Message.



6
7
8
# File 'lib/bytom/api/message.rb', line 6

def initialize(client)
  @client = client
end

Instance Method Details

#sign_message(address:, message:, password:) ⇒ Hash

Sign a message with the key password(decode encrypted private key) of an address.

Parameters:

  • address (String)
  • message (String)
  • password (String)

Returns:

  • (Hash)

    signature, derived_xpub



37
38
39
40
41
42
43
44
45
# File 'lib/bytom/api/message.rb', line 37

def sign_message(address:, message:, password:)
  params = {
      address: address,
      message: message,
      password: password
  }
  p params
  client.make_request('/sign-message', 'post', params: params)
end

#verify_message(address:, derived_xpub:, message:, signature:) ⇒ Object

Verify a signed message with derived pubkey of the address.

Parameters:

  • address (String)
  • derived_xpub (String)
  • message (String)
  • signature (String)


18
19
20
21
22
23
24
25
26
# File 'lib/bytom/api/message.rb', line 18

def verify_message(address:, derived_xpub:, message:, signature:)
  params = {
      address: address,
      derived_xpub: derived_xpub,
      message: message,
      signature: signature
  }
  client.make_request('/verify-message', 'post', params: params)
end