Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lnwallet+lnrpc: add ability to fetch the last unused wallet addr #2661

Merged
merged 3 commits into from Mar 6, 2019

Conversation

Roasbeef
Copy link
Member

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.

Copy link
Contributor

@bjarnemagnussen bjarnemagnussen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

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.

lnwallet/btcwallet/btcwallet.go Outdated Show resolved Hide resolved
lnwallet/interface.go Outdated Show resolved Hide resolved
lnwallet/interface_test.go Show resolved Hide resolved
lnwallet/btcwallet/btcwallet.go Outdated Show resolved Hide resolved
lnwallet/btcwallet/btcwallet.go Outdated Show resolved Hide resolved
rpcserver.go Outdated Show resolved Hide resolved
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.
@Roasbeef
Copy link
Member Author

Roasbeef commented Mar 5, 2019

Comments addressed, PTAL @cfromknecht!

Copy link
Contributor

@cfromknecht cfromknecht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👏

Copy link
Contributor

@wpaulino wpaulino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🕹

@wpaulino wpaulino merged commit 63273e1 into lightningnetwork:master Mar 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants