-
Notifications
You must be signed in to change notification settings - Fork 632
export legacy wallets in a friendly way for automatic import in cardano-wallet #4278
base: develop
Are you sure you want to change the base?
Conversation
This little command-line tool extract the name and encrypted XPrv of known wallets and spits them back in a user-friendly format on stdout. $ export-wallets --mainnet --wallet-db-path state-wallet-mainnet/wallet-db --keyfile state-wallet-mainnet/secret.key [ { "encrypted_root_private_key": "5da58210e3f6e2b1e24659158554f91bb5970202ba0e0cd2d32767ce3c2893c29515a5469493f6133857c0dc86f127aa70e46d047424e07f7221715357bfb35052aed22cefd53ea7d75b5804add54e653c21e03ffd7c01cb8f6c033f7d383cc127046148d89a1828b76bdb46b56f6fec06d31b5b412dc68ab4b5ffa2418e7e8d", "name": "My Wallet", "passphrase_hash": "31347c387c317c57434478796c7064635a736853367a6d3150766d54456a34667038795a34623145557868627765347a36596645413d3d7c48544739445a456d4f2b79535a6a705a76553145614d795a437170732b43347330704738414562745638773d" } ] The format matches exactly the JSON format expected by the cardano-wallet for restoring legacy wallet from xprv.
$ export-wallets --mainnet --wallet-db-path state-wallet-mainnet/wallet-db --keyfile state-wallet-mainnet/secret.key [ { "encrypted_root_private_key": "b824f5268bdf05d783b0c594936e51c65d6d155021ddcbdb3370bb7a51caba4bedece046fc9d12143ce900d8238e444904e08a85af80299b012e7f12030a2ab6d3d1cf6fc565476c17326baebddcf31c5e3409ba697b9bf04ac588cb59868c22d043e0237a3ba2eb167d1504dd93f788fc4a72503a261cf338ad7e4cf8837aff", "name": "My Wallet", "passphrase_hash": null }, { "encrypted_root_private_key": "5da58210e3f6e2b1e24659158554f91bb5970202ba0e0cd2d32767ce3c2893c29515a5469493f6133857c0dc86f127aa70e46d047424e07f7221715357bfb35052aed22cefd53ea7d75b5804add54e653c21e03ffd7c01cb8f6c033f7d383cc127046148d89a1828b76bdb46b56f6fec06d31b5b412dc68ab4b5ffa2418e7e8d", "name": "My Wallet", "passphrase_hash": "31347c387c317c57434478796c7064635a736853367a6d3150766d54456a34667038795a34623145557868627765347a36596645413d3d7c48544739445a456d4f2b79535a6a705a76553145614d795a437170732b43347330704738414562745638773d" } ]
@cleverca22 how do you suggest we invoke and use this util in Daedalus? We need to pack it with the installer... |
@KtorZ can it happen that the script only extracts some of the wallets and not all of them? |
@nikolaglumac I don't expect this script to error, provided the filepath given to it are correct. I kept the option name the same so that they exactly match those of As for your second question:
The only case I can think of (and for which I've added some logging), even though I doubt it'll happen, would be if there are secret keys in the keystore but no corresponding wallet in the acid-state file. I'd expect these two data store to be somewhat consistent with each other, but I am also not discarding the possibility of the keystore having references to keys that matches no wallet... Anyway, if a wallet is being returned by the legacy API, it'll show up.
If I may, I'd suggest running this little with the installer itself, such that all wallets get exported to disk as a json file. Then, the new Daedalus can simply read that file and submit the exported wallets directly to the new backend. |
@KtorZ but what would happen in this case? Will it throw an error or simply return just the wallets which are both within secrets.key and the acid state? |
We would like to avoid writing this info to the hard drive. |
my wallet happens to be missing in the acid-state db, and the tool fails identically for both the db, and an empty dir it would help if it could return:
|
It's already on the hard drive... |
I know, but it is not provided in such a way I guess. We will think about this option. cc @darko-mijic @KtorZ if a wallet is missing from the acid-state db then surely it is not visible in Daedalus right? |
Correct. |
Before that, the script would simply create a new empty database and pretty much fail to export every wallet in the keystore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@@ -369,6 +369,7 @@ executable export-wallets | |||
, cardano-sl-util | |||
, cardano-wallet | |||
, contravariant | |||
, directory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nix files will need regenerating.
export-wallets-qa/README.md How To Use
Mainnet
Testnet
Annexwallet with passphrase{
"assuranceLevel": "strict",
"backupPhrase": [
"inhale",
"arm",
"pilot",
"fitness",
"ceiling",
"october",
"donate",
"between",
"language",
"all",
"limit",
"taxi"
],
"name": "亜哀うめるтУуФф",
"operation": "create",
"spendingPassword": "0000000000000000000000000000000000000050415441544520504154415445"
} wallet without passphrase{
"assuranceLevel": "strict",
"backupPhrase": [
"marriage",
"blouse",
"orbit",
"quarter",
"treat",
"series",
"release",
"sing",
"lava",
"spice",
"surface",
"rule"
],
"name": "WALLET 💜 💛 💚 💙",
"operation": "create",
"spendingPassword": null
} |
LGTM.
|
@KtorZ This can't be done at install time because the installer doesn't know the path to the user state directory. The installation happens globally but the state is tied to the user home directory/AppData. What probably makes sense is before launching the launcher, check if a new state directory exists. If it does, do nothing, if it doesn't check if a legacy state dir exists, if it does run the utility. Then proceed as normal with launching node/wallet. |
Daedalus integration is now complete: input-output-hk/daedalus#1905 |
@nikolaglumac updated.
Here's an example on the previously generated databases: $ export-wallets --mainnet --wallet-db-path ./state-wallet-mainnet/wallet-db --keyfile state-wallet-mainnet/secret.key
[
{
"encrypted_root_private_key": "f6e79f49b8999a39d7e970e42d0a91224ecacefc3aa1edb342f34eb8bc6c2fc63e743b862b312a6f92ba0161d4d53c3ee5a2bd8085476d9575765c49dceecbe54b34ec47daf9b7ebc6bdb706622616451c000e85ba81c7449ae436a8cbbf3aab98e5cc704977bd11bb0ba8d5b5571a705704cb9334d27a048532eab49a698c2d",
"name": "亜哀うめるтУуФф",
"id": "5c409c7e4fddfa99d11c0345dc75e514d2a0faad",
"passphrase_hash": "31347c387c317c5743413633702f6a487a5777575278756756344e316854793470646c6d4f76665177653863775a575472784f79773d3d7c796341722f61326f4f777a736e4e746f4e655049416e4f6b7978426549494a6b59623039574b564a7159493d"
},
{
"encrypted_root_private_key": "38e8de9c583441213fe34eecc4e28265267466877ba4048e3ab1fa9956366947aefaf5ba9779db67eead7fc9cd1354b994a5d8d9cd40ab874bfeb1b33649280cd33651377731e0e59e0233425a55257782c5adaa768da0567f43c1c6c0c18766ed0a547bb34eb472c120b170a8640279832ddf18002887f03c15dea59705422d",
"name": "WALLET 💜 💛 💚 💙",
"id": "05377e480bd68a2da04f00c39ce5886e4746ed1f",
"passphrase_hash": "31347c387c317c574342652b796362417576356c2b4258676a344a314c6343675375414c2f5653393661364e576a2b7550766655513d3d7c6f784636654939734151444e6f38395147747366324e653937426338372b484b6b4137756772752f5970673d"
},
{
"encrypted_root_private_key": "b824f5268bdf05d783b0c594936e51c65d6d155021ddcbdb3370bb7a51caba4bedece046fc9d12143ce900d8238e444904e08a85af80299b012e7f12030a2ab6d3d1cf6fc565476c17326baebddcf31c5e3409ba697b9bf04ac588cb59868c22d043e0237a3ba2eb167d1504dd93f788fc4a72503a261cf338ad7e4cf8837aff",
"name": null,
"id": "781647fe8876d7e09e3d2da23658482deebfb0d1",
"passphrase_hash": "31347c387c317c5743436e774771435944796e4233684d477168706234556c64392b6a6844506b3836314e5a773865382b637954673d3d7c524e53642f35537a51704857593148375161594b3466423045466f765659564830666b2b4d6c53454d64733d"
},
{
"encrypted_root_private_key": "5da58210e3f6e2b1e24659158554f91bb5970202ba0e0cd2d32767ce3c2893c29515a5469493f6133857c0dc86f127aa70e46d047424e07f7221715357bfb35052aed22cefd53ea7d75b5804add54e653c21e03ffd7c01cb8f6c033f7d383cc127046148d89a1828b76bdb46b56f6fec06d31b5b412dc68ab4b5ffa2418e7e8d",
"name": null,
"id": "0a436b1142929758a54f6008ff558ff8fa264e76",
"passphrase_hash": "31347c387c317c57434478796c7064635a736853367a6d3150766d54456a34667038795a34623145557868627765347a36596645413d3d7c48544739445a456d4f2b79535a6a705a76553145614d795a437170732b43347330704738414562745638773d"
}
] |
@KtorZ you are a true ⭐️ |
@KtorZ did you also set it so that secret.key is mandatory and wallet-acid-db optional? |
From the command-line options you mean? No. I didn't quite get that this is what you wanted. Although, passing |
Well we will always be passing a path - but it may not be valid in some cases (e.g. when user only has secret.key... |
Also, side-note: I couldn't get you the balance. This requires setting up a whole 'NodeStateAdaptor' which basically needs the entire node configuration and is therefore an much heavier setup. I've started pulling the thread a bit but if this is really something you'd want at some point, we'll need to allocate a day or two to work this out. |
@KtorZ this could be handled on Daedalus end once we extract the wallets if you would be able to get us an endpoint which takes the wallet-id and returns the wallet balance. |
@KtorZ please let me know once this version is ready so @disassembler can add it to Daedalus 🙏 |
@KtorZ @disassembler any ETA on when this will be ready? |
This won't probably happen, unless the node makes the full Ledger UTxO available through the local state query protocol. Something to be checked with them. |
Yes, 2 days ago. |
```json $ export-wallets --mainnet --keyfile state-wallet-mainnet/secret.key [ { "encrypted_root_private_key": "18b952a968ccbac047f9c227dd05fced84ba85a1f83daf54f0a3c0de3e5664502678b1ba34a0b44ce22a2b54f39830570bdfeeed0a2f8586aa988fa5399987252b81f30b3c1e4c39e1edb16a4c7975eea106fc5d12d3b4fa516b9332f777defba949a42ef709a2d2f5c64057e99987c545b6e014f8cd9502bd5b800ddc6e10b7", "is_passphrase_empty": true, "name": null, "id": "f1aaaf1e1e6db1255ec2d59d50c5db892ff20330", "passphrase_hash": "31347c387c317c5743424875746242496c6a66734d764934314a30727a79663076657375724954796376766a793150554e377452673d3d7c54753434596d6e547957546c5759674a3164494f7974474a7842632b432f7862507657382b5135356a38303d" }, { "encrypted_root_private_key": "6d9e6a5135d373fb62eadaf02bc8f5ecf35148806721c704c6dbfcf818ff958f1fc4a933542c423f5b8621cfe6404c4b208f2c96f6246082dffbc9fb1029a79ed33651377731e0e59e0233425a55257782c5adaa768da0567f43c1c6c0c18766ed0a547bb34eb472c120b170a8640279832ddf18002887f03c15dea59705422d", "is_passphrase_empty": false, "name": null, "id": "05377e480bd68a2da04f00c39ce5886e4746ed1f", "passphrase_hash": "31347c387c317c574342652b796362417576356c2b4258676a344a314c6343675375414c2f5653393661364e576a2b7550766655513d3d7c2f376738486c59723174734e394f6e4e753253302b6a65515a6b5437316b45414941366a515867386539493d" } ] ```
|
Works great @KtorZ. Thanks! |
Hey, just an FYI that we've given thoughts about importing/exporting wallet files for Yoroi and this won't be compatible with our format since ours will be more generic as opposed to the straight-forward approach you're taking. Maybe it doesn't matter since I think this is just your temporary solution for legacy wallets. |
@SebastienGllmt yes, this is simply to enable a smooth migration of the legacy cardano-sl. This clearly abuses the old scheme and the way the HD payload was constructed and encrypted. For a proper import/export wallet, we should definitely agree on a format via a CIP :) |
I used the testnet data name=亜悲めるтУуФф wallet data in the example to import into the new byron wallet, but when I created the address, 0000000000000000000000000000000000000050415441544520504154415445 was passed as the passphrase, and then the following error was returned:
|
Description
implement export-wallets for Byron reboot migration
This little command-line tool extract the name and encrypted XPrv of
known wallets and spits them back in a user-friendly format on stdout.
The format matches exactly the JSON format expected by the
cardano-wallet for restoring legacy wallet from xprv.
148076e
Return 'null' for 'passphrase_hash' when there's no passphrase set
$ export-wallets --mainnet --wallet-db-path state-wallet-mainnet/wallet-db --keyfile state-wallet-mainnet/secret.key
Linked issue
Type of change
Developer checklist
Testing checklist
QA Steps
Screenshots (if available)
How to merge
Send the message
bors r+
to merge this PR. For more information, seedocs/how-to/bors.md
.