Fix waddrmgr version 4 upgrade path.
If the account number to name index mapped the default account name to an alias, the upgrade would not succeed and the upgrade would be aborted (and rolled back). This became a problem for upgrading old (pre-v3) wallets since the v3 upgrade did not rename the previous "" account to "default", but instead just created an alias. Fix tested by @dajohi, who ran into this issue with a wallet upgrade from an older keystore version.
This commit is contained in:
parent
0a13274d5b
commit
0ae57f2564
1 changed files with 12 additions and 2 deletions
|
@ -1921,8 +1921,18 @@ func upgradeToVersion4(namespace walletdb.Namespace, pubPassPhrase []byte) error
|
|||
}
|
||||
}
|
||||
|
||||
// Ensure that the "default" name maps forwards and backwards to
|
||||
// the default account index.
|
||||
// The account number to name index may map to the wrong name,
|
||||
// so rewrite the entry with the true name from the account row
|
||||
// instead of leaving it set to an incorrect alias.
|
||||
err = putAccountIDIndex(tx, DefaultAccountNum, acctInfo.name)
|
||||
if err != nil {
|
||||
const str = "account number to name index could not be " +
|
||||
"rewritten with actual account name"
|
||||
return managerError(ErrUpgrade, str, err)
|
||||
}
|
||||
|
||||
// Ensure that the true name for the default account maps
|
||||
// forwards and backwards to the default account number.
|
||||
name, err := fetchAccountName(tx, DefaultAccountNum)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Add table
Reference in a new issue