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.
315 lines
6.9 KiB
315 lines
6.9 KiB
<template>
|
|
<view class="">
|
|
<navigation :showBack="true">
|
|
Import via private key
|
|
</navigation>
|
|
<view class="main">
|
|
<view class="title">
|
|
Private key import verification
|
|
</view>
|
|
<view class="title2">
|
|
Please enter your private key and do not disclose it to othersThe external address cannot be recovered
|
|
by mnemonics. Please keep it properly
|
|
</view>
|
|
<textarea v-model="wordInfo" class="textareaa" placeholder="Please enter your private key"
|
|
placeholder-style="color:rgb(224,229,242)">
|
|
|
|
</textarea>
|
|
|
|
|
|
<u-button class="custom-style" @click="confirm">Confirm</u-button>
|
|
|
|
|
|
<view class="info_con" v-if="show">
|
|
<image src="../../../../static/tongyonh/xg.png" mode="aspectFit" class="img2" @click="show=false">
|
|
</image>
|
|
<image src="../../../../static/tongyonh/Frame60.png" mode="aspectFit" class="img"></image>
|
|
<view class="info">
|
|
Successful
|
|
</view>
|
|
<view class="text">
|
|
Backup mnemonic completed!
|
|
</view>
|
|
<view class="btn">
|
|
Confirm
|
|
</view>
|
|
</view>
|
|
|
|
<view class="info_con" v-if="show2">
|
|
<image src="../../../../static/tongyonh/xg.png" mode="aspectFit" class="img2" @click="show2=false">
|
|
</image>
|
|
<image src="../../../../static/tongyonh/Subtract.png" mode="aspectFit" class="img"></image>
|
|
<view class="info">
|
|
Invalid Seed
|
|
</view>
|
|
<view class="text">
|
|
You entered the wrong booster words, <br>please try again.
|
|
</view>
|
|
<view class="btncon">
|
|
<view class="can" @click="show2=false">
|
|
Cancel
|
|
</view>
|
|
<view class="con" @click="restart">
|
|
Confirm
|
|
</view>
|
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
<u-mask :show="show" z-index="10"></u-mask>
|
|
<u-mask :show="show2" z-index="10"></u-mask>
|
|
</view>
|
|
|
|
</view>
|
|
</view>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
import cont from "@/components/navigation/navigation.vue"
|
|
export default {
|
|
data() {
|
|
return {
|
|
mnemonics: [],
|
|
wordArr: [],
|
|
show: false,
|
|
index: 0,
|
|
returnIndex: 0,
|
|
// 拿来对比的
|
|
mnemonics2: [],
|
|
show2: false,
|
|
wordInfo: '',
|
|
walletInfo: {},
|
|
go: false,
|
|
name: '',
|
|
info: {},
|
|
};
|
|
},
|
|
methods: {
|
|
// 成功去到设置交易密码
|
|
goTranPaw() {
|
|
uni.navigateTo({
|
|
url: '/pages/menu/backUp/transPaw/index'
|
|
})
|
|
},
|
|
// 失败重刷新
|
|
restart() {
|
|
uni.redirectTo({
|
|
url: '../backUp4/index'
|
|
})
|
|
},
|
|
// 提交
|
|
confirm() {
|
|
this.walletInfo = uni.getStorageSync('walletInfo');
|
|
if (this.wordInfo == '') {
|
|
uni.showToast({
|
|
title: 'Cannot be empty',
|
|
icon: 'none',
|
|
duration: 1500
|
|
})
|
|
return;
|
|
}
|
|
|
|
var a = uni.getStorageSync('createWalletName')
|
|
console.log(a)
|
|
if (a == 'BTC' && a != '' && a != undefined) {
|
|
try {
|
|
this.walletInfo = uni.getStorageSync('walletInfo');
|
|
var mnemonic = this.wordInfo;
|
|
uni.setStorageSync('privateKey', mnemonic);
|
|
console.log(mnemonic)
|
|
|
|
let btc = this.$Token.importBtcPrivateKey(mnemonic);
|
|
|
|
|
|
for (var i = 0; i < this.walletInfo.BTC.length; i++) {
|
|
if (this.walletInfo.BTC[i].privateKey == btc.privateKey) {
|
|
uni.showToast({
|
|
title: 'The wallet has been imported',
|
|
icon: 'none',
|
|
duration: 1500
|
|
})
|
|
this.go = false;
|
|
} else {
|
|
this.go = true;
|
|
}
|
|
|
|
}
|
|
} catch (err) {
|
|
uni.showToast({
|
|
title: 'Private key does not exist',
|
|
icon: 'none',
|
|
duration: 1500
|
|
})
|
|
|
|
}
|
|
if (this.go) {
|
|
uni.showToast({
|
|
title: 'Import succeeded',
|
|
icon: 'success',
|
|
duration: 1500
|
|
})
|
|
setTimeout(() => {
|
|
uni.navigateTo({
|
|
url: '/pages/menu/backUp/transPaw2/index'
|
|
})
|
|
}, 1500)
|
|
|
|
}
|
|
}
|
|
|
|
if (a == 'ETH' && a != '' && a != undefined) {
|
|
try {
|
|
this.walletInfo = uni.getStorageSync('walletInfo');
|
|
var mnemonic = this.wordInfo;
|
|
uni.setStorageSync('privateKey', mnemonic);
|
|
console.log(mnemonic)
|
|
|
|
let eth = this.$Token.importEthPrivateKey(mnemonic);
|
|
|
|
|
|
for (var i = 0; i < this.walletInfo.ETH.length; i++) {
|
|
if (this.walletInfo.ETH[i].privateKey == eth.privateKey) {
|
|
uni.showToast({
|
|
title: 'The wallet has been imported',
|
|
icon: 'none',
|
|
duration: 1500
|
|
})
|
|
this.go = false;
|
|
} else {
|
|
this.go = true;
|
|
}
|
|
|
|
}
|
|
} catch (err) {
|
|
uni.showToast({
|
|
title: 'Private key does not exist',
|
|
icon: 'none',
|
|
duration: 1500
|
|
})
|
|
|
|
}
|
|
if (this.go) {
|
|
uni.showToast({
|
|
title: 'Import succeeded',
|
|
icon: 'success',
|
|
duration: 1500
|
|
})
|
|
setTimeout(() => {
|
|
uni.navigateTo({
|
|
url: '/pages/menu/backUp/transPaw2/index'
|
|
})
|
|
}, 1500)
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (a == 'TRX' && a != '' && a != undefined) {
|
|
try {
|
|
this.walletInfo = uni.getStorageSync('walletInfo');
|
|
var mnemonic = this.wordInfo;
|
|
console.log(this.wordInfo)
|
|
uni.setStorageSync('privateKey', mnemonic);
|
|
console.log(mnemonic)
|
|
|
|
this.info = this.$Token.importTronPrivateKey(mnemonic);
|
|
|
|
|
|
for (var i = 0; i < this.walletInfo.TRON.length; i++) {
|
|
if (this.walletInfo.TRON[i].privateKey == this.info.privateKey) {
|
|
uni.showToast({
|
|
title: 'The wallet has been imported',
|
|
icon: 'none',
|
|
duration: 1500
|
|
})
|
|
this.go = false;
|
|
} else {
|
|
|
|
this.go = true;
|
|
}
|
|
|
|
}
|
|
} catch (err) {
|
|
console.log(err)
|
|
uni.showToast({
|
|
title: 'Private key does not exist',
|
|
icon: 'none',
|
|
duration: 1500
|
|
})
|
|
|
|
}
|
|
if (this.go) {
|
|
console.log(this.info, 111)
|
|
this.$store.commit('addTroni', 1)
|
|
let that = this;
|
|
this.$TronUtil.getTronBalance(this.info.address).then((res) => {
|
|
that.info.balance = res
|
|
|
|
}).catch(err => {
|
|
console.log(err)
|
|
})
|
|
this.info.coinList = [{
|
|
name: "TRX",
|
|
name2: "TRX",
|
|
xname: 'TRON',
|
|
icon: require('@/static/tongyonh/tron1.png'),
|
|
balance: this.info.balance
|
|
}];
|
|
uni.setStorageSync('wallet', this.info)
|
|
uni.setStorageSync('walleti', this.info.privateKey)
|
|
|
|
this.walletInfo.TRON[this.$store.state.troni] = this.info
|
|
uni.setStorageSync('walletInfo', this.walletInfo)
|
|
uni.showToast({
|
|
title: 'Import succeeded',
|
|
icon: 'success',
|
|
duration: 1500
|
|
})
|
|
setTimeout(() => {
|
|
uni.navigateTo({
|
|
url: '/pages/menu/backUp/transPaw2/index'
|
|
})
|
|
}, 1500)
|
|
|
|
}
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
onLoad(item) {
|
|
|
|
if (item != '' || item != undefined) {
|
|
uni.setStorageSync('createWalletName', item.name)
|
|
}
|
|
},
|
|
};
|
|
</script>
|
|
<style scoped>
|
|
.custom-style {
|
|
height: 112rpx;
|
|
text-align: center;
|
|
color: #fff;
|
|
background-color: #5B53FF !important;
|
|
border-radius: 40rpx;
|
|
margin-top: 50rpx;
|
|
}
|
|
|
|
.u-default-hover {
|
|
background-color: #5B53FF !important;
|
|
border-radius: 40rpx !important;
|
|
color: #fff !important;
|
|
border: none;
|
|
}
|
|
</style>
|
|
|
|
<style>
|
|
@import './index.css';
|
|
</style>
|
|
|