-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
lnrpc+lnwallet: adds listaddresses RPC #6596
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks very promising! I think we can re-use the code from ListAccounts
to avoid some code duplication.
424318d
to
4fdaffe
Compare
df1a8f7
to
eb69b90
Compare
eb69b90
to
a9c006a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a round of manual testing and found a few things that can be optimized. But I really like this feature, it makes debugging things around wallet balances so much easier! So great work thus far!
c28345e
to
5d06c22
Compare
Here's the diff I'm proposing: diff --git a/lnwallet/btcwallet/btcwallet.go b/lnwallet/btcwallet/btcwallet.go
index 14f9e3d7d..58db4322e 100644
--- a/lnwallet/btcwallet/btcwallet.go
+++ b/lnwallet/btcwallet/btcwallet.go
@@ -739,29 +739,48 @@ func (b *BtcWallet) ListAddresses(name string) (
}
for _, accntDetails := range accounts {
+ scopedMgr, err := b.wallet.Manager.FetchScopedKeyManager(
+ accntDetails.KeyScope,
+ )
+ if err != nil {
+ return nil, err
+ }
+
// Retrieve all addresses of an account.
- addresses, err := b.wallet.AccountAddresses(accntDetails.AccountNumber)
+ var managedAddrs []waddrmgr.ManagedAddress
+ err = walletdb.View(
+ b.wallet.Database(), func(tx walletdb.ReadTx) error {
+ addrmgrNs := tx.ReadBucket(waddrmgrNamespaceKey)
+ return scopedMgr.ForEachAccountAddress(
+ addrmgrNs, accntDetails.AccountNumber,
+ func(a waddrmgr.ManagedAddress) error {
+ managedAddrs = append(
+ managedAddrs, a,
+ )
+
+ return nil
+ },
+ )
+ },
+ )
if err != nil {
return nil, err
}
// Only consider those accounts which have addresses.
- if len(addresses) == 0 {
+ if len(managedAddrs) == 0 {
continue
}
- addressProperties := make([]lnwallet.AddressProperty, len(addresses))
-
- for idx, address := range addresses {
- addressInfo, err := b.wallet.AddressInfo(address)
- if err != nil {
- return nil, err
- }
-
- addressString := address.String()
+ addressProperties := make(
+ []lnwallet.AddressProperty, len(managedAddrs),
+ )
+ for idx, managedAddr := range managedAddrs {
+ addr := managedAddr.Address()
+ addressString := addr.String()
addressProperties[idx] = lnwallet.AddressProperty{
Address: addressString,
- Internal: addressInfo.Internal(),
+ Internal: managedAddr.Internal(),
Balance: addressBalance[addressString],
}
} |
5d06c22
to
0dac5b0
Compare
a487103
to
1231806
Compare
36234e8
to
7d81bce
Compare
35d6dac
to
b9a1ff7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking very good, I like the new flag!
Mostly style nits and the integration test that needs some adjustment. But we're getting very close!
b9a1ff7
to
08bb5b3
Compare
36437f0
to
83d3449
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK, LGTM 🎉
Very nice work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! Just a few nits.
needs rebase |
83d3449
to
d65bd77
Compare
@bhandras: review reminder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, nice work @priyanshiiit 🎉
My only comment here is to perhaps change the loop order in the test case to make sure we don't pass on skipped addresses.
d65bd77
to
468fa22
Compare
468fa22
to
98a6e5d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just one tiny last comment 🎉
98a6e5d
to
ec53b61
Compare
Change Description
Related: #2498
Command:
lncli wallet addresses list --account_name "default"
Steps to Test
Steps for reviewers to follow to test the change.
Pull Request Checklist
Testing
Code Style and Documentation
[skip ci]
in the commit message for small changes.📝 Please see our Contribution Guidelines for further guidance.