spesmilo / electrum

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

Labels export does not reflect what is on History tab #8896

Open lionkmp opened 7 months ago

lionkmp commented 7 months ago

I think the History tab takes some Labels from OTHER PLACES and displays them as if it was the transaction's label. And those are not exported. But there is no visual clue of this, and this results in loss of labels on export.

To reproduce:

Later, I deleted a Payment Request, because I received that, but due to amount not matching, it was not "removed" from Receive tab and not auto-moved to History. That's OK... ;-)

Thus my error report is, that there is totally no way on History to know whether what I see is really exported.

I understand that they are not exported because (probably) they belong to addresses and not transaction. But this is very confusing. (I want to copy all my older labels from an older system, but I wonder how many of my labels are "not real" there...? And there is no way to know, no way to SAVE ("update" without editing)...)

Expected behavior:

Export what I see on History tab.

However as I understand, that in case, importing would assign Address labels to Transactions. ??

Thanks. I hope this report is understandable. I'm not sure my assumptions are correct.

SomberNight commented 7 months ago

Right, this is a bit complex. In short, there are three sources of labels atm,

You can see the convolutedness around here: https://github.com/spesmilo/electrum/blob/57270e3bf3c4c1f6cad9b5fba3ca38d0308ed613/electrum/wallet.py#L1611

When you export labels, only wallet._labels is exported. However you can export/import both invoices and requests. Have you tried doing all 3?

lionkmp commented 7 months ago

Thanks, yes, that is understandable, but very confusing to user, and not user friendly.

My first example label was still on "Receive" tab, thus it was visible on History but not exported with History. Then I deleted the Request, that "eliminated" the label from History - this is already confusing, as I expected History "knows" that label, because it was displayed there.

My second example, that label we NOT on my "Send" tab, because the transaction got auto-moved to History when it was completed, months ago. Thus the label came from a place not visible to user (however as mentioned, I found it in "Coins", where it is not editable. Still, I had no way to "burn that label into the History" without modifying its content.)

I have not tried to export/import Send and Receive, because there was NOTHING on them. (at this point)

Now, I went to my old PC from where I want to move all my old labels. "Shockingly" (sorry ;) ) the export contains less than half of my labels, while seemingly all transactions have a label on History.

(Send and Receive tabs are EMPTY. But even more confusingly, if I export them, there is data in both files! So I export the nothing, and there is something.)

I do not plan to copy this non-visible Invoice/Request data from my old PC to the new, because I do not understand what this contains. I just want to copy my Historic labels. History labels export file looks simple and understandable.

Maybe it's not technically a good solution but maybe History labels export should do as your linked code?? At least that would provide a way for user to copy transaction history notes as it is visible.

return self._labels.get(tx_hash) or self._get_default_label_for_txid(tx_hash)

Off note: Interestingly, one item on my History export JSON contains an address, not a transaction ID. (However that transaction may be from an older Electrum version. That is the first transaction.)