This is going to quickly cause a big slowdown in your node, because z_getnewaddress gets a new spending key, and the speed of node scanning is linear in the number of spending keys.
For your given workflow, I would instead recommend generating diversified addresses. This allows you to generate multiple payment addresses backed by the same spending key. You would generate a diversified address for each user (could be one per user, or a fresh one every time), and then when a user sends you funds, you can detect which address the funds came from (to determine which user sent the funds).
With diversified addresses, there is no need to move funds to the master address, because the funds are already there
I have 3 cmd, but can’t gen a diversified address from the viewing key.
the error: Invalid mainnet Sapling viewing key
But I want to gen a testnet diversified address
Can you check for me? Many many thanks!
woa, it works for me. Thank you I love you.
ah how to build this to an execute file.
ex: cargo run --example diversify-address --<viewing_key> <index>
to: ./gen_diversify_address --<viewing_key> <index>
Yes, this is expected: not every diversifier index results in a valid Sapling address (on average half of the 288 diversifiers will be invalid).
The example tool starts searching for the next Sapling address starting from the index you provide, and it returns the closest index for which it could find a valid address. You will need to account for this in your code.