Bitcoin Forum

Bitcoin => Electrum => Topic started by: clue_less on May 01, 2020, 07:37:48 AM



Title: [Solved] electrum listaddresses --funded | What does funded mean?
Post by: clue_less on May 01, 2020, 07:37:48 AM
When I run the command with CLI: electrum listaddresses --funded | electrum getprivatekeys - it returns 75 keys.
However when I run it like this: electrum listaddresses| electrum getprivatekeys - it lists all of my 100 keys. Same as what it shows in the GUI version.
Why is this? What does funded mean? I believe all of my keys should be funded since I've received them and transactions are OK.


Title: Re: electrum listaddresses --funded | What does funded mean?
Post by: TryNinja on May 01, 2020, 07:47:46 AM
AFAIK, funded means addresses that received transactions at some point (or not empty as the name suggests? at least, mine seems to behave differently).

75 addresses got coins.
35 didn't get coins.
100 total addresses.

You always have more addresses than what you used, so your total is usually bigger than the number of funded.


Title: Re: electrum listaddresses --funded | What does funded mean?
Post by: HCP on May 01, 2020, 07:49:24 AM
"funded" means that they currently have some coins in them... so "empty" addresses that may have received coins at some point, but that currently have a 0.00 balance are not shown when you use the "--funded" command.


Title: Re: electrum listaddresses --funded | What does funded mean?
Post by: NeuroticFish on May 01, 2020, 08:13:46 AM
HCP is correct. I'll just add the part of the doc for reference.

Export private keys and sweep coins
The following command will export the private keys of all wallet addresses that hold some bitcoins:

electrum listaddresses --funded | electrum getprivatekeys -


Title: Re: electrum listaddresses --funded | What does funded mean?
Post by: clue_less on May 01, 2020, 03:35:11 PM
But what happened to the coins that were in the private keys that were not 'funded'? Because the transactions record that coins went to that private address.
Or were they just amalgamated at some point in the course of transactions? I just want to make sure I didn't lose coins somewhere.


Title: Re: electrum listaddresses --funded | What does funded mean?
Post by: Abdussamad on May 01, 2020, 05:21:37 PM
But what happened to the coins that were in the private keys that were not 'funded'? Because the transactions record that coins went to that private address.
Or were they just amalgamated at some point in the course of transactions? I just want to make sure I didn't lose coins somewhere.

When you spend bitcoin some coins end up in change addresses so that's probably what happened:

https://en.bitcoin.it/wiki/Change

https://en.bitcoin.it/wiki/Coin_analogy


That's why we use wallet software to manage all this instead of dealing with raw private keys because there's a risk you will make a mistake and lose money.


Title: Re: electrum listaddresses --funded | What does funded mean?
Post by: clue_less on May 01, 2020, 07:16:34 PM
@Abdussamad
I completely understand (and I made sure I understood that before I went to Bitcoin) that and  I've done all my transactions with the wallet. Yet as TryNinja said, it seems one generates more private addresses than used because the total is bigger than the keys funded. I know this because when ask electrum for the value of the funded keys (i.e. sweeping) it generates fewer keys than my total but the value is equivalent to what I have in all my private keys. 


Title: Re: electrum listaddresses --funded | What does funded mean?
Post by: HCP on May 01, 2020, 10:29:32 PM
But what happened to the coins that were in the private keys that were not 'funded'? Because the transactions record that coins went to that private address.
Or were they just amalgamated at some point in the course of transactions? I just want to make sure I didn't lose coins somewhere.
The short answer is that you spent them ;)


When you send coins out, Electrum (unless instructed otherwise using coin control or privacy features etc) will generally select the most 'efficient' set of UTXOs that makes up the amount to be sent, while minimising the size of the transaction...

That is to say... assume you have:

1AddressA = 0.00012448
1AddressB = 0.00145671
1AddressC = 0.00248822
1AddressD = 0.00292394

