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.
42 lines
1.2 KiB
42 lines
1.2 KiB
7 years ago
|
import { dirname } from 'path'
|
||
7 years ago
|
import * as walletController from '../methods/walletController'
|
||
7 years ago
|
import config from '../config'
|
||
7 years ago
|
|
||
7 years ago
|
export default function(walletUnlocker, log, event, msg, data) {
|
||
7 years ago
|
const lndConfig = config.lnd()
|
||
|
|
||
|
const decorateError = error => {
|
||
|
switch (error.code) {
|
||
|
// wallet already exists
|
||
|
case 2:
|
||
|
error.context = {
|
||
|
lndDataDir: dirname(lndConfig.cert)
|
||
|
}
|
||
|
}
|
||
|
return error
|
||
|
}
|
||
|
|
||
7 years ago
|
log.info(`Calling walletUnlocker method '${msg}'`)
|
||
7 years ago
|
switch (msg) {
|
||
|
case 'genSeed':
|
||
7 years ago
|
walletController
|
||
|
.genSeed(walletUnlocker)
|
||
7 years ago
|
.then(genSeedData => event.sender.send('receiveSeed', genSeedData))
|
||
7 years ago
|
.catch(error => event.sender.send('receiveSeedError', decorateError(error)))
|
||
7 years ago
|
break
|
||
|
case 'unlockWallet':
|
||
7 years ago
|
walletController
|
||
|
.unlockWallet(walletUnlocker, data)
|
||
7 years ago
|
.then(() => event.sender.send('walletUnlocked'))
|
||
|
.catch(() => event.sender.send('unlockWalletError'))
|
||
7 years ago
|
break
|
||
|
case 'initWallet':
|
||
7 years ago
|
walletController
|
||
|
.initWallet(walletUnlocker, data)
|
||
7 years ago
|
.then(() => event.sender.send('finishOnboarding'))
|
||
7 years ago
|
.catch(error => log.error('initWallet:', error))
|
||
7 years ago
|
break
|
||
|
default:
|
||
|
}
|
||
|
}
|