Litecoin-Java / bitcoin-wallet

Bitcoin Wallet app for your Android device. Standalone Bitcoin node, no centralized backend required.
https://play.google.com/store/apps/details?id=de.schildbach.wallet
31 stars 42 forks source link

Exporting wallet backup files #61

Closed markuspeloquin closed 10 years ago

markuspeloquin commented 10 years ago

Maybe I'm ignorant, but I don't seem to be able to backup my wallet. When I back up my private keys, it says they have been backed up to /storage/emulated/0/Download/litecoin-wallet-keys.... When I mount my Nexus 5 in my computer, I do not see this anywhere. I'm sure it ends up in the filesystem of the phone since I am able to restore from it.

I'd much rather have an option to write it directly to my Google Drive or Dropbox.

And for that matter, I cannot browse for my backups unless they happen to be in that magical directory on my phone's filesystem.

hank commented 10 years ago

After you backup, press Archive to copy the backup to Google Drive, etc. You should be able to use a file browser to select backups from anywhere on the device because I believe they are written with a special MIME type handled from the app.

markuspeloquin commented 10 years ago

Ah, I didn't realize that was the Downoload directory when I mount my phone ... somehow. It is also identical to the file that gets backed up to my Google Drive.

MIME types are just derived from file contents. It looks like it is a base64-encoding of 'Salted__', with 168 unpredictable bytes following it. I guess that's how OpenSSL does it. It looks like it contains a salt, some padding, a comment that uses the word 'Bitcoins' funnily enough, a version, a private key, and a timestamp. It seems there is likely no way to distinguish litecoin and bitcoin private keys, unless the 8-bit version is checked at some point. I will just be careful to not use bitcoin :)

hank commented 10 years ago

Actually, in this case the MIME type is specifically set by the app in the intent when doing the Archive action:

intent.setType("x-litecoin/private-keys");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));

And this MIME type is recorded with the file when saved in Google Drive, which allows you to open it later on a phone and have it be sent to the right app (in this case, litecoin wallet).

The file on disk doesn't have this metadata, and therefore creates an intent that can be handled by any app. As you noted, the format of the file is simply base64'ed salted AES data. The checking of litecoin versus bitcoin would happen when the private key version is checked during import - this is handled nicely, and will alert you if you, for instance, try to import a bitcoin backup into the litecoin app, and won't import the keys from the backup in this case.

Cheers!

markuspeloquin commented 10 years ago

Interesting. But now I wonder what business Litecoin has using PBKDF2 instead of scrypt to generate the key.

hank commented 10 years ago

Ha! Good point. I'll have to dig through the code and see if it would be easy to switch that out.