Skip to content

Commit

Permalink
store pw changes on no-restart path (#2928)
Browse files Browse the repository at this point in the history
  • Loading branch information
buck54321 authored Aug 23, 2024
1 parent bce9337 commit 5bf8936
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions client/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -3623,6 +3623,8 @@ func (c *Core) ReconfigureWallet(appPW, newWalletPW []byte, form *WalletForm) er
if err = c.setWalletPassword(oldWallet, newWalletPW, crypter); err != nil {
return newError(walletAuthErr, "failed to update password: %v", err)
}
dbWallet.EncryptedPW = oldWallet.encPW()

}
if err = storeWithBalance(oldWallet, dbWallet); err != nil {
return err
Expand Down Expand Up @@ -3737,8 +3739,7 @@ func (c *Core) ReconfigureWallet(appPW, newWalletPW []byte, form *WalletForm) er
return fmt.Errorf("setWalletPassword: %v", err)
}
// Update dbWallet so db.UpdateWallet below reflects the new password.
dbWallet.EncryptedPW = make([]byte, len(wallet.encPass))
copy(dbWallet.EncryptedPW, wallet.encPass)
dbWallet.EncryptedPW = wallet.encPW()
} else if oldWallet.locallyUnlocked() {
// If the password was not changed, carry over any cached password
// regardless of backend lock state. loadWallet already copied encPW, so
Expand Down
1 change: 1 addition & 0 deletions client/core/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func (w *xcWallet) Unlock(crypter encrypt.Crypter) error {
if err != nil {
return fmt.Errorf("%s unlockWallet decryption error: %w", unbip(w.AssetID), err)
}

err = a.Unlock(pw) // can be slow - no timeout and NOT in the critical section!
if err != nil {
return err
Expand Down

0 comments on commit 5bf8936

Please sign in to comment.