Bug Description and Scenario:
I have recently configured my Gaia hub. As the next step, I want to configure my Gaia hub as the default app storage hub.
I tried using the Stacks-cli way following the forum post and Stacks-cli docs. I hit the below roadblocks. Appreciate any leads on the same. Thank you so much.
1) get_app_keys and gaia_sethub commands are failing with the below error, unable to make getfile/putfile command.
```
$ export BACKUP_PHRASE=“
gaia@gaia-VirtualBox:~$ stx get_app_keys “$BACKUP_PHRASE” lockwise.id.blockstack https://blocksurvey.io
Enter password:
Error: Non-base58 character
at Object.decode (/home/gaia/.nvm/versions/node/v16.1.0/lib/node_modules/@stacks/cli/node_modules/base-x/src/index.js:115:11)
at Object.decode (/home/gaia/.nvm/versions/node/v16.1.0/lib/node_modules/@stacks/cli/node_modules/bs58check/base.js:39:25)
at Object.fromBase58Check (/home/gaia/.nvm/versions/node/v16.1.0/lib/node_modules/@stacks/cli/node_modules/bitcoinjs-lib/src/address.js:11:29)
at BlockstackNetwork.coerceAddress (/home/gaia/.nvm/versions/node/v16.1.0/lib/node_modules/@stacks/cli/node_modules/blockstack/src/network.ts:84:42)
at /home/gaia/.nvm/versions/node/v16.1.0/lib/node_modules/@stacks/cli/node_modules/blockstack/src/network.ts:353:62
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Non-base58 character
2) **stx authenticator** is starting on port 8888. But not sure how to proceed, since blockstack browser is not active anymore. Any guidance on this is appreciated.
```
stx authenticator “http://gaia.blsy.me:3000” “$BACKUP_PHRASE” “https://hub.blockstack.org” 8888
Press Ctrl+C to exit
Authentication server started on 8888
3) With the new keychain, couldn’t proceed further. As I couldn’t get app-keys without domain name and register subdomain command also fails with the same error ,Invalid command arguments.
stx get_app_keys “$BACKUP_PHRASE” 1PQ4NSLCJLbge95AXd8tWmY6TX8KfxduPM https://blocksurvey.io
Invalid command arguments: Schema “#/items/1/pattern” failed validation (problem: “should match pattern “^([0-9a-z_.±]{3,37})$|^([0-9a-z_±]{1,37}).([0-9a-z_.±]{3,37})$|^ID-[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{1,35}$””, cause: “{“pattern”:”^([0-9a-z_.±]{3,37})$|^([0-9a-z_±]{1,37}).([0-9a-z_.±]{3,37})$|^ID-[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{1,35}$"}")
4) Also, make_keychain command generates 24 word seed phrase and stx encrypt_keychain fails for the newly created key, as it throws the below error.
Invalid command arguments: Schema “#/items/1/pattern” failed validation (problem: “should match pattern “^([0-9a-z_.±]{3,37})$|^([0-9a-z_±]{1,37}).([0-9a-z_.±]{3,37})$|^ID-[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{1,35}$””, cause: “{“pattern”:”^([0-9a-z_.±]{3,37})$|^([0-9a-z_±]{1,37}).([0-9a-z_.±]{3,37})$|^ID-[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{1,35}$"}")
Is the bug present in the Blockstack CLI, Gaia hub, Connect or Blockstack Browser?
The bug is reported in Stacks CLI . @stacks/cli package was used.
Setup:
Installed cli using npm install -g @stacks/cli . Tried the cli in both Ubuntu and Windows. Faced the same error.
Additional context
This was originally reported in Stacks Forum. Adding the link here.
Thanks for opening this issue @HariniRajan397! I don't maintain the CLI myself anymore -- this responsibility has passed to the maintainers of this repo -- but I can answer some of these issues:
- get_app_keys and gaia_sethub commands are failing with the below error, unable to make getfile/putfile command.
Is there an end-to-end example you can provide here, using a made-up backup phrase? I'm actually stuck in part 4 of this issue -- I can't seem to make backup phrases at all.
- stx authenticator is starting on port 8888. But not sure how to proceed, since blockstack browser is not active anymore. Any guidance on this is appreciated.
Back when I wrote the authenticator feature, stacks.js would try to invoke a protocol handler for blockstack:<auth-token>, where <auth-token> was a JWT that encoded the login request and redirect URL. The Web browser would intercept this and load up your OS's protocol handler for blockstack: URLs. The old Blockstack Browser was this handler -- when you clicked a username, it would redirect you back to the URL in <auth-token> with an authResponse JWT containing the login credentials.
I'm not sure if this is still the case today (hoping someone else here can confirm this), but a quick glance at the code suggests that it might be. Can you confirm whether or not you have a protocol handler installed for blockstack:, and if so, what it's set to? If it's set to the browser, you'll need to set it to the stx CLI instead.
The way I've done this in the past is to create the following files:
$ # protocol handler .desktop file, which runs a `blockstack.sh` script to handle `blockstack:` URLs
$ cat ~/.local/share/applications/blockstack.desktop
[Desktop Entry]
Name=Blockstack
Exec=blockstack.sh %u
Type=Application
NoDisplay=true
Categories=System;
MimeType=x-scheme-handler/blockstack;
$ # protocol handler script. Put this in your $PATH somewhere and make it executable.
$ cat ~/bin/blockstack.sh
#!/bin/sh
# tailor to your needs -- I think you were using 8888 here?
PORTNUM=3000
PORTAL_URL="http://localhost:$PORTNUM"
# logging...
echo "request: $@" >> /tmp/blockstack.log
# expect blockstack:AUTHENTICATION_TOKEN
if [ -z "$1" ]; then
exit 1
fi
AUTH_TOKEN="$(echo "$1" | sed -r 's/blockstack://g')"
exec chromium-browser "$PORTAL_URL/auth?authRequest=$AUTH_TOKEN"
Then, your browser should redirect you to the stx authenticator. But, I will need someone else here to confirm that the login process still works this way.
- With the new keychain, couldn’t proceed further. As I couldn’t get app-keys without domain name and register subdomain command also fails with the same error ,Invalid command arguments.
You need to prefix the address with ID-. So, the usage should be:
$ stx get_app_keys “$BACKUP_PHRASE” ID-1PQ4NSLCJLbge95AXd8tWmY6TX8KfxduPM https://blocksurvey.io
- Also, make_keychain command generates 24 word seed phrase and stx encrypt_keychain fails for the newly created key, as it throws the below error.
I'm actually getting a different error when I try this:
$ stx make_keychain
{
"mnemonic": "silly journey pill ocean client cherry stool asset image bachelor craft wasp cage slow loud spot swallow build obscure business lazy physical want pizza",
"keyInfo": {
"privateKey": "f51adcd56339621957285c42b45585a642722e297fbc8fe46cfe22d09f0a607501",
"address": "SP2201YTKGR0K0ARPZBVJ1M9NP8AJEP6PVJP98A8",
"btcAddress": "1Np5JHJCD6LyQPWyT6er4vG9hWPTWuNTg",
"index": 0
}
}
$ stx encrypt_keychain "silly journey pill ocean client cherry stool asset image bachelor craft wasp cage slow loud spot swallow build obscure business lazy physical want pizza"
{"error":{},"level":"error","message":"uncaughtException: Invalid backup phrase: must be 12 words\nError: Invalid backup phrase: must be 12 words\n at method (/usr/lib/node_modules/@stacks/cli/src/cli.ts:1405:11)\n at CLIMain (/usr/lib/node_modules/@stacks/cli/src/cli.ts:1881:5)\n at Object.<anonymous> (/usr/lib/node_modules/@stacks/cli/src/index.ts:32:1)\n at Module._compile (internal/modules/cjs/loader.js:1063:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)\n at Module.load (internal/modules/cjs/loader.js:928:32)\n at Function.Module._load (internal/modules/cjs/loader.js:769:14)\n at Module.require (internal/modules/cjs/loader.js:952:19)\n at require (internal/modules/cjs/helpers.js:88:18)\n at Object.<anonymous> (/usr/lib/node_modules/@stacks/cli/dist/index.js:7:20)","stack":"Error: Invalid backup phrase: must be 12 words\n at method (/usr/lib/node_modules/@stacks/cli/src/cli.ts:1405:11)\n at CLIMain (/usr/lib/node_modules/@stacks/cli/src/cli.ts:1881:5)\n at Object.<anonymous> (/usr/lib/node_modules/@stacks/cli/src/index.ts:32:1)\n at Module._compile (internal/modules/cjs/loader.js:1063:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)\n at Module.load (internal/modules/cjs/loader.js:928:32)\n at Function.Module._load (internal/modules/cjs/loader.js:769:14)\n at Module.require (internal/modules/cjs/loader.js:952:19)\n at require (internal/modules/cjs/helpers.js:88:18)\n at Object.<anonymous> (/usr/lib/node_modules/@stacks/cli/dist/index.js:7:20)","exception":true,"date":"Wed May 05 2021 22:39:11 GMT-0600 (GMT-06:00)","process":{"pid":2608,"uid":1000,"gid":1000,"cwd":"/home/jude/Desktop/research/git/stacks.js","execPath":"/usr/bin/node","version":"v14.16.1","argv":["/usr/bin/node","/usr/bin/stx","encrypt_keychain","silly journey pill ocean client cherry stool asset image bachelor craft wasp cage slow loud spot swallow build obscure business lazy physical want pizza"],"memoryUsage":{"rss":119869440,"heapTotal":82673664,"heapUsed":54237520,"external":3358220,"arrayBuffers":161499}},"os":{"loadavg":[0.38,0.53,0.49],"uptime":26788961},"trace":[{"column":11,"file":"/usr/lib/node_modules/@stacks/cli/src/cli.ts","function":"method","line":1405,"method":null,"native":false},{"column":5,"file":"/usr/lib/node_modules/@stacks/cli/src/cli.ts","function":"CLIMain","line":1881,"method":null,"native":false},{"column":1,"file":"/usr/lib/node_modules/@stacks/cli/src/index.ts","function":null,"line":32,"method":null,"native":false},{"column":30,"file":"internal/modules/cjs/loader.js","function":"Module._compile","line":1063,"method":"_compile","native":false},{"column":10,"file":"internal/modules/cjs/loader.js","function":"Module._extensions..js","line":1092,"method":".js","native":false},{"column":32,"file":"internal/modules/cjs/loader.js","function":"Module.load","line":928,"method":"load","native":false},{"column":14,"file":"internal/modules/cjs/loader.js","function":"Module._load","line":769,"method":"_load","native":false},{"column":19,"file":"internal/modules/cjs/loader.js","function":"Module.require","line":952,"method":"require","native":false},{"column":18,"file":"internal/modules/cjs/helpers.js","function":"require","line":88,"method":null,"native":false},{"column":20,"file":"/usr/lib/node_modules/@stacks/cli/dist/index.js","function":null,"line":7,"method":null,"native":false}]}
The CLI expects a 12-word backup phrase, but make_keychain creates a 24-word pharse. This appears to be a bug.
@agraebe Could you evaluate this for prioritization by the platform team soon? Harini is looking to get this set up for an enterprise client, so it'd be great to help unblock her here.
will review during the next sprint planning
Thank you so much, Jude @jcnelson. For the get app_keys, I am giving below the sample secret key and id I have been using. Using make_keychain I was also getting the 24-word secret key, so I created the below username in the application login.
export BACKUP_PHRASE="relax slice swift walk there like keep avoid stove domain rough embrace"
stx get_app_keys "$BACKUP_PHRASE" lockwise.id.blockstack https://blocksurvey.io
And, I am getting the below error.
Error: Non-base58 character
at Object.decode (/home/gaia/.nvm/versions/node/v16.1.0/lib/node_modules/@stacks/cli/node_modules/base-x/src/index.js:115:11)
at Object.decode (/home/gaia/.nvm/versions/node/v16.1.0/lib/node_modules/@stacks/cli/node_modules/bs58check/base.js:39:25)
at Object.fromBase58Check (/home/gaia/.nvm/versions/node/v16.1.0/lib/node_modules/@stacks/cli/node_modules/bitcoinjs-lib/src/address.js:11:29)
at BlockstackNetwork.coerceAddress (/home/gaia/.nvm/versions/node/v16.1.0/lib/node_modules/@stacks/cli/node_modules/blockstack/src/network.ts:84:42)
at /home/gaia/.nvm/versions/node/v16.1.0/lib/node_modules/@stacks/cli/node_modules/blockstack/src/network.ts:353:62
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Non-base58 character
Meanwhile, after giving my APP_GAIA details in the gaia_sethub command, I am getting the same error. Given below is the sample set gaia_hub command used.
stx gaia_sethub lockwise.id.blockstack https://hub.blockstack.org https://blocksurvey.io https://gaia.blsy.me "$BACKUP_PHRASE"
2) Thank you for the info on the authenticator. This is very helpful. I haven't set the protocol handler. I will try once someone confirms.
3) With the prefix of ID, I am still getting the same error.
stx get_app_keys “$BACKUP_PHRASE” ID-1PQ4NSLCJLbge95AXd8tWmY6TX8KfxduPM https://blocksurvey.io
Invalid command arguments: Schema "#/items/2/pattern" failed validation (problem: "should match pattern "^http[s]?://.+$"", cause: "{"pattern":"^http[s]?://.+$"}")
Thank you Mark and Alex for looking into this. Appreciate all the support. @agraebe Kindly let me know if you need any other information from my end. Thank you.
Today, I was checking a few other cli methods whois, lookup, and names calls. . Looks like those methods are not functioning anymore. Getting the below error for all the above-mentioned methods. Requesting you to have a look at them as well. Thank you.
{"error":{},"level":"error","message":"uncaughtException: method is not a function\nTypeError: method is not a function\n at CLIMain (C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\@stacks\\cli\\src\\cli.ts:1880:5)\n at Object.<anonymous> (C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\@stacks\\cli\\src\\index.ts:32:1)\n at Module._compile (internal/modules/cjs/loader.js:1063:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)\n at Module.load (internal/modules/cjs/loader.js:928:32)\n at Function.Module._load (internal/modules/cjs/loader.js:769:14)\n at Module.require (internal/modules/cjs/loader.js:952:19)\n at require (internal/modules/cjs/helpers.js:88:18)\n at Object.<anonymous> (C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\@stacks\\cli\\dist\\index.js:7:20)\n at Module._compile (internal/modules/cjs/loader.js:1063:30)","stack":"TypeError: method is not a function\n at CLIMain (C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\@stacks\\cli\\src\\cli.ts:1880:5)\n at Object.<anonymous> (C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\@stacks\\cli\\src\\index.ts:32:1)\n at Module._compile (internal/modules/cjs/loader.js:1063:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)\n at Module.load (internal/modules/cjs/loader.js:928:32)\n at Function.Module._load (internal/modules/cjs/loader.js:769:14)\n at Module.require (internal/modules/cjs/loader.js:952:19)\n at require (internal/modules/cjs/helpers.js:88:18)\n at Object.<anonymous> (C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\@stacks\\cli\\dist\\index.js:7:20)\n at Module._compile (internal/modules/cjs/loader.js:1063:30)","exception":true,"date":"Mon May 24 2021 11:38:28 GMT-0400 (Eastern Daylight Time)","process":{"pid":13424,"uid":null,"gid":null,"cwd":"C:\\WINDOWS\\system32","execPath":"C:\\Program Files\\nodejs\\node.exe","version":"v14.15.1","argv":["C:\\Program Files\\nodejs\\node.exe","C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\@stacks\\cli\\bin.js","lookup","nomadcarl.id.blockstack"],"memoryUsage":{"rss":108359680,"heapTotal":83992576,"heapUsed":56032312,"external":3240905,"arrayBuffers":117253}},"os":{"loadavg":[0,0,0],"uptime":351072},"trace":[{"column":5,"file":"C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\@stacks\\cli\\src\\cli.ts","function":"CLIMain","line":1880,"method":null,"native":false},{"column":1,"file":"C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\@stacks\\cli\\src\\index.ts","function":null,"line":32,"method":null,"native":false},{"column":30,"file":"internal/modules/cjs/loader.js","function":"Module._compile","line":1063,"method":"_compile","native":false},{"column":10,"file":"internal/modules/cjs/loader.js","function":"Module._extensions..js","line":1092,"method":".js","native":false},{"column":32,"file":"internal/modules/cjs/loader.js","function":"Module.load","line":928,"method":"load","native":false},{"column":14,"file":"internal/modules/cjs/loader.js","function":"Module._load","line":769,"method":"_load","native":false},{"column":19,"file":"internal/modules/cjs/loader.js","function":"Module.require","line":952,"method":"require","native":false},{"column":18,"file":"internal/modules/cjs/helpers.js","function":"require","line":88,"method":null,"native":false},{"column":20,"file":"C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\@stacks\\cli\\dist\\index.js","function":null,"line":7,"method":null,"native":false},{"column":30,"file":"internal/modules/cjs/loader.js","function":"Module._compile","line":1063,"method":"_compile","native":false}]}
thanks for the follow-up @HariniRajan397. The CLI includes some pre-Stacks-2.0 functionality which was not updated since the release. it is likely fair to say that quite a few commands are deprecated and/or not supported anymore. BNS and Gaia commands are in that bucket.
@reedrosenbluth wanted to investigate more IIRC. Anything to add?
Thank you, Alex! Appreciate the support. I am confident that once cli is available, it will be extremely beneficial to the community.
Meanwhile, As discussed, adding the update here. We're also working with Mark&team to find out how to make the necessary changes at connect to allow user-selected storage at the app level. Thank you.
@HariniRajan397 - just to confirm: @friedger's PR is resolving _one_ of the issues, right?
@HariniRajan397 - just to confirm: @friedger's PR is resolving _one_ of the issues, right?
Yes, That's correct , Alex! Friedger's PR will help resolve the get_app_keys cli command. Thank you.
Most helpful comment
will review during the next sprint planning