Bitcoin Forum

Bitcoin => Electrum => Topic started by: rpstatic on July 18, 2018, 07:54:53 AM



Title: Electrum: Can you recover new change addresses from seed?
Post by: rpstatic on July 18, 2018, 07:54:53 AM
I noticed a a nasty bug on the electrum wallet. If you use it regularly and don't have any change addresses left, electrum will create new ones for you.

If you then restore the wallet from the seed, the newly generated addresses aren't visible / availalable anymore. How can I check the correct balance on my new wallet? Would it be possible to sign from the missing change addresses?


Title: Re: Electrum: Can you recover new change addresses from seed?
Post by: mdayonliner on July 18, 2018, 09:25:47 AM
How can I check the correct balance on my new wallet?
Isn't it suppose to show the total balance for the wallet on the bottom left corner?

Quote
Would it be possible to sign from the missing change addresses?
I never had this experience however from common sense it should work since the address is associated with the same wallet/seed. May be it does not show by default. If you know the address then why don't you try a test sign for the address?


Good luck.


Title: Re: Electrum: Can you recover new change addresses from seed?
Post by: OmegaStarScream on July 18, 2018, 11:21:48 AM
Which version are you using? I'm not aware of such a bug but assuming this is a display issue only:

If you want to check your balance (console command):

Code:
getbalance()

To get all your addresses that have funds inside them:

Code:
listunspent()

After having your address, you could sign a message like this (It will ask you to type your password If you have any):

Code:
signmessage('address_here', 'Message_here')


Title: Re: Electrum: Can you recover new change addresses from seed?
Post by: bob123 on July 18, 2018, 11:55:46 AM
AFAIK electrum unfortunately does only allow to create new 'receiving' addresses via the console, but no change addresses.

In order to derive more change addresses from your seed, you will have to use another wallet/tool to derive them.

Since electrum does not use BIP39, you will have to export the master private key of your wallet.
To do this, you will have to open the console ('View' -> 'Show Console' -> 'Console'-tab). Then enter this command:

Code:
getmasterprivate()

This will print you out your mpk (will start with xprv..).

Afterwards either import it into another wallet (using the derivation path: m/44'/0'/1'/, for receiving-addresses: m/44'/0'/0'/ ) or download this site (https://iancoleman.io/bip39/ (https://iancoleman.io/bip39/)) and run it on an offline PC to generate the private keys of your addresses (which you afterwards can import into another wallet).


Title: Re: Electrum: Can you recover new change addresses from seed?
Post by: BitMaxz on July 18, 2018, 10:45:48 PM
I just want to add this --> You can disable the change address feature by going to tools>preferences>Click the transaction tab
then uncheck "use change addresses" so that if you send a bitcoin the electrum wouldn't make a new change address again then after that if you want to merge all of your balances in one bitcoin address just send all bitcoins to your own bitcoin address.


Title: Re: Electrum: Can you recover new change addresses from seed?
Post by: Abdussamad on July 19, 2018, 06:36:07 AM
what version of electrum are you using and what is your operating system?

it should generate the new change addresses automatically on restore. try switching servers via tools > network, right click on a server and select use server. If that doesn't do it go to wallet menu > addresses > filter then on the addresses tab you can fine tune the display using the filter selections up top. See if you can find the missing change address. ctrl+f can also be used to search for addresses on the addresses tab.



Title: Re: Electrum: Can you recover new change addresses from seed?
Post by: Abdussamad on July 19, 2018, 06:37:10 AM
AFAIK electrum unfortunately does only allow to create new 'receiving' addresses via the console, but no change addresses.

you can generate new change addresses via wallet.create_new_address(True). put in a loop to make many change addresses.


Title: Re: Electrum: Can you recover new change addresses from seed?
Post by: Abdussamad on July 19, 2018, 06:37:41 AM
I just want to add this --> You can disable the change address feature by going to tools>preferences>Click the transaction tab
then uncheck "use change addresses" so that if you send a bitcoin the electrum wouldn't make a new change address again then after that if you want to merge all of your balances in one bitcoin address just send all bitcoins to your own bitcoin address.

this is bad for your privacy and security and is not recommended.


Title: Re: Electrum: Can you recover new change addresses from seed?
Post by: bob123 on July 19, 2018, 01:59:46 PM
AFAIK electrum unfortunately does only allow to create new 'receiving' addresses via the console, but no change addresses.

you can generate new change addresses via wallet.create_new_address(True). put in a loop to make many change addresses.

No. This does not work. Typos are evil.

This command worked in older versions of electrum.
The current command to create an address in electrum is createnewaddress().

There is no way to actually create a change address via the command line (afaik). createnewaddress doesn't take any parameters.


Title: Re: Electrum: Can you recover new change addresses from seed?
Post by: HCP on July 20, 2018, 09:01:05 AM
you can generate new change addresses via wallet.create_new_address(True). put in a loop to make many change addresses.
No. This does not work.

Yes. It does:

Quote
>> wallet.create_new_address()
'bc1q7d0yqv39nmerhzxreakzhd8d28wn350kgv244e'
>> wallet.create_new_address(True)
'bc1q0x0d36v4wuz7yq629qwwu683qpxzxuk8chdv89'
>>
Which results in this:
https://talkimg.com/images/2023/11/15/z8wP3.png

You can see that the wallet.create_new_address(True) command created the 'bc1q0x0d...' address which is shown as a "change" address.

As Abdussamad said, if you want to generate multiples... use a loop like this:
Code: (Create 100 new change addresses)
for i in range(0, 100): print wallet.create_new_address(True)

Code: (Create 100 new "receive" addresses)
for i in range(0, 100): print wallet.create_new_address(False)


NOTE: the "True" and "False" are Case-sensitive...


Title: Re: Electrum: Can you recover new change addresses from seed?
Post by: bob123 on July 20, 2018, 09:16:05 AM
You can see that the wallet.create_new_address(True) command created the 'bc1q0x0d...' address which is shown as a "change" address.

Weird.. i am certainly sure that this hasn't worked when i tried it..
Unfortunately this command doesn't appear in the list of commands (help()).


I guess this was my mistake  ::)

NOTE: the "True" and "False" are Case-sensitive...


Title: Re: Electrum: Can you recover new change addresses from seed?
Post by: pooya87 on July 20, 2018, 12:13:28 PM
very interesting. i messed around a little based on comments here and here is what i figured (my knowledge of Python is still zero :P) correct me if i am wrong.

when you call createnewaddress() inside the console, you are running a predefined command. so you are basically accessing this here (https://github.com/spesmilo/electrum/blob/01193be241fa1cafa263658750ed6b999e4701dc/electrum/commands.py#L580-L582) which calls wallet.create_new_address() which passes False as its argument.

when you call wallet.create_new_address() you are calling the method itself directly from wallet.py file (https://github.com/spesmilo/electrum/blob/597295e35931f001dce80cc30937911d6b2229b0/electrum/wallet.py#L1418-L1429) and False is just telling it that it is a receiving address not a change.
now what i don't get is that whether this is a python thing that you can call methods from one of the classes or whether the console.py (https://github.com/spesmilo/electrum/blob/master/electrum/gui/qt/console.py) file is responsible. i have tried reading it but honestly i have no idea what is happening there ...