Skip to content

Additional Features

dez1337 edited this page Oct 6, 2017 · 5 revisions

This page explains some additional features offered by SteemJ and provides some examples.

TOC

Recover Private Keys From Your Password

Getting your private keys using the Steemit.com Web-Interface can be hard and frustrating as a lot of questions at Steemit.com have shown in the past.

Because of that, SteemJ implements the getPrivateKeyFromPassword method which is already known from the Steemd-CLI-Wallet. This method allows you to regenerate your private posting, active and owner key from your Steemit.com password.

ImmutablePair<PublicKey, String> myActiveKeyPair = steemJ.getPrivateKeyFromPassword(new AccountName("dez1337"), PrivateKeyType.ACTIVE, "YOUR_STEEMIT_PASSWORD");

LOGGER.info("My active public key is {}.", myActiveKeyPair.getLeft().getAddressFromPublicKey());
LOGGER.info("My private WIF key is {}.", myActiveKeyPair.getRight());

Key Generator

SteemJ offers a class called KeyGenerator which can be used to generate new Key pairs accepted by the Steem Blockchain.

Generate a new Key Pair

SteemJ implements the "BrainKey Dictionary" introduced by Graphene. Due to that, SteemJ is able to generate new key pairs without any input from your side.

[...]
KeyGenerator keyGenerator = new KeyGenerator();
LOGGER.info("The generated private key is {}", keyGenerator.getPrivateKeyAsWIF());
[...]

Attention: The keys are generated randomly which makes it impossible to regenerate them if you loose one of the keys. Because of that you should make sure to save all key parts carefully.

[...]
LOGGER.info("I will write down all following keys because I know that I can't regenerate them:");
LOGGER.info("The generated brain key is {}", keyGenerator.getBrainKey());
LOGGER.info("The generated private key is {}", keyGenerator.getPrivateKeyAsWIF());
LOGGER.info("The generated public key is {}", keyGenerator.getPublicKey().getAddressFromPublicKey());
[...]

Generate multiple Key Pairs

The brain key is typically used to regenerate a password. Therefore you may want to use the same brain key for all keys (posting, active, owner, memo) of an account, so that you only have to keep one brain key in mind. The following snippet shows how to do so using SteemJ.

[...]
String myBrainKey = KeyGenerator.suggestBrainKey();
KeyGenerator keyGenerator = new KeyGenerator(myBrainKey, 0);
// Save the keys
[...]
// Generate a new key by increasing the sequence:
keyGenerator = new KeyGenerator(myBrainKey, 1);
// Save the keys
[...]
keyGenerator = new KeyGenerator(myBrainKey, 2);
// Save the keys
[...]

Back to TOC