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) {
58 this.connection.request('/create-account', {
66 * List accounts whose id starts with the given id.
68 * @param {module:AccountsApi~id} id - Account id prefix.
69 * @return {Promise<Response>} target accounts response.
72 this.connection.request('/list-accounts', {id})
76 * Create account receiver.
78 * @param {module:AccountsApi~id} accountId - Id for the target account.
79 * @return {Promise<Response>} target receiver response.
81 createReceiverById(accountId) {
82 this.connection.request('/create-account-receiver', {
88 * List all addresses for one account.
89 * @param {module:AccountsApi~id} accountId - Id for the target account.
90 * @return {Promise<Response>} target addresses response.
92 listAddressesById(accountId) {
93 this.connection.request('/list-addresses', {
100 * @param {module:AccountsApi~id} id - Target account id.
103 this.connection.request('/delete-account', {
110 export default Accounts