spesmilo / electrum

Electrum Bitcoin Wallet
https://electrum.org
MIT License
7.44k stars 3.09k forks source link

CPFP reuses addresses #6413

Open ziggamon opened 4 years ago

ziggamon commented 4 years ago

Most recent master.

CPFP transaction A CPFP transaction B

Notice they both get sweeped to the same address. No way in UI to select address to which they would get sent in the CPFP feature either.

github12101 commented 4 years ago

There is no links in your report - please add transaction A or B you mentioned.

gits7r commented 4 years ago

also please specify what kind of wallet you are using? standard p2wpkh? or something else?

SomberNight commented 4 years ago

https://github.com/spesmilo/electrum/blob/52f8aafb604d05487a0612f65bacb966c0d0f569/electrum/wallet.py#L1439

The wallet always picks an unused address. If there are no unused addresses (which can happen as the gap limit is only rolled forward after 3 confirmations), it falls back to re-use the "input address".

One idea I have is that you CPFP-ed two transactions "in parallel", and by that I mean you haven't broadcasted/saved the first CPFP tx before starting the flow for the second. This way the address picked by the first flow would still be unused when you start the second flow and would get re-picked.

ziggamon commented 4 years ago

Sorry, prefer to not publish transactions here for privacy reasons, and currently don't have access to the computer with the wallet.

The wallet is a standard p2wpkh.

I don't know but maybe this is related to a previous bug in which receive addresses weren't removed from the list of unused until the transaction confirms.

One idea I have is that you CPFP-ed two transactions "in parallel", and by that I mean you haven't broadcasted/saved the first CPFP tx before starting the flow for the second. This way the address picked by the first flow would still be unused when you start the second flow and would get re-picked.

Hard to say but I'm pretty sure this wasn't the case, I always broadcast right away. It was 3 incoming transactions CPFP'd right after another that ended up all getting the same address.