Author

Topic: Blank descriptions in transaction history after upgrading to 2.1 (Read 692 times)

sr. member
Activity: 282
Merit: 250
SteamBitShop.com
Problem solved. Here's my PHP script that converts address labels to transaction labels, in case someone else might find it useful. You'll need to download EasyBitcoin-PHP and add the following command line arguments to bitcoin core to enable JSON-RPC: "-server -rpcuser=user -rpcpassword=pw" You could also connect to a publicly available bitcoin node that has JSON-RPC enabled.

Note that my wallet file uses the old 1.x format. The script should work fine with newer wallet files but I'm not 100% sure . Either way you should definitely backup your wallet file first.

Code:
// connect to bitcoin node, init variables, and read wallet file
require_once('easybitcoin.php');
$bitcoin = new Bitcoin('user''pw''127.0.0.1''8332');
$file_output = array();
$address_labels = array();
$wallet_file_path 'C:/Users/User/AppData/Roaming/Electrum/wallets/default_wallet'// wallet file location
$file_input json_decode(file_get_contents($wallet_file_path), true);

// pull address labels from file
foreach ($file_input['labels'] as $key => $label) {
  if (
strlen($key) < 64) {
    
$address_labels[$key] = $label;
  }
}

// check each tx against address labels and create new tx label if needed
foreach ($file_input['transactions'] as $tx_hash => $transaction) {
  if (
array_key_exists($tx_hash$file_input['txo'])) {
    
$tx_json json_encode($bitcoin->decoderawtransaction($transaction));
    foreach (
$address_labels as $address => $label) {
      if (
strpos($tx_json$address) !== false && !array_key_exists($tx_hash$file_input['labels'])) {
        
$file_output['labels'][$tx_hash] = $label;
        echo 
$tx_hash.'    '.$label.PHP_EOL// display each new label (optional)
      
}
    }
  }
}

// remove address labels and add new tx labels
$file_input['labels'] = array_diff($file_input['labels'], $address_labels);
$file_input['labels'] = array_merge($file_input['labels'], $file_output['labels']);
ksort($file_input['labels']);

// convert some arrays to objects, to comply with electrum wallet format
$file_input['accounts'] = (object) $file_input['accounts'];
$file_input['accounts_expanded'] = (object) $file_input['accounts_expanded'];
$file_input['pruned_txo'] = (object) $file_input['pruned_txo'];
$file_input['receive_requests2'] = (object) $file_input['receive_requests2'];
foreach (
$file_input['txi'] as &$txi) {
  
$txi = (object) $txi;
}
foreach (
$file_input['txo'] as &$txo) {
  
$txo = (object) $txo;
}

// encode wallet and write to file
$file_output json_encode($file_inputJSON_PRETTY_PRINT JSON_UNESCAPED_SLASHES);
$file_output str_replace("\n""\r\n"$file_output); // convert line endings for windows
file_put_contents($wallet_file_path$file_output);
?>
sr. member
Activity: 282
Merit: 250
SteamBitShop.com
I'm attempting to use a script to replace all my address labels with transaction labels, rather than edit each one manually. I've successfully created a new wallet file so that the only difference is the addition of more labels, however Electrum crashes immediately on loading the new wallet:

Code:
Traceback (most recent call last):
  File "/usr/local/bin/electrum", line 254, in
    gui.main(url)
  File "/usr/local/lib/python2.7/dist-packages/electrum_gui/qt/__init__.py", line 224, in main
    w.load_wallet(wallet)
  File "/usr/local/lib/python2.7/dist-packages/electrum_gui/qt/main_window.py", line 216, in load_wallet
    self.update_history_tab()
  File "/usr/local/lib/python2.7/dist-packages/electrum_gui/qt/main_window.py", line 580, in update_history_tab
    h = self.wallet.get_history(domain)
  File "/usr/local/lib/python2.7/dist-packages/electrum/wallet.py", line 722, in get_history
    delta = self.get_tx_delta(tx_hash, addr)
  File "/usr/local/lib/python2.7/dist-packages/electrum/wallet.py", line 405, in get_tx_delta
    d = self.txo.get(tx_hash, {}).get(address, [])
AttributeError: 'list' object has no attribute 'get'

Any ideas?

legendary
Activity: 1896
Merit: 1353
Edit: In the contacts tab, what is the "type" column for? Are transaction labels supposed to be there as well?

Edit 2: I figured out what happened. I had multiple addresses with the same label, and only 1 of each label was saved in the new format, since labels are used as array keys. Any chance this could be changed, or should I just switch to using transaction labels instead?

The "type" of a contact can be 'address' or 'openalias', (you get those if you use the openalias plugin).
We will add another type for email addresses in the future.

If you want to label transactions, use transaction labels indeed.


All the txs where the description was just the incoming or outgoing btc address no show blank after updating to 2.1.
That is expected behaviour. showing random hashes to the user is of little help.
legendary
Activity: 1246
Merit: 1024
After upgrading from Electrum 2.0.3 to 2.1 on Windows, some transactions show a blank description in the history tab. It seems that some address labels were moved correctly to the new contacts file, but over half of them weren't.

Edit: In the contacts tab, what is the "type" column for? Are transaction labels supposed to be there as well?

Edit 2: I figured out what happened. I had multiple addresses with the same label, and only 1 of each label was saved in the new format, since labels are used as array keys. Any chance this could be changed, or should I just switch to using transaction labels instead?

Any tx I edited description it stayed. All the txs where the description was just the incoming or outgoing btc address no show blank after updating to 2.1.
sr. member
Activity: 282
Merit: 250
SteamBitShop.com
After upgrading from Electrum 2.0.3 to 2.1 on Windows, some transactions show a blank description in the history tab. It seems that some address labels were moved correctly to the new contacts file, but over half of them weren't.

Edit: In the contacts tab, what is the "type" column for? Are transaction labels supposed to be there as well?

Edit 2: I figured out what happened. I had multiple addresses with the same label, and only 1 of each label was saved in the new format, since labels are used as array keys. Any chance this could be changed, or should I just switch to using transaction labels instead?
Jump to: