1
1
// @flow
2
2
import type { AccountKeys } from '../reducers/types' ;
3
- import {
4
- computeBlake2bHexWithSecret ,
5
- isBlake2HashHexWithSecretOk ,
6
- aesEncrypt ,
7
- aesDecrypt
8
- } from './decrypt' ;
3
+ import { aesEncrypt , aesDecrypt } from './decrypt' ;
9
4
10
- const WALLET_SPEDING_PASSWORD_KEY = 'wallet.spending.pwd' ;
11
5
const WALLET_ENCRYPTED_KEYS = 'wallet.encrypted.account.info' ;
12
6
13
- export function saveSpendingPassword ( spendingPassword : ?string = '' ) : void {
14
- const spendingHash = computeBlake2bHexWithSecret ( spendingPassword ) ;
15
- localStorage . setItem ( WALLET_SPEDING_PASSWORD_KEY , spendingHash ) ;
16
- }
17
-
18
- export function isValidSpendingPassword ( spendingPassword : string ) : boolean {
19
- const savedSpendingHash = localStorage . getItem ( WALLET_SPEDING_PASSWORD_KEY ) ;
20
- if ( ! savedSpendingHash )
21
- throw new Error ( 'There is not a spending password created' ) ;
22
- return isBlake2HashHexWithSecretOk ( spendingPassword , savedSpendingHash ) ;
23
- }
24
-
25
- export function isSpedingPasswordCreated ( ) : boolean {
26
- const savedSpendingHash = localStorage . getItem ( WALLET_SPEDING_PASSWORD_KEY ) ;
27
- if ( savedSpendingHash ) return true ;
7
+ export function isUnlockWalletPasswordCreated ( ) : boolean {
8
+ const encryptedAccountInfo = localStorage . getItem ( WALLET_ENCRYPTED_KEYS ) ;
9
+ if ( encryptedAccountInfo ) return true ;
28
10
return false ;
29
11
}
30
12
@@ -39,7 +21,7 @@ export function saveEncryptedAccountInfo(
39
21
}
40
22
41
23
// eslint-disable-next-line flowtype/space-after-type-colon
42
- export function readAccountKeysFromDEN (
24
+ export function readEncryptedAccountInfo (
43
25
spendingPassword : ?string
44
26
) : ?AccountKeys {
45
27
const encryptedHex = localStorage . getItem ( WALLET_ENCRYPTED_KEYS ) ;
0 commit comments