BTM0006:'输入有效的地址格式。',
BTM0007:'钱包名称错误,请输入正确钱包名称。',
BTM0008:'密码不能为空',
- BTM0009:'目前钱包已为账户'
+ BTM0009:'目前钱包已为账户',
+ BTM0010:'Keystore导入不支持V2多账户导入,请拆分为单个Keystore',
+ BTM0011:'Keystore文件格式错误。',
+ BTM0012:'Keystore已存在请勿重复导入。'
},
successMsg:{
createWallet:{
BTM0006:'Address format error',
BTM0007:'Wallet name error',
BTM0008:'Empty password',
- BTM0009:'Current wallet is already an account'
+ BTM0009:'Current wallet is already an account',
+ BTM0010:'Keystore restore dose not support V2 multiple account. Please split into single keystore.',
+ BTM0011:'Keystore file format error.',
+ BTM0012:'Keystore already exist.'
},
successMsg:{
createWallet:{
import uuid from 'uuid'
import * as Actions from '../store/constants';
import _ from 'lodash'
-import {getDomains} from '@/utils/utils.js'
+import {getDomains, camelize} from '@/utils/utils.js'
let account = {
setupNet: bytom.setupNet
return bytom.keys.isValidMnemonic(mnemonic)
}
-account.isValidKeystore = function(keystore) {
- return bytom.keys.isValidKeystore(keystore)
+account.isValidKeystore = function(keystore, context) {
+ const walletImage = camelize(JSON.parse(keystore));
+ //V2
+ if(walletImage['accounts-server']){
+ const account = walletImage['accounts-server'].filter(a => a.net === context.net)
+ if(account.length>1){
+ throw(context.$t('error.BTM0010'))
+ }else if(account.length===0){
+ throw(context.$t('error.BTM0011'))
+ }else{
+ const xpub = account[0].rootXPub
+ if(context.bytom.keychain.findIdentity(xpub)){
+ throw(context.$t('error.BTM0012'))
+ }else{
+ const key = walletImage["keys"].find(key => key.xpub === xpub)
+ return key.key
+ }
+ }
+ }
+ //invalid format
+ else if(!walletImage['crypto']){
+ throw(context.$t('error.BTM0011'))
+ }
+ return walletImage
}
account.decryptMnemonic = function(vault,password, context) {
if(!keyAlias){
keyAlias = `${accountAlias}-key-${uuid.v4()}`
}
- debugger
bytom.keys
.create(keyAlias, passwd)
.then(res => {
- debugger
bytom.accounts
.createAccountUseServer(res.xpub, accountAlias)
.then(ret => {
}
try{
- const keystore = account.isValidKeystore(this.formItem.keystoreF)
+ const keystore = account.isValidKeystore(this.formItem.keystoreF, this)
this[Actions.SET_DATA]({
keystore: keystore
}).then(() => {
}
try{
- const keystore = account.isValidKeystore(this.formItem.keystore)
+ const keystore = account.isValidKeystore(this.formItem.keystore, this)
this[Actions.SET_DATA]({
keystore: keystore
}).then(() => {