Qortal UI - Main Code Repository A User Interface for the Qortal Blockchain Project. Truly decentralized web hosting, application hosting, communications, data storage, and full infrastructure for the future global decentralized digital world.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
760 B

11 months ago
import {kdf} from './kdf.js'
3 years ago
import PhraseWallet from './PhraseWallet.js'
import Base58 from './deps/Base58.js'
11 months ago
import {decryptStoredWallet} from './decryptStoredWallet.js'
3 years ago
export const createWallet = async (sourceType, source, statusUpdateFn) => {
let version, seed
3 years ago
switch (sourceType) {
case 'phrase':
version = 2
seed = await kdf(source.seedPhrase, void 0, statusUpdateFn)
break
case 'seed':
version = 1
seed = Base58.decode(source.seed)
break
case 'storedWallet':
case 'backedUpSeed':
version = source.wallet.version
seed = await decryptStoredWallet(source.password, source.wallet, statusUpdateFn)
break
default:
throw 'sourceType ' + sourceType + ' not recognized'
}
3 years ago
return new PhraseWallet(seed, version)
3 years ago
}