lukechampine/us

Reuse addresses to form/renew contracts

jkawamoto opened this issue · 4 comments

Reusing addresses seems urgent. Our wallet that is running for about one month has 831432 addresses already. Although one of the reasons might be it retries forming/renewing contracts so many times because of wallet conflict, it may be going to run out of memory.

I think the simplest way to handle this would be something like:

w.AllowAddressReuse(true)
cur := w.CurrentAddress() // panic/error if AllowAddressReuse == false
next := w.NextAddress() // works the same as it does now
cur2 := w.CurrentAddress() // cur2 == next

In other words, you first need to enable reuse, then you can call CurrentAddress. Then you call NextAddress whenever you want to start using a new address.

How about CurrentAddress generate a new address if AllowAddressReuse is false and proto package always uses it? It'd avoid adding error handling after CurrentAddress.

yeah, I think if AllowAddressReuse == false (the default), then CurrentAddress would return a new address, just like NextAddress. Most code would use CurrentAddress to get a wallet address, and only use NextAddress when necessary.

One of our siad that was used to form contracts with us now has 12030 outputs 😮

wallet

Then, we cannot send the remaining coins to another wallet... We don't use siad as a wallet and this wouldn't be a problem in future but it'd be better this issue is fixed at some point.