trezor-suite icon indicating copy to clipboard operation
trezor-suite copied to clipboard

Label files moved from Dropbox to Local file system become incompatible

Open Perlover opened this issue 2 years ago • 5 comments

Describe the bug

When copying label files (*.mtdt) from the Dropbox Apps/TREZOR folder to the local folder (Linux for example: /home/$USER/.config/@trezor/suite-desktop/metadata) for storing labels and running Suite, a lot of errors of about this content are obtained (they quickly pop up and disappear from view):

"Failed to load labeling data: Unsupported state or unable to authenticate data"

Info:

  • Remembered Wallet: no
  • Suite Version: app
  • Browser: name, version
  • OS: Ubuntu 20.04
  • Firmware Version: actual firmware

How to reproduce

  1. Download files through web interface of the Dropbox site as ZIP archive
  2. Unpack a *.mtdt files to /home/$USER/.config/@trezor/suite-desktop/metadata
  3. Run Trezor Suite
  4. Select Options -> Application -> Labels On -> Connect -> To select type as "Local file system"

Expected behavior

The label files that are stored in Dropbox, in my opinion, should be compatible with the label files that are stored on the local storage

Perlover avatar May 06 '22 10:05 Perlover

I can confirm that I was able to reproduce it. .mtdt files are incompatible when transferred both ways. I switched them both ways Dropbox <> Local storage and Trezor Suite reported
Failed to load labeling data: Unsupported state or unable to authenticate data both times.

I'm not sure if this expected or not. We have to ask developers of labeling.

bosomt avatar May 19 '22 10:05 bosomt

Hello, there is a mismatch in how files are saved. What you download from dropbox is in binary format. What suite saves and reads from local filesystem is expected to be in utf-8 format.

Thanks for reporting, we should do:

  • [ ] add some format checks and show an error that makes sense
  • [ ] unify it somehow.

mroz22 avatar May 19 '22 12:05 mroz22

What suite saves and reads from local filesystem is expected to be in utf-8 format.

This sounds strange, because if you save utf-8 and read utf-8, it's the same as working with a binary format.

Perlover avatar Jun 02 '22 16:06 Perlover

Thanks for reporting, we should do:

In general, it is considered good form to work with binary files as with binary ones. I believe that crypted label files are in any binary format, and they need to be opened in binary mode. If you open binary files as utf-8 encoding, then it's generally strange that you have it all working somewhere.

Perlover avatar Jun 02 '22 16:06 Perlover

any update on this?

veritasdigitalis avatar Oct 13 '22 20:10 veritasdigitalis

I found workaround and converted all files!

  1. Get all files from DropBox through web! Go to Apps/TREZOR folder and download ZIP archive
  2. Unpack files from archive and to move to ~/.config/@trezor/suite-desktop/metadata folder (Linux). If there are other mdtd files please delete their before!
  3. Write in this folder a perl script below too (convert.pl file) and set permissions as 755 (chmod 755 convert.pl):
#!/usr/bin/perl

open(my $fh, '<:raw', $ARGV[0]) or die;
open(my $fhOut, '>:utf8', $ARGV[0] . '.converted') or die;
local $/ = undef;
print $fhOut unpack('H*', <$fh>);
close $fh || die;
close $fhOut || die;
rename($ARGV[0] . '.converted', $ARGV[0]);
  1. To do this in shell:
ls -1 *.mtdt|awk '{print "./convert.pl "$1}'|sh
  1. Go to Suite and unconnect a Dropbox method and do there a Local method. You will see your labels again!
  2. Delete convert.pl file or chmod 644 convert.pl (to protect against accidental conversion twice)

Bonus: I recommend to see the Syncthing as solution for sync the folder of ~/.config/@trezor/suite-desktop/metadata between your own machines! (no cloud there just your devices as your own cloud!)

Perlover avatar Apr 26 '23 12:04 Perlover