In the background you'd actually have something like 25+ addresses automatically generated, so:
listaddresses - Would show 25+ keys
listaddresses("funded") - would only show the 4 addresses with coins, A,B,C & D

Now let's say you want to send 0.004 BTC to Bob... You don't have any UTXOs of 0.004 (or more), so the wallet has to combine several.

It could use any of the following combinations:
A+B+C     0.00406941
B+D         0.00438065
C+D         0.00541216
A+B+D     0.00450513
A+C+D     0.00553664
A+B+C+D 0.00699335

Let's say that Electrum decides to use B+D... it'll "spend" the UTXOs on those addresses (remember, in bitcoin you have to spend the whole amount, you don't spend partials), and then send 0.004 to BTC to Bob and return any leftovers (- transaction fee) to a change address... so you'll end up with:

1AddressA = 0.00012448
1AddressB = 0.00000000
1AddressC = 0.00248822
1AddressD = 0.00000000
1Change1 = 0.00037800 (0.00038065 - an imaginary 265 sat transaction fee)


Now if you do:
listaddresses() - you'd see exactly the same number of addresses as before
listaddresses("funded") - you would only see THREE addresses... A, C & Change1... because they're the only ones that currently contain coins.


Scenario 2. If Electrum had used A+B+C+D... your wallet would now look like this:

1AddressA = 0.00000000
1AddressB = 0.00000000
1AddressC = 0.00000000
1AddressD = 0.00000000
1Change1 = 0.00299000 (0.00299335 - an imaginary 335 sat transaction fee)

And if you did:
listaddresses() - You'd still see exactly the same number of addresses as before... ie. ALL of your addresses
listaddresses("funded") - You'd now only see ONE address... Change1... as... that is the only address with coins in it.



All that being said, it might be easier to visualise with the GUI. If you haven't already, enable the filter on the "addresses" tab.:
https://talkimg.com/images/2023/11/15/zjPEq.png

Then you can set to:
- "All" + "All" - shows EVERY address (ie. zero balance, non-zero balance and zero transactions etc.)
https://talkimg.com/images/2023/11/15/zjR5j.png


- "All" + "Unused" - Shows only addresses that have a zero balance and a zero number of transactions.
https://talkimg.com/images/2023/11/15/zjtUG.png


- "All" + "Funded" - Shows only addresses that have a non-zero balance
https://talkimg.com/images/2023/11/15/zjzRD.png


- "All" + "Used" - Shows addresses that have a zero balance, but also have a non-zero number of transactions (ie. they did have coins in them at some point, but they are now empty)
https://talkimg.com/images/2023/11/15/zjF1f.png


NOTE: you will always have "unused" addresses because Electrum, by default, has a gap limit of 20. So you will always have at least 20 "zero balance and zero transaction" addresses. Therefore, it should not come as a surprise, that "funded" will return less than "All"... even if you have only ever received coins and never spent any.



Title: Re: [Solved] electrum listaddresses --funded | What does funded mean?
Post by: clue_less on May 02, 2020, 06:13:13 AM
Thanks for the reply HCP! That answered my question very well.


Title: Re: electrum listaddresses --funded | What does funded mean?
Post by: Abdussamad on May 02, 2020, 12:19:05 PM
@Abdussamad
I completely understand (and I made sure I understood that before I went to Bitcoin) that and  I've done all my transactions with the wallet. Yet as TryNinja said, it seems one generates more private addresses than used because the total is bigger than the keys funded. I know this because when ask electrum for the value of the funded keys (i.e. sweeping) it generates fewer keys than my total but the value is equivalent to what I have in all my private keys. 

When you sweep it's sending the funds to an address in the new wallet. So it's not incorporating the old wallet's private keys into the new wallet. They are called private keys btw and not private addresses.

If you want to incorporate the old wallet's priv keys into a new wallet you have to create an imported private key wallet:

https://bitcoinelectrum.com/importing-your-private-keys-into-electrum/