1

I generate a code to create wallets for a private chain made with ethereum.

String password = unlockAccountParameter.getPass();
        ECKeyPair keyPair = Keys.createEcKeyPair();
        WalletFile wallet = Wallet.createStandard(password, keyPair);

        System.out.println("Private key: " + keyPair.getPrivateKey().toString(16));
        System.out.println("Account: " + wallet.getAddress());

        String fileName = WalletUtils.generateNewWalletFile(unlockAccountParameter.getPass(), new File("C:\\Users\\emendez\\Wallet"), true);

        System.out.println("File name: " + fileName);

Thats return me this output:

Priate key: 67f7a218d5d595dff19cafca9384b5a6e0693bc085d7c16468b8a8a44e20135a Account: bf29892787a79bb66188f9c44ca9ffd9ccff37aa

File name: UTC--2018-11-15T12-26-51.672000000Z--252209a58e16be3c43776e38ff4bfaeb70660cfb.json

The JSON file is in the path that write in code (in the real machine). But when I go to the geth console for list the account that are created in the node (virtualmachine) the account that I just created does not appear.

So i think that i cant make transaction between them.

Any help??

2

The problem might be related to the location where you are storing your wallet.

To be automatically detected, the wallet file needs to be stored in a folder called keystore inside the folder where geth is installed. These are the most common paths:

– Mac: ~/Library/Ethereum

– Linux: ~/.ethereum

– Windows: %USERPROFILE%\AppData\Roaming\Ethereum

If you can't access that folder, you can import your account by using this command:

geth account import --datadir /fileWithOnlyPrivateKey --password /fileWithPasswordStringToEncryptThatKey ./key.prv

And your final solution would be to generate the transaction in your code, and send the transaction already signed to the node (This would be the safest approach if you can keep your private key safe), look into web3 to learn how to do that

  • And it have sense to save my wallet in the net?? Im mean mi personal wallet I save in my pocket. Im new so its probably a idiot question. Thx – UnexpectedCharacter Nov 16 '18 at 9:35
  • This would store your wallet on your geth node, not on the net, you can even make it so that information is only its only accesible from localhost. That said, in some cases, you want your app to be in a different server than your node, in that case, you wouldn't want to keep your wallet in the node, you can keep in anywhere, read the private key, sign the transactions locally and send them signed. These are the main libraries for that: web3, ether.js, or the ethereumjs libraries (I recommend web3) – Enrique Alcazar Nov 19 '18 at 21:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.