How do I my reveal my private owner and private payment keys in the Blockstack Browser?
In the CLI I can do this through ‘sudo blockstack wallet’. Is there a way to display wallet information for an .id through the Browser interface?
I am asking because I would like to amend my config.json file for Subdomain Registrar purposes to allow for sponsored names to be registered against a (domain)name that has been registered through the Browser.
Not from the Browser, but I think @aaron has a way for turning your 12-word phrase into your owner private key on the command-line, with node.js. I’ll let him answer.
The “trick” I use to get the identity key out of the browser is to open the javascript console and enter the following:
var ix = 0
var reduxState = JSON.parse(localStorage.redux)
var state = reduxState.committedState[reduxState.currentStateIndex]
// get the 0th identity address
state.state.account.identityAccount.keypairs[ix].address
// get the 0th identity key
state.state.account.identityAccount.keypairs[ix].key + '01'
That gives you the ownerKey of the 0th-index account in the browser. To get a different index, use a different value for ix.
To get a payment key, I always just generate a new one for a subdomain registrar. There’s many different ways to generate a private key and bitcoin address, but I usually just use node and bitcoinjs-lib. So, from a directory with bitcoinjs installed (just create a new directory and run npm install bitcoinjs-lib), run node and then these commands will make a bitcoin address and private key string:
var btc = require('bitcoinjs-lib')
var paymentPair = btc.ECPair.makeRandom()
var paymentAddress = paymentPair.getAddress()
var paymentKey = paymentPair.d.toHex() + '01'
To fund that paymentKey, you can just send bitcoin to the paymentAddress.
@aaron Will there be a way to reveal these through the Blockstack Browser at some point? I am asking because it would make it a lot easier to reveal keys for the purpose of running a Subdomain Registrar. Thank you.
@aaron when running this in Google Chrome Console while having the Blockstack Browser open (in Windows 10) I get the following response:
// get the 0th identity address
state.state.account.identityAccount.keypairs[ix].address
// get the 0th identity key
state.state.account.identityAccount.keypairs[ix].key + ‘01’
VM151:1 Uncaught TypeError: Cannot read property ‘state’ of undefined
at :1:7
(anonymous) @ VM151:1
Edit: have tried this in the Blockstack Browser App and browser.blockstack.org both in Chrome. Getting the same error message.
@aaron generating the payment key with Node works great, thank you.
@chris-asl, have you tried using the experimental Blockstack CLI? It works quite well and is easy to use if you need your owner and payment keys. I did a video where I go over the install (it was more for the Stacks Testnet, but I covered how to install the new CLI after I talked about blockstack.js) and then you can use the following command:
blockstack-cli make-keychain [“12 word mnemonic phrase”]
Make sure you wrap the 12 word phrase in “quotes” otherwise it’ll come back with the wrong ID address and keys.
Thank you very much for the helpful video @Kitsana!
I was able to set it up, with an extra step in the end.
After npm install in the cli-blockstack directory, I had to run npm link in order to get the CLI as an executable.
From that point, I was able to run blockstack-cli, otherwise I was getting command not found errors from my shell.
Running the following commands in Chrome’s developer console (while on your Blockstack Browser’s Identity page) should return the information you need:
var ix = 0
var reduxState = JSON.parse(localStorage.redux)
var state = reduxState.computedStates[reduxState.currentStateIndex]
state.state.account.identityAccount.keypairs[ix].address
state.state.account.identityAccount.keypairs[ix].key + ‘01’
Sorry I think I misunderstood, but that code is running in an application, and if you are running from dev tools you need blockstack.js in the global scope.
I am not sure how to do it from the blockstack browser if you are trying to get the private key for your Bitcoin wallet. It might not be possible for security reasons.