-
Notifications
You must be signed in to change notification settings - Fork 114
fix(HD-Wallet): store & load correct HD Accounts #2537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
as it's gonna be used as the identifier for the wallet instead of coin ticker
update the schema to include purpose and coin_type integers. currently also the same migration deletes the hd_account table where purpose=0 (and since purpose was just added, then the migration deletes all rows). we can rethink that before merging this PR. we can leave a leehway where marking purpose=0 means that this entry is carried over from an old mm2 version and we keep waiting until the user ever decides to enable the coin and we check the xpub and find it the one matching in the DB, only then do we assign the purpose and coin values to the correct values gotten from the recent enablement. this solution ofc doesn't work for HW wallets, otherwise we gonna ask HW wallets to derive xpubs all the time which is the bad UX we tryna avoid
this clears the object store, deletes the indexes and reinitailzes the new indexes with the proper fields using the same indexes names.
… hd_wallet_storage
|
Quoting myself (from DMs):
@shamardy this PR doesn't do that. I opted to not do that for perf reasons. not a strong opinion tho, so we can impl this if you want. |
|
heck no... not this |
@mariocynicys can you please write a test case for @smk762 to test this and know how GUIs should handle this. |
But all testnet coins should use the same |
thanks! didn't know that. |
|
discussed over DM with @shamardy: we can set the purpose and coin_type to |
this step is supposed to look for bad accounts and fix them to (replace them by) good accounts by setting the correct purpose and coin_types. a bad account is fixed into a good one only if the derived xpub matches the one stored in the bad account. if they don't match, this means the current purpose and coin_type of the coin don't match the ones who were used to create the bad account. this commit has compilation errors for multiple reasons. but still separating it away to be coherent. fixing the compilation errors in the next commits
as it has more (friendly) methods to deal with data inside the object store
because it was infunctionally written (doesn't wait on the IDBRequest to complete) and it already exists in IdbObjectStoreImpl that was added inside the table upgrader the previous commit
f975372 to
1079f11
Compare
|
im still working on creating the ability to do updates while |
we also don't really need the Send, we just need the Sync to be able to Send a reference of DbUpgrader
add the datastore mutation code on upgrade callback. this still fails though because these calls aren't Send which on_upgrade_needed needs them to be
looks like we never needed the Send requirement from BoxFuture after all :)
including the Sync where the reference was needed to be Send
|
@smk762 |
|
@smk762 |
|
@smk762 |
|
@smk762 |
|
@smk762 |
11 similar comments
|
@smk762 |
|
@smk762 |
|
@smk762 |
|
@smk762 |
|
@smk762 |
|
@smk762 |
|
@smk762 |
|
@smk762 |
|
@smk762 |
|
@smk762 |
|
@smk762 |
This PR makes it so that
HDPathToCoinis a fieled ofHDWalletCoinStorageand integrates it inside the databases.HDWalletCoinStorageused to represent a selective set of the DB rows that match the samehd_wallet_rmd160andcoin(ticker).This has changed to
hd_wallet_rmd160andpurposeandcoin_type(sincepurpose+coin_typedefine the coin uniquely*).coinfield is still stored in the DB but is not used. This is more for convenience.This PR at the current state will purge your HD Wallet DB via a migration when run, so take a backup of it before running this code.
Will discuss a mitigation (easy for native, a little harder/tedious for wasm) for this side-effect in the review.
*: This isn't entirely true. All test coins use the same
coin_type=1.How to test this (please backup your
MM2-shared.dbDB first):purpose&coin_typein the DB selector/updater query (this doesn't really have any effect from the user facing side). So methods likecreate_new_accountandgenerate_new_addressshould do such things.supersedes #2482
closes #2470