-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathapi-docs.js
4699 lines (4691 loc) · 184 KB
/
api-docs.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
const { cloneDeep } = require('lodash');
const settings = require('./settings');
const packageJson = require('../package.json');
const commonExamples = {
xWalletIdErrResponseExamples: {
'no-wallet-id': {
summary: 'No wallet id parameter',
value: { success: false, message: "Parameter 'wallet-id' is required." }
},
'invalid-wallet-id': {
summary: 'Wallet id parameter is invalid',
value: { success: false, message: 'Invalid wallet-id parameter.' }
},
},
};
const nanoContractsDataParameter = {
type: 'object',
description: 'Data of the method for the nano contract.',
properties: {
actions: {
type: 'array',
items: {
type: 'object',
required: ['type', 'token', 'amount'],
properties: {
type: {
type: 'string',
description: 'Type of action: \'deposit\' or \'withdrawal\'.'
},
token: {
type: 'string',
description: 'Token of the action.'
},
amount: {
type: 'integer',
description: 'Amount to deposit or withdrawal.'
},
address: {
type: 'string',
description: 'Required for withdrawal, and it\'s the address to send the token to. For deposit is optional and it\'s the address to get the utxo from.'
},
changeAddress: {
type: 'string',
description: 'Address to send the change amount. Only used for deposit and it\'s optional.'
},
}
},
description: 'List of actions for the initialize method.'
},
args: {
type: 'array',
items: {
oneOf: [
{
type: 'string',
},
{
type: 'integer',
},
{
type: 'number',
},
{
type: 'boolean',
},
],
},
description: 'List of arguments for the method.'
},
}
};
// Default values for the API Docs
const defaultApiDocs = {
openapi: '3.0.0',
servers: [
{ url: 'http://localhost:8000' }
],
info: {
title: 'Headless Hathor Wallet API',
description: 'This wallet is fully controlled through an HTTP API.',
version: packageJson.version,
license: {
name: 'MIT',
url: 'https://github.com/HathorNetwork/hathor-wallet-headless/blob/master/LICENSE'
},
},
components: {
parameters: {
XWalletIdParameter: {
name: 'x-wallet-id',
in: 'header',
description: 'Defines the key of the wallet on which the request will be executed.',
required: true,
schema: {
type: 'string',
},
},
},
},
security: [],
paths: {
'/start': {
post: {
operationId: 'startWallet',
summary: 'Create and start a wallet and add to store.',
requestBody: {
description: 'Data to start the wallet',
required: true,
content: {
'application/json': {
schema: {
type: 'object',
required: ['wallet-id', 'seedKey'],
properties: {
'wallet-id': {
type: 'string',
description: 'Defines the key of wallet that future requests will need to use as a reference.'
},
passphrase: {
type: 'string',
description: 'Passphrase of the wallet that will be created.'
},
seedKey: {
type: 'string',
description: 'Key of the corresponding seed in the config file to create the wallet.'
},
seed: {
type: 'string',
description: '24-words seed separated with spaces. This parameter is incompatible with seedKey. Either seed or seedKey are required.'
},
xpubkey: {
type: 'string',
description: 'Account level xpubkey. This will be used to start wallet on readonly mode.',
},
multisig: {
type: 'boolean',
description: 'Start as a multisig wallet. Requires multisig configuration.'
},
multisigKey: {
type: 'string',
description: 'Key of the multisig wallet data in the config. This allow wallets to be started without a seedKey, e.g. with the seed on the parameters or from an xpubkey.',
},
scanPolicy: {
type: 'string',
enum: ['gap-limit', 'index-limit'],
description: 'Address scanning policy to use.',
default: 'gap-limit',
},
gapLimit: {
type: 'number',
description: 'Gap limit to use when scanning addresses. Only used when scanPolicy is set to \'gap-limit\'. If not given the configured default will apply.',
},
policyStartIndex: {
type: 'number',
description: 'Load addresses starting from this index. Only used when scanPolicy is set to \'index-limit\'.',
default: 0,
},
policyEndIndex: {
type: 'number',
description: 'Stop loading addresses at this index. Only used when scanPolicy is set to \'index-limit\'. Defaults to policyStartIndex',
},
historySyncMode: {
type: 'string',
enum: ['polling_http_api', 'xpub_stream_ws', 'manual_stream_ws'],
description: 'History sync mode for the wallet to use.',
default: 'polling_http_api',
},
}
},
examples: {
data: {
summary: 'Data to start the wallet',
value: {
'wallet-id': '123',
passphrase: 'Test',
seedKey: 'default'
}
}
}
}
}
},
responses: {
200: {
description: 'Start a wallet',
content: {
'application/json': {
examples: {
success: {
summary: 'Success',
value: { success: true },
},
'seed-not-found': {
summary: 'Seed key sent does not exist in config file.',
value: { success: false, message: 'Seed not found.' }
},
'no-wallet-id': {
summary: 'No wallet id parameter',
value: { success: false, message: "Parameter 'wallet-id' is required." }
},
'wallet-already-started': {
summary: 'Wallet with same id was already started.',
value: { success: false, message: 'Failed to start wallet with id X', errorCode: 'WALLET_ALREADY_STARTED' }
},
'start-failed': {
summary: 'Wallet failed to start.',
value: { success: false, message: 'Failed to start wallet with id X' }
},
},
},
},
},
},
},
},
'/hsm/start': {
post: {
operationId: 'hsmWalletStart',
summary: 'Create and start a read-only wallet through an HSM, then add it to store.',
requestBody: {
description: 'Data to start the wallet',
required: true,
content: {
'application/json': {
schema: {
type: 'object',
required: ['wallet-id', 'hsm-key'],
properties: {
'wallet-id': {
type: 'string',
description: 'Define the key of the corresponding wallet it will be executed the request.'
},
'hsm-key': {
type: 'string',
description: 'Key name containing the BIP32 xPriv on the HSM device.'
},
}
},
examples: {
data: {
summary: 'Data to start the wallet',
value: {
'wallet-id': 'hardware-wallet-1',
'hsm-key': 'hathor_wallet_1',
}
}
}
}
}
},
responses: {
200: {
description: 'Start a wallet',
content: {
'application/json': {
examples: {
success: {
summary: 'Success',
value: { success: true },
},
'no-wallet-id': {
summary: 'No wallet id parameter',
value: { success: false, message: "Parameter 'wallet-id' is required." }
},
'no-hsm-key': {
summary: 'No HSM key parameter',
value: { success: false, message: "Parameter 'hsm-key' is required." }
},
'hsm-key-invalid': {
summary: 'HSM key informed is not valid',
value: { success: false, message: `Informed 'hsm-key' is not a valid xPriv.` }
},
'start-failed': {
summary: 'Wallet failed to start.',
value: { success: false, message: 'Failed to start wallet with id X and key Y' }
},
'wallet-already-started': {
summary: 'Wallet with same id was already started.',
value: { success: false, message: 'Error starting wallet because this wallet-id is already in use. You must stop the wallet first.', errorCode: 'WALLET_ALREADY_STARTED' }
},
},
},
},
},
},
},
},
'/fireblocks/start': {
post: {
operationId: 'fireblocksWalletStart',
summary: 'Start a fireblocks client wallet on Hathor network.',
requestBody: {
description: 'Data to start the wallet',
required: true,
content: {
'application/json': {
schema: {
type: 'object',
required: ['wallet-id', 'xpub'],
properties: {
'wallet-id': {
type: 'string',
description: 'Define the key of the corresponding wallet it will be executed the request.'
},
xpub: {
type: 'string',
description: 'Fireblocks xPub derived to the Fireblocks account path (m/44/280/0).'
},
}
},
examples: {
data: {
summary: 'Data to start the wallet',
value: {
'wallet-id': 'hardware-wallet-1',
xpub: 'xpub...',
}
}
}
}
}
},
responses: {
200: {
description: 'Start a wallet',
content: {
'application/json': {
examples: {
success: {
summary: 'Success',
value: { success: true },
},
'no-wallet-id': {
summary: 'No wallet id parameter',
value: { success: false, message: "Parameter 'wallet-id' is required." }
},
'no-xpub': {
summary: 'No xPub parameter',
value: { success: false, message: "Parameter 'xpub' is required." }
},
'start-failed': {
summary: 'Wallet failed to start.',
value: { success: false, message: 'Failed to start wallet with id X' }
},
'wallet-already-started': {
summary: 'Wallet with same id was already started.',
value: { success: false, message: 'Failed to start wallet with id X', errorCode: 'WALLET_ALREADY_STARTED' }
},
'fireblocks-not-configured': {
summary: 'Missing Fireblocks client config.',
value: { success: false, message: 'Fireblocks client is not configured.' }
},
'fireblocks-invalid-xpub': {
summary: 'Fireblocks first address and local xPub first address do not match.',
value: { success: false, message: 'Fireblocks api generated a public key different from local public key.' }
},
'fireblocks-api-error': {
summary: 'Client raised an error when trying to connect to Fireblocks API.',
value: { success: false, message: 'Could not validate Fireblocks client config, received error: X' }
},
},
},
},
},
},
},
},
'/multisig-pubkey': {
post: {
operationId: 'getMultisigPubkey',
summary: 'Get MultiSig xpub for a seed.',
requestBody: {
description: '',
required: true,
content: {
'application/json': {
schema: {
type: 'object',
required: ['seedKey'],
properties: {
seedKey: {
type: 'string',
description: 'Key of the corresponding seed in the config file to create the wallet.'
},
passphrase: {
type: 'string',
description: 'Passphrase of the wallet.'
},
}
},
examples: {
data: {
summary: 'Get multisig for default seed',
value: {
seedKey: 'default',
passphrase: 'Test',
}
}
}
}
}
},
responses: {
200: {
description: 'Get MultiSig xpubkey',
content: {
'application/json': {
examples: {
success: {
summary: 'Success',
value: { success: true, xpubkey: 'xpub....' },
},
'seed-not-found': {
summary: 'Seed key sent does not exist in config file.',
value: { success: false, message: 'Seed not found.' }
},
},
},
},
},
},
}
},
'/wallet/status': {
get: {
operationId: 'getWalletStatus',
summary: 'Return the wallet status',
parameters: [
{ $ref: '#/components/parameters/XWalletIdParameter' },
],
responses: {
200: {
description: 'A JSON with general wallet info',
content: {
'application/json': {
examples: {
closed: {
summary: 'Wallet is closed',
value: { statusCode: 0, statusMessage: 'Closed', network: 'mainnet', serverUrl: 'https://node2.mainnet.hathor.network/v1a/', serverInfo: null }
},
connecting: {
summary: 'Wallet is connecting',
value: { statusCode: 1, statusMessage: 'Connecting', network: 'mainnet', serverUrl: 'https://node2.mainnet.hathor.network/v1a/', serverInfo: null }
},
syncing: {
summary: 'Wallet is syncing',
value: { statusCode: 2, statusMessage: 'Syncing', network: 'mainnet', serverUrl: 'https://node2.mainnet.hathor.network/v1a/', serverInfo: { version: '0.29.0', network: 'mainnet', min_weight: 14, min_tx_weight: 14, min_tx_weight_coefficient: 1.6, min_tx_weight_k: 100, token_deposit_percentage: 0.01 } }
},
ready: {
summary: 'Wallet is ready',
value: { statusCode: 3, statusMessage: 'Ready', network: 'mainnet', serverUrl: 'https://node2.mainnet.hathor.network/v1a/', serverInfo: { version: '0.29.0', network: 'mainnet', min_weight: 14, min_tx_weight: 14, min_tx_weight_coefficient: 1.6, min_tx_weight_k: 100, token_deposit_percentage: 0.01 } }
},
'wallet-not-ready': {
summary: 'Wallet is not ready yet',
value: { success: false, message: 'Wallet is not ready.', state: 1 }
},
...commonExamples.xWalletIdErrResponseExamples,
},
},
},
},
},
},
},
'/wallet/balance': {
get: {
operationId: 'getWalletBalance',
summary: 'Return the balance of HTR',
parameters: [
{ $ref: '#/components/parameters/XWalletIdParameter' },
{
name: 'token',
in: 'query',
description: 'Token uid. Optional parameter to get the balance from a token different than HTR.',
required: false,
schema: {
type: 'string',
},
},
],
responses: {
200: {
description: 'Balance of tokens available and locked. To get the total, you must sum them up.',
content: {
'application/json': {
examples: {
success: {
summary: 'Success',
value: { available: 2, locked: 0 }
},
'wallet-not-ready': {
summary: 'Wallet is not ready yet',
value: { success: false, message: 'Wallet is not ready.', state: 1 }
},
...commonExamples.xWalletIdErrResponseExamples,
},
},
},
},
},
},
},
'/wallet/address': {
get: {
operationId: 'getCurrentAddress',
summary: 'Return the current address',
parameters: [
{ $ref: '#/components/parameters/XWalletIdParameter' },
{
name: 'mark_as_used',
in: 'query',
description: 'Mark the current address as used. So, it will return a new address in the next call.',
required: false,
schema: {
type: 'boolean',
},
},
{
name: 'index',
in: 'query',
description: 'Get the address in this specific derivation path index.',
required: false,
schema: {
type: 'integer',
},
},
],
responses: {
200: {
description: 'Return the current address',
content: {
'application/json': {
examples: {
success: {
summary: 'Success',
value: { address: 'H8bt9nYhUNJHg7szF32CWWi1eB8PyYZnbt' }
},
'wallet-not-ready': {
summary: 'Wallet is not ready yet',
value: { success: false, message: 'Wallet is not ready.', state: 1 }
},
...commonExamples.xWalletIdErrResponseExamples,
},
},
},
},
},
},
},
'/wallet/address-index': {
get: {
operationId: 'getAddressIndex',
summary: 'Get the index of an address',
parameters: [
{ $ref: '#/components/parameters/XWalletIdParameter' },
{
name: 'address',
in: 'query',
description: 'Address to get the index.',
required: true,
schema: {
type: 'string',
},
},
],
responses: {
200: {
description: 'Return the index of the address.',
content: {
'application/json': {
examples: {
success: {
summary: 'Success',
value: { index: 2, success: true },
},
error: {
summary: 'Address does not belong to the wallet',
value: { success: false },
},
'wallet-not-ready': {
summary: 'Wallet is not ready yet',
value: { success: false, message: 'Wallet is not ready.', state: 1 }
},
...commonExamples.xWalletIdErrResponseExamples,
},
},
},
},
},
},
},
'/wallet/addresses': {
get: {
operationId: 'getAddresses',
summary: 'Return all generated addresses of the wallet.',
parameters: [
{ $ref: '#/components/parameters/XWalletIdParameter' },
],
responses: {
200: {
description: 'Return the addresses',
content: {
'application/json': {
examples: {
success: {
summary: 'Success',
value: { addresses: ['H8bt9nYhUNJHg7szF32CWWi1eB8PyYZnbt', 'HPxB4dKccUWbECh1XMWPEgZVZP2EC34BbB'] }
},
'wallet-not-ready': {
summary: 'Wallet is not ready yet',
value: { success: false, message: 'Wallet is not ready.', state: 1 }
},
...commonExamples.xWalletIdErrResponseExamples,
},
},
},
},
},
},
},
'/wallet/simple-send-tx': {
post: {
operationId: 'simpleSendTx',
summary: 'Send a transaction to exactly one output.',
parameters: [
{ $ref: '#/components/parameters/XWalletIdParameter' },
],
requestBody: {
description: 'Data to create the transaction',
required: true,
content: {
'application/json': {
schema: {
type: 'object',
required: ['address', 'value'],
properties: {
address: {
type: 'string',
description: 'Address to send the tokens.'
},
value: {
type: 'integer',
description: 'The value parameter must be an integer with the value in cents, i.e., 123 means 1.23 HTR.'
},
token: {
type: 'string',
description: 'Token uid to send the transaction, just in case is not HTR.',
},
'token [DEPRECATED]': {
type: 'object',
required: ['uid', 'name', 'symbol'],
description: '[DEPRECATED] Token to send the transaction, just in case is not HTR. This parameter is old and still works for compatibility reasons but will be removed soon, you should use the string format.',
properties: {
uid: {
type: 'string',
description: 'UID of the custom token to send the transaction.'
},
name: {
type: 'string',
description: 'Name of the custom token to send the transaction.'
},
symbol: {
type: 'string',
description: 'Symbol of the custom token to send the transaction.'
},
}
},
change_address: {
type: 'string',
description: 'Optional address to send the change amount.'
},
}
},
examples: {
data: {
summary: 'Data to create the transaction',
value: {
address: 'Wk2j7odPbC4Y98xKYBCFyNogxaRimU6BUj',
value: 100,
token: '006e18f3c303892076a12e68b5c9c30afe9a96a528f0f3385898001858f9c35d'
}
}
}
}
}
},
responses: {
200: {
description: 'Send a transaction',
content: {
'application/json': {
examples: {
error: {
summary: 'Insuficient amount of tokens',
value: { success: false, error: 'Token HTR: Insufficient amount of tokens' }
},
success: {
summary: 'Success',
value: { success: true, message: '', tx: { hash: '00001bc7043d0aa910e28aff4b2aad8b4de76c709da4d16a48bf713067245029', nonce: 33440807, timestamp: 1579656120, version: 1, weight: 16.827294220302488, parents: ['000036e846dee9f58a724543cf5ee14cf745286e414d8acd9563963643f8dc34', '000000fe2da5f4cc462e8ccaac8703a38cd6e4266e227198f003dd5c68092d29'], inputs: [{ tx_id: '000000fe2da5f4cc462e8ccaac8703a38cd6e4266e227198f003dd5c68092d29', index: 0, data: 'RzBFAiEAyKKbtzdH7FjvjUopHFIXBf+vBcH+2CKirp0mEnLjjvMCIA9iSuW4B/UJMQld+c4Ch5lIwAcTbzisNUaCs+JpK8yDIQI2CLavb5spKwIEskxaVu0B2Tp52BXas3yjdX1XeMSGyw==' }], outputs: [{ value: 1, token_data: 0, script: 'dqkUtK1DlS8IDGxtJBtRwBlzFWihbIiIrA==' }], tokens: [] } }
},
'wallet-not-ready': {
summary: 'Wallet is not ready yet',
value: { success: false, message: 'Wallet is not ready.', state: 1 }
},
...commonExamples.xWalletIdErrResponseExamples,
},
},
},
},
},
},
},
'/wallet/decode': {
post: {
operationId: 'decodeTx',
summary: 'Decode tx hex or serialized partial tx into human readable inputs and outputs with metadata to assist informed decision-making. To obtain input metadata, this method retrieves a transaction per input from the wallet\'s transaction history. If the required transaction is not located, the method queries the fullnode for the transaction details.',
requestBody: {
description: 'Transaction hex representation or a partial transaction serialization.',
required: true,
content: {
'application/json': {
schema: {
type: 'object',
properties: {
txHex: {
type: 'string',
description: 'Hex format of a Transaction instance.'
},
partial_tx: {
type: 'string',
description: 'Serialized PartialTx instance.',
},
}
},
}
}
},
responses: {
200: {
description: 'Decode a transaction from its hex',
content: {
'application/json': {
examples: {
success: {
summary: 'Success',
value: {
success: true,
tx: {
completeSignatures: false,
tokens: [],
outputs: [
{
decoded: {
address: 'Wk2j7odPbC4Y98xKYBCFyNogxaRimU6BUj',
timelock: null,
},
token: '00',
value: 100,
tokenData: 0,
token_data: 0,
script: 'dqkUISAnpOn9Vo269QBvOfBeWJTLx82IrA==',
type: 'p2sh',
mine: true,
}
],
inputs: [
{
decoded: {
type: 'MultiSig',
address: 'Wk2j7odPbC4Y98xKYBCFyNogxaRimU6BUj',
timelock: null,
},
txId: '006e18f3c303892076a12e68b5c9c30afe9a96a528f0f3385898001858f9c35d',
index: 0,
token: '00',
value: 100,
tokenData: 0,
token_data: 0,
script: 'dqkUISAnpOn9Vo269QBvOfBeWJTLx82IrA==',
signed: false,
mine: true,
}
]
},
balance: {
'00': {
tokens: { available: 0, locked: 0 },
authorities: {
melt: { available: 0, locked: 0 },
mint: { available: 0, locked: 0 },
},
},
},
},
},
},
},
},
},
},
},
},
'/wallet/utxos-selected-as-input': {
put: {
operationId: 'utxosSelectedAsInput',
summary: 'Mark or unmark the inputs of a given transaction as selected as inputs on the storage. This prevents the inputs from being chosen by another transaction.',
requestBody: {
description: 'Transaction hex representation.',
required: true,
content: {
'application/json': {
schema: {
type: 'object',
properties: {
txHex: {
type: 'string',
description: 'Hex format of a Transaction instance.'
},
}
},
}
}
},
responses: {
200: {
description: 'Mark the inputs from the given transaction',
content: {
'application/json': {
examples: {
success: {
summary: 'Success',
value: {
success: true,
},
},
},
},
},
},
},
},
},
'/wallet/tx-proposal': {
post: {
operationId: 'createTxProposal',
summary: 'Build a transaction with many outputs without sending. Will not include signatures.',
parameters: [
{ $ref: '#/components/parameters/XWalletIdParameter' },
],
requestBody: {
description: 'Data to create the transaction',
required: true,
content: {
'application/json': {
schema: {
type: 'object',
required: ['outputs'],
properties: {
outputs: {
type: 'array',
items: {
type: 'object',
properties: {
address: {
type: 'string',
description: 'Destination address of the output. Required if P2PKH or P2SH.'
},
value: {
type: 'integer',
description: 'The value parameter must be an integer with the value in cents, i.e., 123 means 1.23 HTR. Required if P2PKH or P2SH.'
},
token: {
type: 'string',
description: 'Token id of the output. If not sent, HTR will be chosen.'
},
type: {
type: 'string',
description: 'Type of output script. Required if data script and expected to be "data".'
},
data: {
type: 'string',
description: 'Data string of the data script output. Required if it\'s a data script output.'
},
}
},
description: 'Outputs to create the transaction.'
},
inputs: {
type: 'array',
items: {
type: 'object',
properties: {
hash: {
type: 'string',
description: 'Hash of the transaction being spent in this input. Used if not type query.'
},
index: {
type: 'integer',
description: 'Index of the output being spent in this input. Used if not type query.'
},
type: {
type: 'string',
description: 'Type of input object. Can be \'query\' only for now.'
},
max_utxos: {
type: 'integer',
description: 'Maximum number of utxos to filter in the query. Optional query parameter when using type query.'
},
token: {
type: 'string',
description: 'Token uid to filter utxos in the query. Optional query parameter when using type query.'
},
filter_address: {
type: 'string',
description: 'Address to filter utxos in the query. Optional query parameter when using type query.'
},
amount_smaller_than: {
type: 'integer',
description: 'Filter only utxos with value smaller than this. Optional query parameter when using type query.'
},
amount_bigger_than: {
type: 'integer',
description: 'Filter only utxos with value bigger than this. Optional query parameter when using type query.'
},
}
},
description: 'Inputs to create the transaction.'
},
change_address: {
type: 'string',
description: 'Optional address to send the change amount.'
},
}
},
examples: {
data: {
summary: 'Data to create the transaction',
value: {
outputs: [
{
address: 'Wk2j7odPbC4Y98xKYBCFyNogxaRimU6BUj',
value: 100,
token: '006e18f3c303892076a12e68b5c9c30afe9a96a528f0f3385898001858f9c35d'
}
],
inputs: [
{
hash: '006e18f3c303892076a12e68b5c9c30afe9a96a528f0f3385898001858f9c35d',
index: 0,
}
]
}
},
dataQuery: {
summary: 'Data to create the transaction with query input',
value: {
outputs: [
{
address: 'Wk2j7odPbC4Y98xKYBCFyNogxaRimU6BUj',
value: 100
}
],
inputs: [
{
type: 'query',
filter_address: 'Wk2j7odPbC4Y98xKYBCFyNogxaRimU6BUj',
}
],
}
},
dataScript: {
summary: 'Transaction with a data script output',
value: {
outputs: [
{
address: 'Wk2j7odPbC4Y98xKYBCFyNogxaRimU6BUj',
value: 100,
token: '006e18f3c303892076a12e68b5c9c30afe9a96a528f0f3385898001858f9c35d'
}, {
type: 'data',
data: 'test'
}
],
}
}
}
}
}
},
responses: {
200: {
description: 'Send a transaction with many outputs',
content: {
'application/json': {
examples: {
error: {
summary: 'Insuficient amount of tokens',