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.

30 lines
787 B

3 years ago
import { kdf } from './kdf.js'
import PhraseWallet from './PhraseWallet.js'
import Base58 from './deps/Base58.js'
import { decryptStoredWallet } from './decryptStoredWallet.js'
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
const wallet = new PhraseWallet(seed, version)
return wallet
3 years ago
}