Skip to content

Commit

Permalink
update transaction categorising
Browse files Browse the repository at this point in the history
  • Loading branch information
davidstoneham committed Oct 4, 2020
1 parent 8f64b08 commit 0b94749
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/app/metrix/classes/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class Transaction {
timestamp: Date;
fee: number;
vout: number;
isReward: boolean;

constructor(transactionData?) {
if (transactionData) {
Expand All @@ -33,6 +34,10 @@ export class Transaction {
if (transactionData.blocktime) this.blockTime = new Date(transactionData.blocktime * 1000);
this.timestamp = new Date(transactionData.time * 1000);

// set type
if (this.category === "generate" || this.category === "immature")
this.isReward = true

// santise category
if (this.category === "send") this.category = "Payment"
if (this.category === "generate") this.category = "Stake"
Expand Down
2 changes: 1 addition & 1 deletion src/app/metrix/providers/rpc.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ export class RpcService {
for (const tx of data.result) {
const trx = new Transaction(tx)
if (trx.blockIndex === 1) {
if (trx.category !== 'Payment') {
if (trx.category !== 'Payment' && trx.vout < 4) {
let stake: any = await this.callServer('gettransaction', [trx.txId])
const totalReward = stake.result.details.find(e => e.vout === 1).fee
const dgpPayments = stake.result.details.reduce((a, b) => a.add(b.amount), Big(0))
Expand Down
2 changes: 1 addition & 1 deletion src/app/metrix/providers/wallet.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ export class WalletService {

private notifyUserNewTransaction(serverTrx: Transaction) {
// only notify new coins received
if (serverTrx.category.includes('Stake') || serverTrx.category === 'Received') {
if (serverTrx.isReward || serverTrx.category === 'Received') {
// check we have a block height so we don't notify already known transactions
if (this.walletInfo.startupBlockTime) {
// check we recieved this after the last time we synced
Expand Down
2 changes: 1 addition & 1 deletion src/app/providers/desktop-notification.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class DesktopNotificationService {
let title = 'Metrix - ';
if (trx.category === "Received")
title += await this.translation.translate('DESKTOPNOTIFICATIONS.NEWTRANSACTION_TITLE_RECEIVED');
if (trx.category.includes('Stake'))
if (trx.isReward)
title += await this.translation.translate('DESKTOPNOTIFICATIONS.NEWTRANSACTION_TITLE_STAKE');

// get body
Expand Down

0 comments on commit 0b94749

Please sign in to comment.