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.

  • What do you mean by "but it requires manual overhead"? What's your use-case? – jtgrassie Mar 22 at 3: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 at 4:02
2

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).

2

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.

  • In addition to my answer, this works too. – jtgrassie Mar 22 at 12:33

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.