2 * An account is an object in Bytom that tracks ownership of assets on a
5 * @typedef {Object} Account
8 * @property {String} id
9 * Unique account identifier in one Bytom node.
11 * @property {String} alias
12 * User specified, unique identifier in one Bytom node.
14 * @property {Key[]} keys
15 * The list of keys used to create control programs under the account.
16 * Signatures from these keys are required for spending funds held in the account.
18 * @property {Number} quorum
19 * The number of keys required to sign transactions for the account.
23 * API for interacting with {@link Account accounts}.
27 const Accounts = (connection) => {
29 * @typedef {String[]} xpubs
30 * The list of keys used to create control programs under the account.
34 * @typedef {String} [alias]
35 * User specified, unique identifier.
39 * @typedef {Number} quorum
40 * The number of keys required to sign transactions for the account.
44 * @typedef {String} id
45 * Unique account identifier in one Bytom node.
50 * Create a new account.
52 * @param {module:AccountsApi~xpubs} xpubs - Keys for account creation.
53 * @param {module:AccountsApi~quorum} quorum - The number of keys required to sign transactions for the account.
54 * @param {module:AccountsApi~alias} alias - Account alias.
55 * @returns {Promise<Response>} Newly created account response.
57 create: (xpubs, quorum, alias) => connection.request('/create-account', {
64 * List accounts whose id starts with the given id.
66 * @param {module:AccountsApi~id} id - Account id prefix.
67 * @return {Promise<Response>} target accounts response.
69 listAccounts: (id) => connection.request('/list-accounts', {id}),
72 * Create account receiver.
74 * @param {module:AccountsApi~id} accountId - Id for the target account.
75 * @return {Promise<Response>} target receiver response.
77 createReceiverById: (accountId) => connection.request('/create-account-receiver', {account_id: accountId}),
80 * List all addresses for one account.
81 * @param {module:AccountsApi~id} accountId - Id for the target account.
82 * @return {Promise<Response>} target addresses response.
84 listAddressesById: (accountId) => connection.request('/list-addresses', {account_id: accountId}),
88 * @param {module:AccountsApi~id} id - Target account id.
90 deleteById: (id) => connection.request('/delete-account', {account_info: id})
94 export default Accounts