Class: Bytom::Keys
- Inherits:
-
Object
- Object
- Bytom::Keys
- Defined in:
- lib/bytom/api/keys.rb
Instance Method Summary collapse
-
#check_key_password(xpub:, password:) ⇒ Hash
Check key password.
-
#create_key(alias_name:, password:, language: 'en', mnemonic: nil) ⇒ Hash
It is to create private key essentially, returns the information of key.
-
#delete_key(xpub:, password:) ⇒ nil
Delete existed key, please make sure that there is no balance in the related accounts.
-
#initialize(client) ⇒ Keys
constructor
A new instance of Keys.
-
#list_keys ⇒ Hash
Returns the list of all available keys.
-
#list_pubkeys(account_alias: nil, account_id: nil, public_key: nil) ⇒ Hash
Returns the list of all available pubkeys by account.
-
#reset_key_password(xpub:, old_password:, new_password:) ⇒ Hash
Reset key password.
-
#update_key_alias(xpub:, new_alias:) ⇒ nil
Update alias for the existed key.
Constructor Details
#initialize(client) ⇒ Keys
Returns a new instance of Keys.
8 9 10 |
# File 'lib/bytom/api/keys.rb', line 8 def initialize(client) @client = client end |
Instance Method Details
#check_key_password(xpub:, password:) ⇒ Hash
Check key password.
81 82 83 84 85 86 87 |
# File 'lib/bytom/api/keys.rb', line 81 def check_key_password(xpub:, password:) params = { xpub: xpub, password: password } client.make_request('/check-key-password', 'post', params: params) end |
#create_key(alias_name:, password:, language: 'en', mnemonic: nil) ⇒ Hash
It is to create private key essentially, returns the information of key. The private key is encrypted in the file and not visible to the user.
22 23 24 25 26 27 28 29 30 |
# File 'lib/bytom/api/keys.rb', line 22 def create_key(alias_name:, password:, language: 'en', mnemonic: nil) params = { alias: alias_name, password: password, language: language, mnemonic: nil } client.make_request('/create-key', 'post', params: params) end |
#delete_key(xpub:, password:) ⇒ nil
Delete existed key, please make sure that there is no balance in the related accounts.
65 66 67 68 69 70 71 |
# File 'lib/bytom/api/keys.rb', line 65 def delete_key(xpub:, password:) params = { xpub: xpub, password: password } client.make_request('/delete-key', 'post', params: params) end |
#list_keys ⇒ Hash
Returns the list of all available keys.
37 38 39 |
# File 'lib/bytom/api/keys.rb', line 37 def list_keys client.make_request('/list-keys', 'get') end |
#list_pubkeys(account_alias: nil, account_id: nil, public_key: nil) ⇒ Hash
Returns the list of all available pubkeys by account.
116 117 118 119 120 121 122 |
# File 'lib/bytom/api/keys.rb', line 116 def list_pubkeys(account_alias: nil, account_id: nil, public_key: nil) params = {} params = {account_alias: account_alias} if account_alias params = {account_id: account_id} if account_id #params = {public_key: public_key} if public_key client.make_request('/list-pubkeys', 'post', params: params) end |
#reset_key_password(xpub:, old_password:, new_password:) ⇒ Hash
Reset key password.
98 99 100 101 102 103 104 105 |
# File 'lib/bytom/api/keys.rb', line 98 def reset_key_password(xpub:, old_password:, new_password:) params = { xpub: xpub, old_password: old_password, new_password: new_password } client.make_request('/reset-key-password', 'post', params: params) end |
#update_key_alias(xpub:, new_alias:) ⇒ nil
Update alias for the existed key.
49 50 51 52 53 54 55 |
# File 'lib/bytom/api/keys.rb', line 49 def update_key_alias(xpub:, new_alias:) params = { xpub: xpub, new_alias: new_alias } client.make_request('/update-key-alias', 'post', params: params) end |