Skip to content

Commit

Permalink
OGWallet | v0.1.5.2 Release. Use new blockies.
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyStig-tao committed Feb 28, 2019
1 parent fa5cbd6 commit 0174293
Show file tree
Hide file tree
Showing 8 changed files with 258 additions and 52 deletions.
18 changes: 18 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"pack:renderer": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.renderer.config.js"
},
"dependencies": {
"@download/blockies": "^1.0.3",
"@lossendae/vue-avatar": "^0.1.5",
"aes-js": "^3.1.2",
"assert": "^1.4.1",
Expand All @@ -35,6 +36,7 @@
"electron-packager": "^13.0.1",
"electron-prebuilt": "^1.4.13",
"element-ui": "^2.4.11",
"ethereum-blockies-base64": "^1.0.2",
"fs": "0.0.1-security",
"install": "^0.12.2",
"keccak": "^2.0.0",
Expand Down
6 changes: 4 additions & 2 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ function createWindow () {
label: 'Application',
submenu: [
// eslint-disable-next-line standard/object-curly-even-spacing
{ label: 'Quit', accelerator: 'Command+Q', click: function () { app.quit() }}
{ label: 'Quit', accelerator: 'Command+Q', click: function () { app.quit() }},
// eslint-disable-next-line standard/object-curly-even-spacing
{ label: 'relaunch', accelerator: 'Command+R', click: function () { app.relaunch() }}
]
},
{
Expand All @@ -47,8 +49,8 @@ function createWindow () {
* Initial window options
*/
mainWindow = new BrowserWindow({
height: 750,
useContentSize: true,
height: 750,
width: 1400,
titleBarStyle: 'hiddenInset',
show: false,
Expand Down
26 changes: 25 additions & 1 deletion src/renderer/components/IndexPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@
<el-carousel :interval="10000" type="card" height="200px" indicator-position="none">
<el-carousel-item :key="account.account_name" v-for="account in accountList" @click.native="goAccount()">
<div style="z-index:-1">
<vue-avatar :username="account.account_name" style="margin-top: 34px;margin-left: 15px;zoom:0.82"></vue-avatar>
<!-- <vue-avatar :username="account.account_name" style="margin-top: 34px;margin-left: 15px;zoom:0.82"></vue-avatar> -->
<img id="address-identicon-index" v-bind:src="account.identicon">
<p class="title alt" style="margin-top: 15px;margin-left: 15px">{{ account.account_name }}</p>
<!-- <p class="title alt small" style="margin-top: 25px;margin-left: 15px">{{ account.address }}</p> -->
<p class="title alt" style="display:inline-block;margin-top: 19px;margin-left: 15px">balance: </p>
Expand Down Expand Up @@ -126,6 +127,7 @@
import sqlite from '../db/db.js'
import config from '../config/config.js'
import VueAvatar from '@lossendae/vue-avatar'
import { createIcon } from '@download/blockies'
export default {
name: 'index-page',
Expand Down Expand Up @@ -192,6 +194,15 @@
sqlite.query('SELECT * FROM usr').then((data) => {
console.log(data)
this.accountList = data.data
for (var j = 0; j < this.accountList.length; j++) {
var seed = this.accountList[j].address
this.accountList[j].identicon = createIcon({ // All options are optional
seed, // seed used to generate icon data, default: random
size: 10, // width/height of the icon in blocks, default: 10
scale: 8 // width/height of each block in pixels, default: 5
}).toDataURL()
}
console.log(this.accountList)
if (data.data.length === 0) {
this.docShow = true
} else {
Expand Down Expand Up @@ -317,6 +328,19 @@
opacity: 0.25;
}
#address-identicon-index{
width: 50px;
height: 50px;
/* display: flex; */
border-radius: 50% !important;
align-items: center;
justify-content: center;
overflow: hidden;
display: inline-block;
margin-top: 10px;
margin-left: 10px;
}
main {
display: flex;
justify-content: space-between;
Expand Down
171 changes: 144 additions & 27 deletions src/renderer/components/account.vue

Large diffs are not rendered by default.

20 changes: 15 additions & 5 deletions src/renderer/components/createAccount.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
</div>
<div id="step2" v-show="create_page == 1">
<p class="title alt small">account</p>
<vue-avatar :username="newAccount.account_name || tag"></vue-avatar>
<!-- <vue-avatar :username="newAccount.account_name || tag"></vue-avatar> -->
<img id="address-identicon" v-bind:src="newAccountOBJ.identicon">
<p class="title alt">{{newAccount.account_name}}</p>
<p class="title alt small">address</p>
<p class="title alt">{{newAccountOBJ.address}}</p>
Expand Down Expand Up @@ -147,11 +148,13 @@
import C from '../js/common.js'
import QRCode from 'qrcode'
import VueAvatar from '@lossendae/vue-avatar'
import { createIcon } from '@download/blockies'
export default {
name: 'account-page',
components: {
QRCode: QRCode,
createIcon: createIcon,
VueAvatar
},
data () {
Expand Down Expand Up @@ -184,14 +187,21 @@ export default {
if (this.newAccount.account_name && this.newAccount.password && this.newAccount.password_repeat) {
if (this.newAccount.password.length > 7) {
if (this.newAccount.password === this.newAccount.password_repeat) {
this.newAccountOBJ = C.createAccount()
this.newAccountOBJ.recoverPhrase = C.getRecoverPhrase(this.newAccountOBJ.privateKey)
this.newAccountOBJ = C.createAccount_useBip39()
// this.newAccountOBJ.recoverPhrase = C.getRecoverPhrase(this.newAccountOBJ.privateKey)
this.newAccountOBJ.recoverPhraseArr = this.newAccountOBJ.recoverPhrase.split(' ')
this.phraseArr = this.newAccountOBJ.recoverPhraseArr
console.log(this.newAccountOBJ.privateKey)
console.log(this.newAccountOBJ)
console.log(this.phraseArr)
this.newAccountOBJ.privateKey = C.encryptPrivKey(this.newAccount.password, this.newAccountOBJ.privateKey)
this.showLoading = true
this.stepPageLoading = true
this.newAccountOBJ.identicon = createIcon({ // All options are optional
seed: this.newAccountOBJ.address, // seed used to generate icon data, default: random
size: 10, // width/height of the icon in blocks, default: 10
scale: 8 // width/height of each block in pixels, default: 5
}).toDataURL()
setTimeout(() => {
this.create_page += 1
this.stepPageLoading = false
Expand Down Expand Up @@ -228,7 +238,7 @@ export default {
} else if (this.create_page === 2) {
var ownerTypeInPhrase = this.ownerTypeInPhrase.toString().replace(/,/g, ' ')
console.log(ownerTypeInPhrase)
// console.log('here', this.newAccountOBJ.recoverPhraseArr)
console.log('here', this.newAccountOBJ.recoverPhraseArr)
if (ownerTypeInPhrase === this.newAccountOBJ.recoverPhrase) {
// if (this.inputPhrase === '1') {
this.$message({
Expand Down Expand Up @@ -259,7 +269,7 @@ export default {
var indexOfPhrase = this.phraseArr.indexOf(phrase)
this.phraseArr.splice(indexOfPhrase, 1)
this.ownerTypeInPhrase.push(phrase)
if (this.ownerTypeInPhrase.length === 24) {
if (this.ownerTypeInPhrase.length === 12) {
this.confirmDisabled = false
}
console.log(this.ownerTypeInPhrase.toString())
Expand Down
47 changes: 33 additions & 14 deletions src/renderer/components/importAccount.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
</div>
<div id="step2" v-show="import_page == 1">
<p class="title alt small">account</p>
<vue-avatar :username="ImpAccount.account_name"></vue-avatar>
<!-- <vue-avatar :username="ImpAccount.account_name"></vue-avatar> -->
<img id="address-identicon" v-bind:src="restoreAccountOBJ.identicon">
<p class="title alt">{{ImpAccount.account_name}}</p>
<p class="title alt small">address</p>
<p class="title alt">{{restoreAccountOBJ.address}}</p>
Expand Down Expand Up @@ -136,11 +137,13 @@
import C from '../js/common.js'
import QRCode from 'qrcode'
import VueAvatar from '@lossendae/vue-avatar'
import { createIcon } from '@download/blockies'
export default {
name: 'account-page',
components: {
QRCode: QRCode,
createIcon: createIcon,
VueAvatar
},
data () {
Expand Down Expand Up @@ -170,20 +173,43 @@ export default {
if (this.ImpAccount.password === this.ImpAccount.password_repeat) {
if (this.ImpAccount.password.length > 7) {
if (this.importMode === '1') { // use private key recover
this.restoreAccountOBJ = C.recoveryAccount(this.ImpAccount.privateKey)
this.restoreAccountOBJ.recoverPhrase = C.getRecoverPhrase(this.ImpAccount.privateKey)
if (this.ImpAccount.privateKey.length === 32) {
var privateKey = this.ImpAccount.privateKey + this.ImpAccount.privateKey
} else {
privateKey = this.ImpAccount.privateKey
}
this.restoreAccountOBJ = C.recoveryAccount(privateKey)
this.restoreAccountOBJ.recoverPhrase = C.getRecoverPhrase(privateKey)
this.restoreAccountOBJ.recoverPhraseArr = this.restoreAccountOBJ.recoverPhrase.split(' ')
this.phraseArr = this.restoreAccountOBJ.recoverPhraseArr
console.log(this.phraseArr)
this.restoreAccountOBJ.privateKey = C.encryptPrivKey(this.ImpAccount.password, this.restoreAccountOBJ.privateKey)
console.log(this.restoreAccountOBJ)
} else if (this.importMode === '2') { // use recovery phrase recover
console.log('asd', this.importMode, this.ImpAccount.recoveryPhrase)
this.ImpAccount.privateKey = C.recoverPrivate(this.ImpAccount.recoveryPhrase)
this.restoreAccountOBJ = C.recoveryAccount(this.ImpAccount.privateKey)
this.restoreAccountOBJ.privateKey = C.encryptPrivKey(this.ImpAccount.password, this.restoreAccountOBJ.privateKey)
console.log(this.restoreAccountOBJ)
var recoveryPhraseArr = this.ImpAccount.recoveryPhrase.split(' ')
if (recoveryPhraseArr.length === 24) {
this.ImpAccount.privateKey = C.recoverPrivate(this.ImpAccount.recoveryPhrase)
this.restoreAccountOBJ = C.recoveryAccount(this.ImpAccount.privateKey)
this.restoreAccountOBJ.privateKey = C.encryptPrivKey(this.ImpAccount.password, this.restoreAccountOBJ.privateKey)
console.log(this.restoreAccountOBJ)
} else if (recoveryPhraseArr.length === 12) {
this.ImpAccount.privateKey = C.recoverPrivate(this.ImpAccount.recoveryPhrase) + C.recoverPrivate(this.ImpAccount.recoveryPhrase)
this.restoreAccountOBJ = C.recoveryAccount(this.ImpAccount.privateKey)
this.restoreAccountOBJ.privateKey = C.encryptPrivKey(this.ImpAccount.password, this.restoreAccountOBJ.privateKey)
console.log(this.restoreAccountOBJ)
} else {
this.$notify.error({
message: 'error',
duration: 2000
})
}
}
this.restoreAccountOBJ.identicon = createIcon({ // All options are optional
seed: this.restoreAccountOBJ.address, // seed used to generate icon data, default: random
size: 10, // width/height of the icon in blocks, default: 10
scale: 8 // width/height of each block in pixels, default: 5
}).toDataURL()
this.import_page += 1
} else {
this.$message({
Expand Down Expand Up @@ -267,13 +293,6 @@ export default {
console.log('QRCode success!')
})
},
checkPhrase (data) {
if (this.restoreAccountOBJ.recoverPhrase === data) {
} else {
}
},
creat () {
C.accountStorage(this.ImpAccount, this.restoreAccountOBJ)
this.$router.push({ path: '/account' })
Expand Down
20 changes: 17 additions & 3 deletions src/renderer/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ C.createAccount = function () {
return og.newAccount()
}

C.createAccount_useBip39 = function () {
var mnemonic = bip39.generateMnemonic()
var entropy = bip39.mnemonicToEntropy(mnemonic)
var privateKey = entropy + entropy
var newAccount = og.recoveryAccount(privateKey)
newAccount.recoverPhrase = mnemonic
return newAccount
}

C.checkTxStatus = function () {
db.query('SELECT * from txHistory where cStatus == "pending"').then((data) => {
console.log(data)
Expand All @@ -103,7 +112,12 @@ C.getBalance = function (addr) {
}

C.getRecoverPhrase = function (data) {
return bip39.entropyToMnemonic(data)
console.log(bip39.entropyToMnemonic(data))
return bip39.entropyToMnemonic(data) // 24
}

C.generateRecoverPhase = function () {
return bip39.generateMnemonic() // 12
}

C.recoverPrivate = function (data) {
Expand Down Expand Up @@ -211,8 +225,8 @@ C.layoutPDF = function (data) {
{ text: 'address:', style: 'header' },
data.address, '\n',
{ qr: data.address }, '\n',
{ text: 'privKey:', style: 'header' },
data.secp_privKey, '\n',
// { text: 'privKey:', style: 'header' },
// data.secp_privKey, '\n',
{ text: 'recoverPhrase:', style: 'header' },
data.recoverPhrase, '\n'
]
Expand Down

0 comments on commit 0174293

Please sign in to comment.