lnd icon indicating copy to clipboard operation
lnd copied to clipboard

How to get address list?

Open 34ro opened this issue 8 years ago • 22 comments

Is there any way to find address list except note newaddress output? I think it is useful for checking address between lnd and wallet application. Does it intend preventing address reuse or just not yet?

34ro avatar Jan 02 '18 06:01 34ro

This would be very useful. Maybe lncli walletbalance can return addresses and balances.

gabbello avatar Jan 02 '18 13:01 gabbello

I missed new field of walletbalance. Thanks.

34ro avatar Jan 03 '18 16:01 34ro

By address list, do you mean the list of all addresses ever used by lnd?

Each call to newaddress will give you a unique address.

Roasbeef avatar Jan 04 '18 19:01 Roasbeef

My understanding is the possibility to list all used addresses, and their current balance.

halseth avatar Jan 05 '18 10:01 halseth

Yes, we need a way to list the addresses and their balance, not just total balance of the wallet.

gabbello avatar Jan 05 '18 13:01 gabbello

@gabbello It's already possible to do this with listchaintxns. It lists all transactions, and the addresses involved in those transactions. The missing aspect is including the outpoints produced and consumed. These are already stored within the database. Once this is in place, it's very straight forward to subtract all spends from credits from an address to derive the "balance" for an address.

I don't really see this being useful at all though as by default, the RPC interface will always rotate addresses.

Roasbeef avatar Jan 05 '18 14:01 Roasbeef

Thanks for your answer, I agree that this is just a nice to have given the above workaround. I encountered this need because I was generating multiple addresses (of different types) and then using faucets to credit them. Now since this was on testnet (and some faucets don't work/know how to send coins to SegWit addresses) I didn't note down the transactions or addresses.

After some time (e.g. next day) I noticed that I still don't have enough funds in my segwit address, but couldn't track what were the addresses which I tried to credit (so I can check them on some blockchain explorer). In the end it was proven that indeed the faucet I was using didn't broadcast the transaction correctly.

gabbello avatar Jan 05 '18 15:01 gabbello

I agree, a way to get the list of all wallet addresses generated in the past for this wallet would be great. I can find it in listchaintxns (transactions[].dest_addresses) but this list other addresses there, so it's not easy to parse.

lra avatar Mar 19 '18 06:03 lra

I was searching for that too yesterday. I spotted listchaintxns, but it lists other on chain addresses, and a lot of additional metadata, so it is hard to figure out things there. A list that shows a bit reversed view of just a list of elements like:

address -> { confirmed_balance, unconfirmed_balance, total_balance, total-input, total-output, [list-of-transaction-ids-and-amounts-sorted-by-block-height-or-something] },

with new addressed being simply:

address -> { 0, 0, 0, 0, 0, [] },

or something like this.

baryluk avatar May 12 '18 23:05 baryluk

I think we should recheck the correct address list before creating funding transactions. But listchaintxns doesn't show all controlled addresses inclusively. Just using newaddress is not completely safe if lnd is adding in a big payment system.

34ro avatar Jun 02 '18 10:06 34ro

Another use case I just encountered that would greatly benefit from this feature: you start a lnd node and create a wallet and send some BTC to it for funding channels, then a few weeks later you want to send more to fund more channels.

I had to rely on the address I saved in the exchange for sending the first transaction to cross-check with listchaintxns. I would have been a lot more confident to get this info from the lnd command-line. Please consider adding this feature.

glemercier avatar Sep 06 '18 07:09 glemercier

In this case can't you just make a new address? You should try to not ever re-use addresses under normal circumstances.

Roasbeef avatar Sep 07 '18 00:09 Roasbeef

An address list is useful for those addresses that have been "created" but never used, especially if many addresses are generated and the wallet is used elsewhere.

Derek701 avatar Sep 22 '18 02:09 Derek701

This is also something I have been wondering about.

When I started lnd, I didn't really know what I was doing. I ended up creating newaddresses. I forgot them as I was testing, but I'm struggling to find a command to list them. I definitely don't know how to use this software yet. So this is a noobs experience so far.

Maybe it isn't necessary? I guess I will follow roasbeef's advice and just make a new one.

ThomasJAnderson avatar Oct 03 '18 03:10 ThomasJAnderson

I think @Roasbeef is right, but as @Derek701 pointed out there is some legitimate use case for this feature. I guess we can call it "nice to have"

glemercier avatar Oct 03 '18 07:10 glemercier

can i be sure, that LND does never reuse an old address?

aggroLINUS avatar Oct 11 '18 03:10 aggroLINUS

@aggroLINUS Users can reuse their addresses but LND doesn't reuse old addresses when you request for a new address with command lncli newaddress ....

molxyz avatar Jan 25 '19 22:01 molxyz

I just want to see in which address I have how much bitcoin, in order to know the best strategy to open channels new channels (with the lowest amount of transaction)

manreo avatar Feb 13 '19 20:02 manreo

@MrManPew 0.6 will include a listunspent command that will show the wallet's utxos and amount in each

cfromknecht avatar Feb 13 '19 20:02 cfromknecht

With the addition of the ListUnspent RPC and its accompanying lncli listunspent command in the master branch, I think this can be closed.

wpaulino avatar Feb 13 '19 20:02 wpaulino