-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathargparse.js
More file actions
2284 lines (2176 loc) · 69.6 KB
/
argparse.js
File metadata and controls
2284 lines (2176 loc) · 69.6 KB
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
/* @flow */
const Ajv = require('ajv');
const process = require('process');
const c32check = require('c32check');
import os from 'os';
import fs from 'fs';
export const NAME_PATTERN =
'^([0-9a-z_.+-]{3,37})$'
export const NAMESPACE_PATTERN =
'^([0-9a-z_-]{1,19})$'
export const ADDRESS_CHARS =
'[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{1,35}';
export const C32_ADDRESS_CHARS = '[0123456789ABCDEFGHJKMNPQRSTVWXYZ]+';
export const ADDRESS_PATTERN = `^(${ADDRESS_CHARS})$`;
export const ID_ADDRESS_PATTERN = `^ID-${ADDRESS_CHARS}$`;
export const STACKS_ADDRESS_PATTERN = `^(${C32_ADDRESS_CHARS})$`;
// hex private key
export const PRIVATE_KEY_PATTERN =
'^([0-9a-f]{64,66})$';
// hex private key, no compression
export const PRIVATE_KEY_UNCOMPRESSED_PATTERN =
'^([0-9a-f]{64})$';
// m,pk1,pk2,...,pkn
export const PRIVATE_KEY_MULTISIG_PATTERN =
'^([0-9]+),([0-9a-f]{64,66},)*([0-9a-f]{64,66})$';
// segwit:p2sh:m,pk1,pk2,...,pkn
export const PRIVATE_KEY_SEGWIT_P2SH_PATTERN =
`^segwit:p2sh:([0-9]+),([0-9a-f]{64,66},)*([0-9a-f]{64,66})$`;
// any private key pattern we support
export const PRIVATE_KEY_PATTERN_ANY =
`${PRIVATE_KEY_PATTERN}|${PRIVATE_KEY_MULTISIG_PATTERN}|${PRIVATE_KEY_SEGWIT_P2SH_PATTERN}`;
export const PUBLIC_KEY_PATTERN =
'^([0-9a-f]{66,130})$'
export const INT_PATTERN = '^-?[0-9]+$'
export const ZONEFILE_HASH_PATTERN = '^([0-9a-f]{40})$'
export const URL_PATTERN = "^http[s]?://.+$"
export const SUBDOMAIN_PATTERN =
'^([0-9a-z_+-]{1,37})\.([0-9a-z_.+-]{3,37})$'
export const TXID_PATTERN =
'^([0-9a-f]{64})$'
export const PATH_PATTERN = '^[/]+.+$'
export const BOOLEAN_PATTERN = '^(0|1|true|false)$'
const LOG_CONFIG_DEFAULTS = {
level: 'warn',
handleExceptions: true,
timestamp: true,
stringify: true,
colorize: true,
json: true
}
const CONFIG_DEFAULTS = {
blockstackAPIUrl: 'https://core.blockstack.org',
blockstackNodeUrl: 'https://node.blockstack.org:6263',
broadcastServiceUrl: 'https://broadcast.blockstack.org',
utxoServiceUrl: 'https://blockchain.info',
logConfig: LOG_CONFIG_DEFAULTS
};
const CONFIG_REGTEST_DEFAULTS = {
blockstackAPIUrl: 'http://localhost:16268',
blockstackNodeUrl: 'http://localhost:16264',
broadcastServiceUrl: 'http://localhost:16269',
utxoServiceUrl: 'http://localhost:18332',
logConfig: LOG_CONFIG_DEFAULTS
};
const PUBLIC_TESTNET_HOST = 'testnet.blockstack.org';
const CONFIG_TESTNET_DEFAULTS = {
blockstackAPIUrl: `http://${PUBLIC_TESTNET_HOST}:16268`,
blockstackNodeUrl: `http://${PUBLIC_TESTNET_HOST}:16264`,
broadcastServiceUrl: `http://${PUBLIC_TESTNET_HOST}:16269`,
utxoServiceUrl: `http://${PUBLIC_TESTNET_HOST}:18332`,
logConfig: Object.assign({}, LOG_CONFIG_DEFAULTS, { level: 'debug' })
};
export const DEFAULT_CONFIG_PATH = '~/.blockstack-cli.conf'
export const DEFAULT_CONFIG_REGTEST_PATH = '~/.blockstack-cli-regtest.conf'
export const DEFAULT_CONFIG_TESTNET_PATH = '~/.blockstack-cli-testnet.conf'
// CLI usage
const CLI_ARGS = {
type: 'object',
properties: {
announce: {
type: "array",
items: [
{
name: 'message_hash',
type: "string",
realtype: 'zonefile_hash',
pattern: ZONEFILE_HASH_PATTERN,
},
{
name: 'owner_key',
type: "string",
realtype: 'private_key',
pattern: `${PRIVATE_KEY_PATTERN_ANY}`
},
],
minItems: 2,
maxItems: 2,
help: 'Broadcast a message on the blockchain for subscribers to read. ' +
'The MESSAGE_HASH argument must be the hash of a previously-announced zone file. ' +
'The OWNER_KEY used to sign the transaction must correspond to the Blockstack ID ' +
'to which other users have already subscribed. OWNER_KEY can be a single private key ' +
'or a serialized multisig private key bundle.\n' +
'\n' +
'Examples:\n' +
' $ # Tip: You can obtain the owner key with the get_owner_keys command\n' +
' $ export OWNER_KEY="136ff26efa5db6f06b28f9c8c7a0216a1a52598045162abfe435d13036154a1b01"\n' +
' $ blockstack-cli announce 737c631c7c5d911c6617993c21fba731363f1cfe "$OWNER_KEY"\n' +
'\n' +
' $ export OWNER_KEY="2,136ff26efa5db6f06b28f9c8c7a0216a1a52598045162abfe435d13036154a1b01,1885cba486a42960499d1f137ef3a475725ceb11f45d74631f9928280196f67401,2418981c7f3a91d4467a65a518e14fafa30e07e6879c11fab7106ea72b49a7cb01"\n' +
' $ blockstack-cli announce 737c631c7c5d911c6617993c21fba731363f1cfe "$OWNER_KEY"\n',
group: 'Peer Services'
},
authenticator: {
type: "array",
items: [
{
name: 'app_gaia_hub',
type: 'string',
realtype: 'url',
pattern: URL_PATTERN,
},
{
name: 'backup_phrase',
type: 'string',
realtype: '12_words_or_ciphertext',
pattern: '.+',
},
{
name: 'profileGaiaHub',
type: 'string',
realtype: 'url',
pattern: URL_PATTERN,
},
{
name: 'port',
type: 'string',
realtype: 'portnum',
pattern: '^[0-9]+',
},
],
minItems: 2,
maxItems: 4,
help: 'Run an authentication endpoint for the set of names owned ' +
'by the given backup phrase. Send applications the given Gaia hub URL on sign-in, ' +
'so the application will use it to read/write user data.\n' +
'\n' +
'You can supply your encrypted backup phrase instead of the raw backup phrase. If so, ' +
'then you will be prompted for your password before any authentication takes place.\n' +
'\n' +
'Example:\n' +
'\n' +
' $ export BACKUP_PHRASE="oak indicate inside poet please share dinner monitor glow hire source perfect"\n' +
' $ export APP_GAIA_HUB="https://1.2.3.4"\n' +
' $ export PROFILE_GAIA_HUB="https://hub.blockstack.org"\n' +
' $ blockstack-cli authenticator "$APP_GAIA_HUB" "$BACKUP_PHRASE" "$PROFILE_GAIA_HUB" 8888\n' +
' Press Ctrl+C to exit\n' +
' Authentication server started on 8888\n',
group: 'Authentication',
},
balance: {
type: "array",
items: [
{
name: 'address',
type: "string",
realtype: 'address',
pattern: `${ADDRESS_PATTERN}|${STACKS_ADDRESS_PATTERN}`,
}
],
minItems: 1,
maxItems: 1,
help: 'Query the balance of an account. Returns the balances of each kind of token ' +
'that the account owns. The balances will be in the *smallest possible units* of the ' +
'token (i.e. satoshis for BTC, microStacks for Stacks, etc.).\n' +
'\n' +
'Example:\n' +
'\n' +
' $ blockstack-cli balance 16pm276FpJYpm7Dv3GEaRqTVvGPTdceoY4\n' +
' {\n' +
' "BTC": "123456"\n' +
' "STACKS": "123456"\n' +
' }\n' +
' $ blockstack-cli balance SPZY1V53Z4TVRHHW9Z7SFG8CZNRAG7BD8WJ6SXD0\n' +
' {\n' +
' "BTC": "123456"\n' +
' "STACKS": "123456"\n' +
' }\n',
group: 'Account Management',
},
convert_address: {
type: "array",
items: [
{
name: "address",
type: "string",
realtype: "address",
pattern: `${ADDRESS_PATTERN}|${STACKS_ADDRESS_PATTERN}`
},
],
minItems: 1,
maxItems: 1,
help: 'Convert a Bitcoin address to a Stacks address and vice versa.\n' +
'\n' +
'Example:\n' +
'\n' +
' $ blockstack-cli convert_address 12qdRgXxgNBNPnDeEChy3fYTbSHQ8nfZfD\n' +
' {\n' +
' "STACKS": "SPA2MZWV9N67TBYVWTE0PSSKMJ2F6YXW7CBE6YPW",\n' +
' "BTC": "12qdRgXxgNBNPnDeEChy3fYTbSHQ8nfZfD"\n' +
' }\n' +
' $ blockstack-cli convert_address SPA2MZWV9N67TBYVWTE0PSSKMJ2F6YXW7CBE6YPW\n' +
' {\n' +
' "STACKS": "SPA2MZWV9N67TBYVWTE0PSSKMJ2F6YXW7CBE6YPW",\n' +
' "BTC": "12qdRgXxgNBNPnDeEChy3fYTbSHQ8nfZfD"\n' +
' }\n',
group: 'Account Management',
},
decrypt_keychain: {
type: "array",
items: [
{
name: "encrypted_backup_phrase",
type: "string",
realtype: "encrypted_backup_phrase",
pattern: "^[^ ]+$",
},
{
name: 'password',
type: 'string',
realtype: 'password',
pattern: '.+',
},
],
minItems: 1,
maxItems: 2,
help: 'Decrypt an encrypted backup phrase with a password. Decrypts to a 12-word ' +
'backup phrase if done correctly. The password will be prompted if not given.\n' +
'\n' +
'Example:\n' +
'\n' +
' $ # password is "asdf"\n' +
' $ blockstack-cli decrypt_keychain "bfMDtOucUGcJXjZo6vkrZWgEzue9fzPsZ7A6Pl4LQuxLI1xsVF0VPgBkMsnSLCmYS5YHh7R3mNtMmX45Bq9sNGPfPsseQMR0fD9XaHi+tBg=\n' +
' Enter password:\n' +
' section amount spend resemble spray verify night immune tattoo best emotion parrot',
group: "Key Management",
},
encrypt_keychain: {
type: "array",
items: [
{
name: "backup_phrase",
type: "string",
realtype: "backup_phrase",
pattern: ".+",
},
{
name: 'password',
type: 'string',
realtype: 'password',
pattern: '.+',
},
],
minItems: 1,
maxItems: 2,
help: "Encrypt a 12-word backup phrase, which can be decrypted later with the " +
"decrypt_backup_phrase command. The password will be prompted if not given.\n" +
'\n' +
'Example:\n' +
'\n' +
' $ # password is "asdf"\n' +
' $ blockstack-cli encrypt_keychain "section amount spend resemble spray verify night immune tattoo best emotion parrot"\n' +
' Enter password:\n' +
' Enter password again:\n' +
' M+DnBHYb1fgw4N3oZ+5uTEAua5bAWkgTW/SjmmBhGGbJtjOtqVV+RrLJEJOgT35hBon4WKdGWye2vTdgqDo7+HIobwJwkQtN2YF9g3zPsKk=',
group: "Key Management",
},
gaia_dump_bucket: {
type: "array",
items: [
{
name: 'name_or_id_address',
type: 'string',
realtype: 'name_or_id_address',
pattern: `${ID_ADDRESS_PATTERN}|${NAME_PATTERN}|${SUBDOMAIN_PATTERN}`
},
{
name: 'app_origin',
type: 'string',
realtype: 'url',
pattern: URL_PATTERN,
},
{
name: 'gaia_hub',
type: 'string',
realtype: 'url',
pattern: URL_PATTERN,
},
{
name: 'backup_phrase',
type: 'string',
realtype: '12_words_or_ciphertext',
},
{
name: 'dump_dir',
type: 'string',
realtype: 'path',
pattern: PATH_PATTERN,
}
],
minItems: 5,
maxItems: 5,
help: 'Download the contents of a Gaia hub bucket to a given directory. The GAIA_HUB argument ' +
'must correspond to the *write* endpoint of the Gaia hub -- that is, you should be able to fetch ' +
'$GAIA_HUB/hub_info. If DUMP_DIR does not exist, it will be created.\n' +
'\n' +
'Example:\n' +
'\n' +
' $ export BACKUP_PHRASE="section amount spend resemble spray verify night immune tattoo best emotion parrot\n' +
' $ blockstack-cli gaia_dump_bucket hello.id.blockstack https://sample.app https://hub.blockstack.org "$BACKUP_PHRASE" ./backups\n' +
' Download 3 files...\n' +
' Download hello_world to ./backups/hello_world\n' +
' Download dir/format to ./backups/dir\\x2fformat\n' +
' Download /.dotfile to ./backups/\\x2f.dotfile\n' +
' 3\n',
group: "Gaia",
},
gaia_getfile: {
type: "array",
items: [
{
name: 'blockstack_id',
type: 'string',
realtype: 'blockstack_id',
pattern: `${NAME_PATTERN}|${SUBDOMAIN_PATTERN}$`,
},
{
name: 'app_origin',
type: 'string',
realtype: 'url',
pattern: URL_PATTERN,
},
{
name: 'filename',
type: 'string',
realtype: 'filename',
pattern: '.+',
},
{
name: 'app_private_key',
type: 'string',
realtype: 'private_key',
pattern: PRIVATE_KEY_UNCOMPRESSED_PATTERN,
},
{
name: 'decrypt',
type: 'string',
realtype: 'boolean',
pattern: BOOLEAN_PATTERN,
},
{
name: 'verify',
type: 'string',
realtype: 'boolean',
pattern: BOOLEAN_PATTERN,
},
],
minItems: 3,
maxItems: 6,
help: 'Get a file from another user\'s Gaia hub. Prints the file data to stdout. If you ' +
'want to read an encrypted file, and/or verify a signed file, then you must pass an app ' +
'private key, and pass 1 for DECRYPT and/or VERIFY. If the file is encrypted, and you do not ' +
'pass an app private key, then this command downloads the ciphertext. If the file is signed, ' +
'and you want to download its data and its signature, then you must run this command twice -- ' +
'once to get the file contents at FILENAME, and once to get the signature (whose name will be FILENAME.sig).\n' +
'\n' +
'Note that Gaia is a key-value store, and has no notion of directories. Any directory-separator characters like / or \\ in FILENAME ' +
'will be treated as string literals.\n' +
'\n' +
'Example without encryption:\n' +
'\n' +
' $ # Get an unencrypted, unsigned file\n' +
' $ blockstack-cli gaia_getfile ryan.id http://publik.ykliao.com statuses.json\n' +
' [{"id":0,"text":"Hello, Blockstack!","created_at":1515786983492}]\n' +
'\n' +
'Example with encryption:\n' +
'\n' +
' $ # Get an encrypted file without decrypting\n' +
' $ blockstack-cli gaia_getfile ryan.id https://app.graphitedocs.com documentscollection.json\n' +
'' +
' $ # Get an encrypted file, and decrypt it\n' +
' $ # Tip: You can obtain the app key with the get_app_keys command\n' +
' $ export APP_KEY="3ac770e8c3d88b1003bf4a0a148ceb920a6172bdade8e0325a1ed1480ab4fb19"\n' +
' $ blockstack-cli gaia_getfile ryan.id https://app.graphitedocs.com documentscollection.json "$APP_KEY" 1 0\n',
group: 'Gaia',
},
gaia_putfile: {
type: "array",
items: [
{
name: 'gaia_hub',
type: 'string',
realtype: 'url',
pattern: URL_PATTERN,
},
{
name: 'app_private_key',
type: 'string',
realtype: 'private_key',
pattern: PRIVATE_KEY_UNCOMPRESSED_PATTERN,
},
{
name: 'data_path',
type: 'string',
realtype: 'path',
pattern: '.+',
},
{
name: 'gaia_filename',
type: 'string',
realtype: 'filename',
pattern: PATH_PATTERN,
},
{
name: 'encrypt',
type: 'string',
realtype: 'boolean',
pattern: BOOLEAN_PATTERN,
},
{
name: 'sign',
type: 'string',
realtype: 'boolean',
pattern: BOOLEAN_PATTERN,
},
],
minItems: 4,
maxItems: 6,
help: 'Put a file into a given Gaia hub, authenticating with the given app private key. ' +
'Optionally encrypt and/or sign the data with the given app private key.',
group: 'Gaia',
},
gaia_listfiles: {
type: "array",
items: [
{
name: 'gaia_hub',
type: 'string',
realtype: 'url',
pattern: URL_PATTERN,
},
{
name: 'app_private_key',
type: 'string',
realtype: 'private_key',
pattern: PRIVATE_KEY_UNCOMPRESSED_PATTERN,
},
],
minItems: 2,
maxItems: 2,
help: 'List all the files in a Gaia hub, authenticating with the given app private key.',
group: 'Gaia',
},
gaia_restore_bucket: {
type: "array",
items: [
{
name: 'name_or_id_address',
type: 'string',
realtype: 'name_or_id_address',
pattern: `${ID_ADDRESS_PATTERN}|${NAME_PATTERN}|${SUBDOMAIN_PATTERN}`
},
{
name: 'app_origin',
type: 'string',
realtype: 'url',
pattern: URL_PATTERN,
},
{
name: 'gaia_hub',
type: 'string',
realtype: 'url',
pattern: URL_PATTERN,
},
{
name: 'backup_phrase',
type: 'string',
realtype: '12_words_or_ciphertext',
},
{
name: 'dump_dir',
type: 'string',
realtype: 'path',
pattern: PATH_PATTERN,
}
],
minItems: 5,
maxItems: 5,
help: 'Upload the contents of a previously-dumped Gaia bucket to a new Gaia hub. The GAIA_HUB argument ' +
'must correspond to the *write* endpoint of the Gaia hub -- that is, you should be able to fetch ' +
'$GAIA_HUB/hub_info. DUMP_DIR must contain the file contents created by a previous successful run of the gaia_dump_bucket command, ' +
'and both NAME_OR_ID_ADDRESS and APP_ORIGIN must be the same as they were when it was run.\n' +
'\n' +
'Example:\n' +
'\n' +
' $ export BACKUP_PHRASE="section amount spend resemble spray verify night immune tattoo best emotion parrot"\n' +
' $ blockstack-cli gaia_restore_bucket hello.id.blockstack https://sample.app https://new.gaia.hub "$BACKUP_PHRASE" ./backups\n' +
' Uploaded ./backups/hello_world to https://new.gaia.hub/hub/1Lr8ggSgdmfcb4764woYutUfFqQMjEoKHc/hello_world\n' +
' Uploaded ./backups/dir\\x2fformat to https://new.gaia.hub/hub/1Lr8ggSgdmfcb4764woYutUfFqQMjEoKHc/dir/format\n' +
' Uploaded ./backups/\\x2f.dotfile to https://new.gaia.hub/hub/1Lr8ggSgdmfcb4764woYutUfFqQMjEoKHc//.dotfile\n' +
' 3\n',
group: "Gaia",
},
gaia_sethub: {
type: "array",
items: [
{
name: 'blockstack_id',
type: 'string',
realtype: 'blockstack_id',
pattern: `^${NAME_PATTERN}|${SUBDOMAIN_PATTERN}$`,
},
{
name: 'owner_gaia_hub',
type: 'string',
realtype: 'url',
pattern: URL_PATTERN,
},
{
name: 'app_origin',
type: 'string',
realtype: 'url',
pattern: URL_PATTERN,
},
{
name: 'app_gaia_hub',
type: 'string',
realtype: 'url',
pattern: URL_PATTERN,
},
{
name: 'backup_phrase',
type: 'string',
realtype: '12_words_or_ciphertext',
},
],
minItems: 5,
maxItems: 5,
help: 'Set the Gaia hub for a particular application for a Blockstack ID.',
group: 'Gaia',
},
get_account_history: {
type: "array",
items: [
{
name: 'address',
type: "string",
realtype: 'address',
pattern: STACKS_ADDRESS_PATTERN,
},
{
name: 'startblock',
type: "string",
realtype: "integer",
pattern: "^[0-9]+$",
},
{
name: 'endblock',
type: "string",
realtype: "integer",
pattern: "^[0-9]+$",
},
{
name: 'page',
type: "string",
realtype: "integer",
pattern: "^[0-9]+$",
},
],
minItems: 4,
maxItems: 4,
help: 'Query the history of account debits and credits over a given block range. ' +
'Returns the history one page at a time. An empty result indicates that the page ' +
'number has exceeded the number of historic operations in the given block range.',
group: 'Account Management',
},
get_account_at: {
type: "array",
items: [
{
name: 'address',
type: "string",
realtype: 'address',
pattern: STACKS_ADDRESS_PATTERN,
},
{
name: 'blocknumber',
type: "string",
realtype: 'integer',
pattern: "^[0-9]+$",
},
],
minItems: 2,
maxItems: 2,
help: 'Query the list of token debits and credits on a given address that occurred ' +
'at a particular block height. Does not include BTC debits and credits.',
group: 'Account Management',
},
get_address: {
type: 'array',
items: [
{
name: 'private_key',
type: 'string',
realtype: 'private_key',
pattern: `${PRIVATE_KEY_PATTERN_ANY}`
}
],
minItems: 1,
maxItems: 1,
help: 'Get the address of a private key or multisig private key bundle. Gives the BTC and STACKS addresses\n' +
'\n' +
'Example:\n' +
'\n' +
' $ blockstack-cli get_address f5185b9ca93bdcb5753fded3b097dab8547a8b47d2be578412d0687a9a0184cb01\n' +
' {\n' +
' "BTC": "1JFhWyVPpZQjbPcXFtpGtTmU22u4fhBVmq",\n' +
' "STACKS": "SP2YM3J4KQK09V670TD6ZZ1XYNYCNGCWCVVKSDFWQ"\n' +
' }\n' +
' $ blockstack-cli get_address 1,f5185b9ca93bdcb5753fded3b097dab8547a8b47d2be578412d0687a9a0184cb01,ff2ff4f4e7f8a1979ffad4fc869def1657fd5d48fc9cf40c1924725ead60942c01\n' +
' {\n' +
' "BTC": "363pKBhc5ipDws1k5181KFf6RSxhBZ7e3p",\n' +
' "STACKS": "SMQWZ30EXVG6XEC1K4QTDP16C1CAWSK1JSWMS0QN"\n' +
' }',
group: 'Key Management',
},
get_blockchain_record: {
type: "array",
items: [
{
name: 'blockstack_id',
type: "string",
realtype: 'blockstack_id',
pattern: `^${NAME_PATTERN}|${SUBDOMAIN_PATTERN}$`,
},
],
minItems: 1,
maxItems: 1,
help: 'Get the low-level blockchain-hosted state for a Blockstack ID. This command ' +
'is used mainly for debugging and diagnostics. You should not rely on it to be stable.',
group: 'Querying Blockstack IDs'
},
get_blockchain_history: {
type: "array",
items: [
{
name: 'blockstack_id',
type: "string",
realtype: 'blockstack_id',
pattern: `${NAME_PATTERN}|${SUBDOMAIN_PATTERN}$`,
},
],
minItems: 1,
maxItems: 1,
help: 'Get the low-level blockchain-hosted history of operations on a Blocktack ID. ' +
'This command is used mainly for debugging and diagnostics, and is not guaranteed to ' +
'be stable across releases.',
group: 'Querying Blockstack IDs',
},
get_confirmations: {
type: "array",
items: [
{
name: 'txid',
type: 'string',
realtype: 'transaction_id',
pattern: TXID_PATTERN,
},
],
minItems: 1,
maxItems: 1,
help: 'Get the number of confirmations for a transaction.',
group: 'Peer Services',
},
get_namespace_blockchain_record: {
type: "array",
items: [
{
name: 'namespace_id',
type: "string",
realtype: 'namespace_id',
pattern: NAMESPACE_PATTERN,
},
],
minItems: 1,
maxItems: 1,
help: 'Get the low-level blockchain-hosted state for a Blockstack namespace. This command ' +
'is used mainly for debugging and diagnostics, and is not guaranteed to be stable across ' +
'releases.',
group: 'Namespace Operations',
},
get_app_keys: {
type: "array",
items: [
{
name: 'backup_phrase',
type: 'string',
realtype: '12_words_or_ciphertext',
},
{
name: 'name_or_id_address',
type: 'string',
realtype: 'name-or-id-address',
pattern: `${NAME_PATTERN}|${SUBDOMAIN_PATTERN}|${ID_ADDRESS_PATTERN}`,
},
{
name: 'app_origin',
type: 'string',
realtype: 'url',
pattern: URL_PATTERN,
},
],
minItems: 3,
maxItems: 3,
help: 'Get the application private key from a 12-word backup phrase and a name or ID-address. ' +
'This is the private key used to sign data in Gaia, and its address is the Gaia bucket ' +
'address. If you provide your encrypted backup phrase, you will be asked to decrypt it. ' +
'If you provide a name instead of an ID-address, its ID-address will be queried automatically ' +
'(note that this means that the name must already be registered). Note that this command does NOT ' +
'verify whether or not the name or ID-address was created by the backup phrase. You should do this yourself ' +
'via the "get_owner_keys" command if you are not sure.\n' +
'There are two derivation paths emitted by this command: a "keyInfo" path and a "legacyKeyInfo"' +
'path. You should use the one that matches the Gaia hub read URL\'s address, if you have already ' +
'signed in before. If not, then you should use the "keyInfo" path when possible.\n' +
'\n' +
'Example:\n' +
'\n' +
' $ export BACKUP_PHRASE="one race buffalo dynamic icon drip width lake extra forest fee kit"\n' +
' $ blockstack-cli get_app_keys "$BACKUP_PHRASE" ID-19veSw4r1aUG4GcrZFQUD7YZa1v2es2j6s https://my.cool.dapp\n' +
' {\n' +
' "keyInfo": {\n' +
' "privateKey": "TODO",\n' +
' "address": "TODO"\n' +
' },\n' +
' "legacyKeyInfo": {\n' +
' "privateKey": "90f9ec4e13fb9a00243b4c1510075157229bda73076c7c721208c2edca28ea8b",\n' +
' "address": "1Lr8ggSgdmfcb4764woYutUfFqQMjEoKHc"\n' +
' },\n' +
' "ownerKeyIndex": 0\n' +
' }',
group: 'Key Management',
},
get_owner_keys: {
type: "array",
items: [
{
name: 'backup_phrase',
type: "string",
realtype: '12_words_or_ciphertext',
},
{
name: 'index',
type: "string",
realtype: 'integer',
pattern: "^[0-9]+$",
}
],
minItems: 1,
maxItems: 2,
help: 'Get the list of owner private keys and ID-addresses from a 12-word backup phrase. ' +
'Pass non-zero values for INDEX to generate the sequence of ID-addresses that can be used ' +
'to own Blockstack IDs. If you provide an encrypted 12-word backup phrase, you will be ' +
'asked for your password to decrypt it.',
group: 'Key Management',
},
get_payment_key: {
type: "array",
items: [
{
name: 'backup_phrase',
type: "string",
realtype: '12_words_or_ciphertext',
},
],
minItems: 1,
maxItems: 1,
help: 'Get the payment private key from a 12-word backup phrase. If you provide an ' +
'encrypted backup phrase, you will be asked for your password to decrypt it.',
group: 'Key Management',
},
get_zonefile: {
type: "array",
items: [
{
name: 'blockstack_id',
type: "string",
realtype: 'blockstack_id',
pattern: `${NAME_PATTERN}|${SUBDOMAIN_PATTERN}$`,
},
],
minItems: 1,
maxItems: 1,
help: 'Get the current zone file for a Blockstack ID',
group: 'Peer Services',
},
help: {
type: 'array',
items: [
{
name: 'command',
type: 'string',
realtype: 'command',
},
],
minItems: 0,
maxItems: 1,
help: 'Get the usage string for a CLI command',
group: 'CLI',
},
lookup: {
type: "array",
items: [
{
name: 'blockstack_id',
type: "string",
realtype: 'blockstack_id',
pattern: `${NAME_PATTERN}|${SUBDOMAIN_PATTERN}$`,
},
],
minItems: 1,
maxItems: 1,
help: 'Get and authenticate the profile and zone file for a Blockstack ID',
group: 'Querying Blockstack IDs',
},
names: {
type: "array",
items: [
{
name: 'id_address',
type: "string",
realtype: 'id-address',
pattern: ID_ADDRESS_PATTERN,
},
],
minItems: 1,
maxItems: 1,
help: 'Get the list of Blockstack IDs owned by an ID-address.',
group: 'Querying Blockstack IDs',
},
make_keychain: {
type: "array",
items: [
{
name: 'backup_phrase',
type: 'string',
realtype: '12_words_or_ciphertext',
},
],
minItems: 0,
maxItems: 1,
help: 'Generate the owner and payment private keys, optionally from a given 12-word ' +
'backup phrase. If no backup phrase is given, a new one will be generated. If you provide ' +
'your encrypted backup phrase, you will be asked to decrypt it.',
group: 'Key Management',
},
make_zonefile: {
type: "array",
items: [
{
name: 'blockstack_id',
type: 'string',
realtype: 'blockstack_id',
pattern: `^${NAME_PATTERN}|${SUBDOMAIN_PATTERN}$`,
},
{
name: 'id_address',
type: 'string',
realtype: 'ID-address',
pattern: ID_ADDRESS_PATTERN,
},
{
name: 'gaia_url_prefix',
type: 'string',
realtype: 'url',
pattern: '.+',
},
{
name: 'resolver_url',
type: 'string',
realtype: 'url',
pattern: '.+',
},
],
minItems: 3,
maxItems: 4,
help: "Generate a zone file for a Blockstack ID with the given profile URL. If you know " +
"the ID-address for the Blockstack ID, the profile URL usually takes the form of:\n" +
"\n" +
" {GAIA_URL_PREFIX}/{ADDRESS}/profile.json\n" +
"\n" +
"where {GAIA_URL_PREFIX} is the *read* endpoint of your Gaia hub (e.g. https://gaia.blockstack.org/hub) and " +
"{ADDRESS} is the base58check part of your ID-address (i.e. the string following 'ID-').",
group: "Peer Services",
},
name_import: {
type: "array",
items: [
{
name: 'blockstack_id',
type: "string",
realtype: 'blockstack_id',
pattern: NAME_PATTERN,
},
{
name: 'id_address',
type: "string",
realtype: 'id-address',
pattern: ID_ADDRESS_PATTERN,
},
{
name: 'gaia_url_prefix',
type: "string",
realtype: 'url',
pattern: '.+',
},
{
name: 'reveal_key',
type: "string",
realtype: 'private_key',
pattern: `${PRIVATE_KEY_PATTERN_ANY}`
},
{
name: 'zonefile',
type: 'string',
realtype: 'path',
pattern: '.+',
},
{
name: 'zonefile_hash',
type: 'string',
realtype: 'zonefile_hash',
pattern: ZONEFILE_HASH_PATTERN,
},
],
minItems: 4,
maxItems: 6,
help: 'Import a name into a namespace you revealed. The REVEAL_KEY must be the same as ' +
'the key that revealed the namespace. You can only import a name into a namespace if ' +
'the namespace has not yet been launched (i.e. via `namespace_ready`), and if the ' +
'namespace was revealed less than a year ago (52595 blocks ago).\n' +
'\n' +
'A zone file will be generated for this name automatically, if "ZONEFILE" is not given. By default, ' +
'the zone file will have a URL to the name owner\'s profile prefixed by GAIA_URL_PREFIX. If you ' +
'know the *write* endpoint for the name owner\'s Gaia hub, you can find out the GAIA_URL_PREFIX ' +
'to use with "curl $GAIA_HUB/hub_info".\n' +
'\n' +
'If you specify an argument for "ZONEFILE," then the GAIA_URL_PREFIX argument is ignored in favor of ' +
'your custom zone file on disk.\n' +
'\n' +
'If you specify a valid zone file hash for "ZONEFILE_HASH," then it will be used in favor of ' +
'both ZONEFILE and GAIA_URL_PREFIX. The zone file hash will be incorporated directly into the ' +
'name-import transaction.\n' +
'\n' +
'Example:\n' +
'\n' +
' $ export REVEAL_KEY="bfeffdf57f29b0cc1fab9ea197bb1413da2561fe4b83e962c7f02fbbe2b1cd5401"\n' +
' $ export ID_ADDRESS="ID-18e1bqU7B5qUPY3zJgMLxDnexyStTeSnvV"\n' +
' $ blockstack-cli name_import example.id "$ID_ADDRESS" https://gaia.blockstack.org/hub "$REVEAL_KEY"',
group: 'Namespace Operations',
},
namespace_preorder: {
type: 'array',