wavesplatform / Waves

⛓️ Reference Waves Blockchain Node (client) implementation on Scala
https://wavesplatform.com/
MIT License
1.17k stars 417 forks source link

A way to bulk generate addresses when restoring wallet. #3363

Open Crypto2 opened 3 years ago

Crypto2 commented 3 years ago

When you are restoring a wallet with the RPC there isn't a way I see to regenerate all your addresses except to POST to /addresses in an endless loop that can be hours/days long.

Would be good if there was an RPC to restore up to a specified index, and maybe when you generate an address it returns in the current index as well so that could be stored for later reference.

DrBlast commented 3 years ago

@Crypto2 what kind of business case do you have that you need to create about million addresses per day? Why don't you want to use one of our libs or create your own to sign and broadcast transaction using lib, not node? It could be much faster if you are using a library

Crypto2 commented 3 years ago

I'm not generating millions/day, I said that's how long it takes to restore a wallet if it crashes/corrupts and you have to restore from seed and you had a bunch of addresses in the wallet.

There isn't a Waves SDK in my language so I can't use one of them.

DrBlast commented 3 years ago

What language do you use? I've tried to restore addresses, it took about 10ms per address.

Crypto2 commented 3 years ago

PHP, this is over the RPC to the internal wallet. Individual addresses are fast, it's just when you have thousands+ of them it adds up to a lot of time.

For example if you had 100,000 addresses * 10 ms = 1,000,000 ms / 60,000 (1 hour) = 16.6 hours.

DrBlast commented 3 years ago

deemru wrote a lib for php: https://github.com/deemru/WavesKit

1 hour contains 3600 seconds = 3600000 ms 1,000,000 / 3600000 = 0.27

Crypto2 commented 3 years ago

That doesn't really help existing systems that use the internal wallet, versus rewriting the whole integration to use a new lib. (When we did the integration Waves was super new and nothing really existed for it yet in PHP.)

I can tell you in real-world we have ~1 million addresses and even using multiple threads it took over 24 hours to regenerate the addresses even using the sequence API that supports like 100 at a time.

DrBlast commented 3 years ago

Why don't you backup wallet.dat? You can restore file with already created addresses if smth failed.