1

I want to generate both the monerowallet and monerowallet.keys files, but I can't find any resources on how to do it. The cli tools offer a --generate-new-wallet, but it requires manual overhead and user input. Is there any good way to do this?


Update:

Using monero-python I can generate all the keys, but even using the monero-wallet-cli's --generate-from-json it still prompts for user input so I can't do it that way either.

Dr-Bracket
  • 483
  • 3
  • 19
  • What do you mean by "but it requires manual overhead"? What's your use-case? – jtgrassie Mar 22 '19 at 03:56
  • --generate-from-json doesn't prompt for input if all the required parameters are in the json file. Also, you don't need to pre-generate any keys, just a seed. See my answer. – jtgrassie Mar 22 '19 at 04:02

2 Answers2

4

In bash, just:

monero-wallet-cli  --create-address-file --password password123 --mnemonic-language English --generate-new-wallet ./new.wallet

You can enumerate new.wallet with a variable. Just wait a few seconds and (p)kill the client before moving on to next.

Dave
  • 484
  • 1
  • 3
  • 8
3

You have a couple of options.

One option is to have a running wallet RPC: monero-wallet-rpc --wallet-dir . --rpc-bind-port 18085 --disable-rpc-login

Which you can then call its create_wallet method like:

curl -X POST http://localhost:18085/json_rpc -d \
  '{"jsonrpc":"2.0","id":"0","method":"create_wallet","params":\
  {"filename":"monerowallet","password":"pass","language":"English"}}' \
  -H 'Content-Type: application/json'

Another option would be to use monero-wallet-cli --generate-from-json wallet.json when you have a wallet.json with content like:

{
  "version": 1,
  "filename": "monerowallet",
  "scan_from_height": 1796000,
  "password": "pass",
  "seed": "some valid seed ..."
}

But of course that requires you to have already created a seed.

Lastly, another approach I've seen used is to create a wrapper script around monero-wallet-cli --generate-new-wallet which uses redirection to echo input to the monero-wallet-cli processes stdin. There are many ways to accomplish this and is very much shell specific.

The RPC method is probably your best option (without knowing your use-case).

jtgrassie
  • 19,111
  • 4
  • 14
  • 51