Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch next minor release fixes to v1.5 #450

Merged
merged 7 commits into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .electrify/package-lock.json

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

2 changes: 1 addition & 1 deletion imports/startup/both/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import './nodes.js'
SHOR_PER_QUANTA = 1000000000

// qrl-wallet Version
WALLET_VERSION = '1.5.0'
WALLET_VERSION = '1.5.1'

// qrl.proto sha256 sum for each release of QRL Node
QRLPROTO_SHA256 = [
Expand Down
53 changes: 53 additions & 0 deletions imports/startup/client/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1052,3 +1052,56 @@ nodeReturnedValidResponse = (request, response, type, tokenDecimals = 0) => {
// We should not get this far - return false as failsafe
return false
}

export function checkIfLedgerTreesMatch() {
const appLedger = hexOrB32(Session.get('transferFromAddress'))
console.log('appLedger', appLedger)
console.log('-- Getting QRL Ledger Nano Public Key --')
if (isElectrified()) {
Meteor.call('ledgerPublicKey', [], (err, data) => {
console.log('> Got Ledger Public Key from USB')
// Convert Uint to hex
const pkHex = Buffer.from(data.public_key).toString('hex')
// Get address from pk
const qAddress = QRLLIB.getAddress(pkHex)
const ledgerQAddress = `Q${qAddress}`
console.log(ledgerQAddress)
if (appLedger !== ledgerQAddress) {
console.log('Trees switched: logout!')
Session.set('closedWithError', 'XMSS-trees-change')
FlowRouter.go('/close')
}
// callback(null, data)
})
} else {
createTransport().then(QrlLedger => {
QrlLedger.publickey().then(data => {
if (ledgerReturnedError()) {
console.log('-- Ledger error --')
} else {
console.log('> Got Ledger Public Key from WebUSB')
// Convert Uint to hex
const pkHex = Buffer.from(data.public_key).toString('hex')
// Get address from pk
const qAddress = QRLLIB.getAddress(pkHex)
const ledgerQAddress = `Q${qAddress}`
console.log(ledgerQAddress)
if (appLedger !== ledgerQAddress) {
console.log('Trees switched: logout!')
Session.set('closedWithError', 'XMSS-trees-change')
FlowRouter.go('/close')
}
// callback(null, data)
}
}, e => {
console.log(`-- Ledger error: ${e} --`)
}).catch(e => {
console.log(`-- Ledger error: ${e} --`)
}).catch(e => {
console.log(`-- Ledger error: ${e} --`)
})
}, e => {
console.log(`-- Ledger error: ${e} --`)
})
}
}
18 changes: 18 additions & 0 deletions imports/ui/pages/close/close.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,22 @@ <h2 id="closeWallet" class="ui center aligned icon header">
</h2>
</div>

<div class="small ui modal" id="closedWithError">
<div class="header">Ledger XMSS Tree Changed</div>
<div class="content">
<div class="ui warning icon message">
<i class="warning icon"></i>
<div class="content">
<div class="header">

</div>
<p>The XMSS tree on the Ledger device has changed. Please re-open the wallet to use functions for this XMSS tree.</p>
</div>
</div>
</div>
<div class="actions">
<div class="ui green approve button">OK</div>
</div>
</div>

</template>
20 changes: 20 additions & 0 deletions imports/ui/pages/close/close.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,24 @@ import './close.html'
Template.appAddressClose.onRendered(() => {
XMSS_OBJECT = null // eslint-disable-line
resetWalletStatus()
if (Session.get('closedWithError')) {
$('#closedWithError').modal({
onApprove: () => {
Session.set('closedWithError', false)
},
onDeny: () => {
Session.set('closedWithError', false)
},
onHide: () => {
Session.set('closedWithError', false)
},
}).modal('show')
}
})

// Template.appAddressClose.events({
// 'click .green': () => {
// console.log('dismiss')
// $('#closedWithError').modal().modal('hide')
// },
// })
2 changes: 1 addition & 1 deletion imports/ui/pages/create/address.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ <h4 class="ui header">Mnemonic Phrase</h4>

<h4 class="ui header">Hexseed</h4>
<div class="ui inverted segment">
<p style="word-wrap: break-word;">{{newAddress.hexseed}}</p>
<p id="newAddressHexseed" style="word-wrap: break-word;">{{newAddress.hexseed}}</p>
</div>

<div class="ui stackable three column grid">
Expand Down
3 changes: 3 additions & 0 deletions imports/ui/pages/create/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ function generateWallet() {

// If it worked, send the user to the address page.
if (newAddress !== '') {
// close existing wallet if open
resetWalletStatus()

Session.set('passphrase', passphrase)
Session.set('xmssHeight', xmssHeight)

Expand Down
6 changes: 5 additions & 1 deletion imports/ui/pages/tools/xmssindex/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* global resetWalletStatus, passwordPolicyValid, countDecimals, supportedBrowser, wrapMeteorCall, getBalance, otsIndexUsed, ledgerHasNoTokenSupport, resetLocalStorageState, nodeReturnedValidResponse */
/* global POLL_TXN_RATE, POLL_MAX_CHECKS, DEFAULT_NETWORKS, findNetworkData, SHOR_PER_QUANTA, WALLET_VERSION, QRLPROTO_SHA256, */

import { isElectrified, createTransport, ledgerReturnedError } from '../../../../startup/client/functions'
import { isElectrified, createTransport, ledgerReturnedError, checkIfLedgerTreesMatch } from '../../../../startup/client/functions'
// import async from 'async'
import './update.html'

Expand Down Expand Up @@ -120,3 +120,7 @@ Template.appXmssIndexUpdate.helpers({
return transferFrom
},
})

Template.appXmssIndexUpdate.onRendered(() => {
checkIfLedgerTreesMatch()
})
38 changes: 24 additions & 14 deletions imports/ui/pages/transfer/transfer.html
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ <h3>Error communicating with Ledger Nano. To save an OTS Key, you should reject
<!-- Confirm Transaction Area -->
<div id="confirmTransactionArea" style="display: none;">

<div class="ui icon message transactionRecord">
<div class="ui icon message">
<img class="transactionTypeImage" src="/img/icons/send.png" />
<div class="content">
<div class="header">
Expand All @@ -447,7 +447,17 @@ <h3>Error communicating with Ledger Nano. To save an OTS Key, you should reject
{{transactionConfirmationAmount}} Quanta
</div>
</div>

{{#if includesMessage}}
<form>
<div class="field">
<label>Message</label>
<div class="ui visible message">
{{messageText}}
</div>
</div>
</form>
<p>&nbsp;</p>
{{/if}}
<form>
<div class="field">
<label>Recipients</label>
Expand Down Expand Up @@ -502,7 +512,7 @@ <h4 class="ui horizontal divider header">

<!-- Confirm Token Transaction Area -->
<div id="confirmTokenTransactionArea" style="display: none;">
<div class="ui icon message transactionRecord">
<div class="ui icon message">
<img class="transactionTypeImage" src="/img/icons/send.png" />
<div class="content">
<div class="header">
Expand Down Expand Up @@ -867,7 +877,7 @@ <h4 class="ui pageHeader header">
{{#if addressHasTransactions}}
{{#each addressTransactions}}
{{#if isTransfer this.tx.transactionType}}
<div class="ui icon message transactionRecord">
<div class="ui icon message transactionRecord" data-txhash="{{this.tx.transaction_hash}}">
{{#if isMyAddress this.addr_from}}
<img class="transactionTypeImage" src="/img/icons/send.png" />
{{else}}
Expand Down Expand Up @@ -899,7 +909,7 @@ <h4 class="ui pageHeader header">
{{/if}}

{{#if isTokenCreation this.tx.transactionType}}
<div class="ui icon message transactionRecord">
<div class="ui icon message transactionRecord" data-txhash="{{this.tx.transaction_hash}}">
<img class="transactionTypeImage" src="/img/icons/send.png" />
<div class="content">
<div class="header">
Expand All @@ -916,7 +926,7 @@ <h4 class="ui pageHeader header">
{{/if}}

{{#if isTokenTransfer this.tx.transactionType}}
<div class="ui icon message transactionRecord">
<div class="ui icon message transactionRecord" data-txhash="{{this.tx.transaction_hash}}">
{{#if isMyAddress this.addr_from}}
<img class="transactionTypeImage" src="/img/icons/send.png" />
{{else}}
Expand Down Expand Up @@ -948,7 +958,7 @@ <h4 class="ui pageHeader header">
{{/if}}

{{#if isCoinbaseTxn this.tx.transactionType}}
<div class="ui icon message transactionRecord">
<div class="ui icon message transactionRecord" data-txhash="{{this.tx.transaction_hash}}">
<img class="transactionTypeImage" src="/img/icons/receive.png" />
<div class="content">
<div class="header">
Expand All @@ -965,7 +975,7 @@ <h4 class="ui pageHeader header">
{{/if}}

{{#if isSlaveTxn this.tx.transactionType}}
<div class="ui icon message transactionRecord">
<div class="ui icon message transactionRecord" data-txhash="{{this.tx.transaction_hash}}">
<img class="transactionTypeImage" src="/img/icons/send.png" />
<div class="content">
<div class="header">
Expand All @@ -982,7 +992,7 @@ <h4 class="ui pageHeader header">
{{/if}}

{{#if isLatticePKTxn this.tx.transactionType}}
<div class="ui icon message transactionRecord">
<div class="ui icon message transactionRecord" data-txhash="{{this.tx.transaction_hash}}">
<img class="transactionTypeImage" src="/img/icons/send.png" />
<div class="content">
<div class="header">
Expand All @@ -999,7 +1009,7 @@ <h4 class="ui pageHeader header">
{{/if}}

{{#if isCreateMultiSigTxn this.tx.transactionType}}
<div class="ui icon message transactionRecord">
<div class="ui icon message transactionRecord" data-txhash="{{this.tx.transaction_hash}}">
<img class="transactionTypeImage" src="/img/icons/send.png" />
<div class="content">
<div class="header">
Expand All @@ -1016,7 +1026,7 @@ <h4 class="ui pageHeader header">
{{/if}}

{{#if isSpendMultiSigTxn this.tx.transactionType}}
<div class="ui icon message transactionRecord">
<div class="ui icon message transactionRecord" data-txhash="{{this.tx.transaction_hash}}">
<img class="transactionTypeImage" src="/img/icons/send.png" />
<div class="content">
<div class="header">
Expand All @@ -1033,7 +1043,7 @@ <h4 class="ui pageHeader header">
{{/if}}

{{#if isVoteMultiSigTxn this.tx.transactionType}}
<div class="ui icon message transactionRecord">
<div class="ui icon message transactionRecord" data-txhash="{{this.tx.transaction_hash}}">
<img class="transactionTypeImage" src="/img/icons/send.png" />
<div class="content">
<div class="header">
Expand All @@ -1050,7 +1060,7 @@ <h4 class="ui pageHeader header">
{{/if}}

{{#if isMessageTxn this.tx.transactionType}}
<div class="ui icon message transactionRecord">
<div class="ui icon message transactionRecord" data-txhash="{{this.tx.transaction_hash}}">
<img class="transactionTypeImage" src="/img/icons/send.png" />
<div class="content">
<div class="header">
Expand All @@ -1067,7 +1077,7 @@ <h4 class="ui pageHeader header">
{{/if}}

{{#if isDocumentNotarisation this.tx.transactionType}}
<div class="ui icon message transactionRecord">
<div class="ui icon message transactionRecord" data-txhash="{{this.tx.transaction_hash}}">
<img class="transactionTypeImage" src="/img/icons/send.png" />
<div class="content">
<div class="header">
Expand Down
26 changes: 25 additions & 1 deletion imports/ui/pages/transfer/transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,12 @@ Template.appTransfer.onRendered(() => {
})

Template.appTransfer.events({
'click .transactionRecord': (event) => {
event.preventDefault()
event.stopPropagation()
const txhash = $(event.target).closest('.transactionRecord').data('txhash')
FlowRouter.go(`/verify-txid/${txhash}`)
},
'click #showMessageField': (event) => {
event.preventDefault()
event.stopPropagation()
Expand Down Expand Up @@ -1062,6 +1068,20 @@ Template.appTransfer.events({
})

Template.appTransfer.helpers({
includesMessage() {
try {
const m = Session.get('transactionConfirmationMessage')
if (m.length > 0) {
return true
}
return false
} catch (e) {
return false
}
},
messageText() {
return Buffer.from(Session.get('transactionConfirmationMessage')).toString()
},
tokenTotalTransferred() {
const num = this.totalTransferred
const { decimals } = this.tx.transfer_token
Expand Down Expand Up @@ -1300,7 +1320,11 @@ Template.appTransfer.helpers({
return tokens
},
balanceAmount() {
return Session.get('balanceAmount')
const b = Session.get('balanceAmount')
if (b !== '') {
return b
}
return Session.get('transferFromBalance')
},
balanceSymbol() {
return Session.get('balanceSymbol')
Expand Down
12 changes: 7 additions & 5 deletions imports/ui/pages/verify/tx.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Template.appVerifyTxid.onRendered(() => {
if (thisTxId) {
wrapMeteorCall('txhash', request, (err, res) => {
if (err) {
Session.set('txhash', { error: err, id: thisTxId })
Session.set('txhash', { error: err.message, id: thisTxId })
} else {
Session.set('txhash', res)
}
Expand All @@ -51,10 +51,12 @@ Template.appVerifyTxid.onRendered(() => {

Template.appVerifyTxid.helpers({
tx() {
const txhash = Session.get('txhash').transaction
const signature = txhash.tx.signature // eslint-disable-line
txhash.tx.ots_key = parseInt(signature.substring(0, 8), 16)
return txhash
try {
const txhash = Session.get('txhash').transaction
return txhash
} catch (e) {
return false
}
},
bech32() {
if (Session.get('addressFormat') === 'bech32') {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "qrl-wallet",
"version": "1.5.0",
"version": "1.5.1",
"description": "QRL Wallet",
"author": "The QRL Contributors",
"license": "MIT",
Expand Down