2 * Each new transaction in the blockchain consumes some unspent outputs and
3 * creates others. An output is considered unspent when it has not yet been used
4 * as an input to a new transaction. All asset units on a blockchain exist in
5 * the unspent output set.
7 * @typedef {Object} UnspentOutput
10 * @property {String} account_alias
11 * The alias of the account transferring the asset (possibly null).
13 * @property {String} account_id
14 * The id of the account transferring the asset (possibly null).
16 * @property {String} address
19 * @property {String} id
20 * Unique transaction identifier.
22 * @property {Number} amount
23 * The number of units of the asset being issued or spent.
25 * @property {String} asset_alias
26 * The alias of the asset being issued or spent (possibly null).
28 * @property {String} asset_id
29 * The id of the asset being issued or spent.
31 * @property {Number} source_pos
32 * The output's position in a transaction's list of outputs.
34 * @property {Boolean} change
35 * Whether this output is asset change of one spend.
37 * @property {Number} control_program_index
38 * Control program index.
40 * @property {String} program
41 * The control program which must be satisfied to transfer this output.
43 * @property {String} source_id
44 * The source unspent output id.
46 * @property {Number} valid_height
47 * It means coinbase utxo if valid_height > 0.
51 * API for interacting with {@link UnspentOutput unspent outputs}.
53 * @module UnspentOutputsApi
55 const unspentOutputsAPI = (connection) => {
58 * Get all unspent outputs.
59 * @returns {Promise<Array<UnspentOutput>>} Target unspent outputs.
61 listAll: () => connection.request('/list-unspent-outputs', {}),
64 * Get target unspent outputs.
66 * @param {Object} params={} - Filter and pagination information.
67 * @param {String} params.id - Unspent output id.
68 * @param {Boolean} params.unconfirmed, is include unconfirmed utxo
69 * @param {Boolean} params.smart_contract, is contract utxo
70 * @param {Integer} params.from, the start position of first utxo
71 * @param {Integer} params.count, the number of returned
72 * @param {String} params.account_id, account id.
73 * @param {String} params.account_alias, name of account.
74 * @returns {Promise<Array<UnspentOutput>>} Target unspent outputs.
76 list: (params) => connection.request('list-unspent-outputs', params)
80 export default unspentOutputsAPI