1

Is there a way to pre-generate 1000 subaddresses from your monero private key? And then say I sent some xmr to the 979th subaddress, would the wallet see it or do I need to do something first?

1

3 Answers 3

1

During wallet generation, set "subaddress-lookahead" higher than default like previously mentioned, example 50:1000. Generate the wallet with the predetermined subaddress lookahead using the flag --subaddress-lookahead 1000

Then, run bash to generate the subaddresses by calling RPC "create_account" method.

In the examples below be sure to make the following changes. Change 12345 to match your wallet RPC-bind-port. Change the integer 1000 to suit your preferred amount of accounts to generate.

#!/bin/bash
x=1
while [ $x -le 1000]
do
  echo "Generated $x Subaddress wallets"
  curl http://localhost:12345/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"create_account","params":{"label":"Subaddress account"}}' -H 'Content-Type: application/json'
  x=$(( $x + 1 ))
done

When done, call RPC method "store" to save the wallet cache.

curl http://127.0.0.1:12345/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"store"}' -H 'Content-Type: application/json'
1
  • create_account creates new accounts (with the first address for the account). create_address creates just addresses (within an account). Given the question, create_address is probably more suitable.
    – jtgrassie
    Commented Oct 18, 2020 at 9:44
3

Is there a way to pre-generate 1000 subaddresses from your monero private key?

Generating subaddresses from a private view key explained in this answer and on the monerodocs site here.

And then say I sent some xmr to the 979th subaddress, would the wallet see it or do I need to do something first?

The default wallet lookahead indices are set to 50:200 (50 accounts, 200 subaddresses). So if you are creating the subaddresses outside of the wallet (so manually constructing them from the wallet private view key), you will need to tell the wallet about them. You can do this in the monero-wallet-cli via the set command: set subaddress-lookahead 50:1000

2
  • The docs give the math and functions on how to generate it yourself, but isn't there just a simple command on the monero-cli to just output X number of subaddressses? Commented Aug 18, 2019 at 14:55
  • Apologies I read the question as wanting to do this outside of the wallet (as you mentioned "private key"). There isn't a batch address new. You could easily script the cli though to run address new 1000 times. There are other answers on how to script the cli. If you script address new, you won't need to set the lookahead.
    – jtgrassie
    Commented Aug 18, 2019 at 15:06
3

I made an offline command-line tool, subaddress-derive-xmr, that derives any number of subaddresses from mnemonic, seed, or priv-view-key + pub-spend-key.

Usage would look like:

$ ./subaddress-derive-xmr --seed="66dcbb7490ee34dad1b04fa316b90ba1795ce70586298e2cc09455de1ae95273" -g --numderive=3

+-------------+-------------+-------------------------------------------------------------------------------------------------+
| major_index | minor_index | address                                                                                         |
+-------------+-------------+-------------------------------------------------------------------------------------------------+
|           0 |           0 | 49zf2PF7nLSHpRwWcPG8ePHxYnR6eFmYuKG8Akpq5vFALTzZzMdv3kC36fCSP3UfFdMrY51QAs5NGiGuwXK6YMa3Nk7549x |
|           0 |           1 | 87i7kA61fNvMboXiYWHVygPAggKJPETFqLXXcdH4mQTrECvrTxZMtt6e6owj1k8jUVjNR11eBuBMWHFBtxAwEVcm9dcSUxr |
|           0 |           2 | 8A9XmWsATrhfedtNhTMNKELwfCwMVAk2iVTdUJdFRb2AC4tV4VeBjsCLYR9cSQTwnvLo4MAuQFMLP6Si4xp6t6BS788db3t |
+-------------+-------------+-------------------------------------------------------------------------------------------------+

Just change to --numderive=1000 for 1000 addresses.

See usage docs for how to derive using mnemonic or view+spend keys or to change formatting of results.

2
  • How does one prove you don't have the seed to all those addresses? An offline computer isn't going to work. Just curious... Commented Oct 15, 2019 at 16:34
  • 1
    To be certain, one would have to review the code to one's own satisfaction. I can tell you that the code I use for generating the seed and performing the derivations is from the monerophp library by the monero-integrations project, which I understand has earned considerable trust/rep in the monero community. However I would very much welcome a code review/audit by a 3rd party.
    – danda
    Commented Oct 16, 2019 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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