Skip to content

Commit

Permalink
Merge pull request #410 from ZencashOfficial/development
Browse files Browse the repository at this point in the history
  • Loading branch information
cronicc committed May 10, 2019
2 parents 3c8f518 + 899bab8 commit 9c778aa
Show file tree
Hide file tree
Showing 8 changed files with 11,728 additions and 265 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

# Version History

## v1.2.3
- [x] Fix transaction history crashing the app for some users
- [x] Clarify intent of transaction limit setting

## v1.2.2

- [x] Fix: Add Async to vout array manipulation to improve performance
Expand Down
2 changes: 1 addition & 1 deletion app/lang/lang_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
},
"settings": {
"label": "Settings",
"limit": "Transaction limit",
"limit": "Transaction history display limit",
"items": "items",
"language": "Language",
"explorerUrl": "ZEN Explorer URL",
Expand Down
29 changes: 23 additions & 6 deletions app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,19 @@ async function apiPost(url, form) {
function getFilteredVout(address, originalVout) {
return new Promise(resolve => {
resolve(originalVout.filter(vout => {
return address.has(vout.scriptPubKey.addresses[0]);
return address.has(vout.scriptPubKey.addresses[0]);
}));
});
}

/**
* @param {Set} address
* @param {object[]} originalVin
*/
function getFilteredVin(address, originalVin) {
return new Promise(resolve => {
resolve(originalVin.filter(vin => {
return address.has(vin.addr);
}));
});
}
Expand All @@ -633,9 +645,10 @@ async function fetchTransactions(txIds, myAddrs) {
// Address field in transaction rows is meaningless. Pick something sane.
let firstMyAddr;

info.vout = await getFilteredVout(myAddrSet, info.vout);
const filteredVout = await getFilteredVout(myAddrSet, info.vout);
const filteredVin = await getFilteredVin(myAddrSet, info.vin);

for (const vout of info.vout) {
for (const vout of filteredVout) {
// XXX can it be something else?
if (!vout.scriptPubKey) {
continue;
Expand All @@ -649,31 +662,35 @@ async function fetchTransactions(txIds, myAddrs) {
firstMyAddr = addr;
}
}

if (!vouts.includes(addr)) {
vouts.push(addr);
}
}
}

for (const vin of info.vin) {
for (const vin of filteredVin) {
const addr = vin.addr;
if (myAddrSet.has(addr)) {
txBalance -= parseFloat(vin.value);
if (!firstMyAddr) {
firstMyAddr = addr;
}
}

if (!vins.includes(addr)) {
vins.push(addr);
}
}

const isWithdraw = txBalance < 0;

const tx = {
txid: info.txid,
time: info.blocktime,
address: firstMyAddr,
vins: vins.join(","),
vouts: vouts.join(","),
vins: isWithdraw ? [...new Set(filteredVin.map(vin => vin.addr))].join(',') : [...new Set(info.vin.map(vin => vin.addr))].join(','),
vouts: isWithdraw ? [...new Set(info.vout.map(vout => vout.scriptPubKey.addresses[0]))].join(',') : [...new Set(filteredVout.map(vout => vout.scriptPubKey.addresses[0]))].join(','),
amount: txBalance,
block: info.blockheight
};
Expand Down
2 changes: 1 addition & 1 deletion app/zwallet.html
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ <h2 slot=headerText data-tr=wallet.settings.label>Settings</h2>
<span class=checkmark></span>
</label>

<label for=settingsTxHistory data-tr=wallet.settings.limit>Transaction limit</label>
<label for=settingsTxHistory data-tr=wallet.settings.limit>Transaction history display limit</label>
<span class=formInput><input type=number name=settingsTxHistory class=settingsTxHistory min=0 /><span data-tr=wallet.settings.items>items</span></span>

<hr class=formDivider />
Expand Down
Binary file added build/install-spinner.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9c778aa

Please sign in to comment.