lnwallet+lnrpc: add ability to fetch the last unused wallet addr #2661
In this PR, we add the ability to fetch the last unused wallet address over the RPC interface. This is useful for end-users UIs as they can spam this call at will without having to worry about potentially unbounded "address inflation".
The current implementation simply adds two new (previously unused) address types. This makes it easy for any existing UIs, as they don't need to switch to a brand new call (or even update their protos), and can instead just pass in the new address type. The alternative was to add a new RPC call all together. I opted to not pursue this approach, as it seemed wasteful to add an entirely new RPC call for what is really a modification on an existing call. Also given that was have soooo many RPC methods, adding a new enum type seemed more conservative.
bjarnemagnussen left a comment
I just took a look at this PR to learn about the LND codebase and found a tiny typo in the comments :) Furthermore I got a question with the unit test, which for my own learning I hope you could find the time to answer me at some point.
In this commit, we add two new address types to `NewAddressRequest`. These address types will allow the caller to retrieve the last _unused_ address, rather than always rotating to the next address in the keychain.
In this commit, we add a new `LastUnusedAddress` method to the `WalletController` interface. Callers can use this new method to graph the last unused address, which can be useful for UIs that want to refresh the address, but not cause nearly unbounded address generation. The implementation for `btcwallet` uses the existing `CurrentAddress` method. We've also added a new integration tests to exercise the new functionality.