-
Notifications
You must be signed in to change notification settings - Fork 0
/
getUTXO.js
executable file
·101 lines (96 loc) · 3.02 KB
/
getUTXO.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
const Validator = require('../../utils/Validator');
const argsSchema = require('../schemas/addresses');
const validator = new Validator(argsSchema);
/**
* @param coreAPI
* @return {getUTXO}
*/
const getUTXOFactory = (coreAPI) => {
/**
* Layer 1 endpoint
* Returns unspent outputs for the given address
* @typedef getUTXO
* @param args
* @param {string|string[]} args.address
* @param {number} args.from
* @param {number} args.to
* @param {number} args.fromHeight
* @param {number} args.toHeight
* @return {Promise<Array<Object>>}
*/
async function getUTXO(args) {
validator.validate(args);
const {
address, from, to, fromHeight, toHeight,
} = args;
return coreAPI.getUTXO(address, from, to, fromHeight, toHeight);
}
return getUTXO;
};
/* eslint-disable max-len */
/**
* @swagger
* /getUTXO:
* post:
* operationId: getUTXO
* deprecated: false
* summary: getUTXO
* description: Returns unspent outputs for the given address
* tags:
* - L1
* responses:
* 200:
* description: Successful response. Promise (object) containing unspent transaction objects.
* requestBody:
* content:
* application/json:
* schema:
* type: object
* required:
* - method
* - id
* - jsonrpc
* - params
* properties:
* method:
* type: string
* default: getUTXO
* description: Method name
* id:
* type: integer
* default: 1
* format: int32
* description: Request ID
* jsonrpc:
* type: string
* default: '2.0'
* description: JSON-RPC Version (2.0)
* params:
* title: Parameters
* type: object
* required:
* - address
* properties:
* address:
* oneOf:
* - type: string
* description: Axe address
* - type: array
* items:
* type: string
* description: Array of Axe addresses
* from:
* type: integer
* description: Start of range in the ordered list of latest UTXO
* to:
* type: integer
* description: End of range in the ordered list of latest UTXO
* fromHeight:
* type: integer
* description: Lowest block height to include
* toHeight:
* type: integer
* description: Block height to end on
*/
/* eslint-enable max-len */
module.exports = getUTXOFactory;