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?
3 Answers
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
- 19,601
- 4
- 17
- 54
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.
- 187
- 4
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'
- 26
- 1