Class: Bytom::Accounts
- Inherits:
-
Object
- Object
- Bytom::Accounts
- Defined in:
- lib/bytom/api/accounts.rb
Instance Method Summary collapse
-
#create_account(root_xpubs: [], alias_name:, quorum: 1, access_token: nil) ⇒ Hash
Create account to manage addresses.
-
#create_account_receiver(account_id: nil, account_alias: nil) ⇒ Hash
create address and control program, the address and control program is are one to one relationship.
-
#delete_account_by_alias(account_alias:) ⇒ Nil
Delete existed account by account alias, please make sure that there is no balance in the related addresses.
-
#delete_account_by_id(account_id:) ⇒ Nil
Delete existed account by account id, please make sure that there is no balance in the related addresses.
-
#initialize(client) ⇒ Accounts
constructor
A new instance of Accounts.
-
#list_accounts(id: nil, alias_name: nil) ⇒ Hash
Returns the list of all available accounts.
-
#update_account_alias_by_alias(account_alias:, new_alias:) ⇒ Nil
By account alias to update alias for the existed account.
-
#update_account_alias_by_id(account_id:, new_alias:) ⇒ nil
By account id to update alias for the existed account.
Constructor Details
#initialize(client) ⇒ Accounts
Returns a new instance of Accounts.
6 7 8 |
# File 'lib/bytom/api/accounts.rb', line 6 def initialize(client) @client = client end |
Instance Method Details
#create_account(root_xpubs: [], alias_name:, quorum: 1, access_token: nil) ⇒ Hash
Create account to manage addresses. single sign account contain only one root_xpubs and quorum; however multi sign account contain many number of root_xpubs and quorum, quorum is the number of verify signature, the range is [1, len(root_xpubs)].
20 21 22 23 24 25 26 27 28 |
# File 'lib/bytom/api/accounts.rb', line 20 def create_account(root_xpubs:[], alias_name:, quorum: 1, access_token: nil) params = { root_xpubs: root_xpubs, alias: alias_name, quorum: quorum, access_token: access_token } client.make_request('/create-account', 'post', params: params) end |
#create_account_receiver(account_id: nil, account_alias: nil) ⇒ Hash
create address and control program, the address and control program is are one to one relationship. in build-transaction API, receiver is address when action type is control_address, and receiver is control program when action type is control_program, they are the same result.
103 104 105 106 107 108 109 |
# File 'lib/bytom/api/accounts.rb', line 103 def create_account_receiver(account_id: nil, account_alias: nil ) params = {} params = { account_id: account_id } if account_id params = { account_alias: account_alias } if account_alias return {status: 'failed'} if not params client.make_request('/create-account-receiver', 'post', params: params) end |
#delete_account_by_alias(account_alias:) ⇒ Nil
Delete existed account by account alias, please make sure that there is no balance in the related addresses.
91 92 93 |
# File 'lib/bytom/api/accounts.rb', line 91 def delete_account_by_alias(account_alias:) client.make_request('/delete-account', 'post', params: {account_alias: account_alias}) end |
#delete_account_by_id(account_id:) ⇒ Nil
Delete existed account by account id, please make sure that there is no balance in the related addresses.
81 82 83 |
# File 'lib/bytom/api/accounts.rb', line 81 def delete_account_by_id(account_id:) client.make_request('/delete-account', 'post', params: {account_id: account_id}) end |
#list_accounts(id: nil, alias_name: nil) ⇒ Hash
Returns the list of all available accounts.
35 36 37 38 39 40 |
# File 'lib/bytom/api/accounts.rb', line 35 def list_accounts(id: nil, alias_name:nil) params = {} params = {id: id} if id params = {alias: alias_name} if alias_name client.make_request('/list-accounts', 'post', params: params) end |
#update_account_alias_by_alias(account_alias:, new_alias:) ⇒ Nil
By account alias to update alias for the existed account.
66 67 68 69 70 71 72 |
# File 'lib/bytom/api/accounts.rb', line 66 def update_account_alias_by_alias(account_alias:, new_alias:) params = { account_alias: account_alias, new_alias: new_alias } client.make_request('/update-account-alias', 'post', params: params) end |
#update_account_alias_by_id(account_id:, new_alias:) ⇒ nil
By account id to update alias for the existed account.
50 51 52 53 54 55 56 |
# File 'lib/bytom/api/accounts.rb', line 50 def update_account_alias_by_id(account_id:, new_alias:) params = { account_id: account_id, new_alias: new_alias } client.make_request('/update-account-alias', 'post', params: params) end |