Skip to content

Commit

Permalink
REF: last tx fetch time (rel BlueWallet#2963)
Browse files Browse the repository at this point in the history
  • Loading branch information
Overtorment committed Apr 21, 2021
1 parent ad931ec commit bdb2bd9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
7 changes: 7 additions & 0 deletions class/wallets/abstract-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ export class AbstractWallet {
this._utxoMetadata = {};
}

/**
* @returns {number} Timestamp (millisecsec) of when last transactions were fetched from the network
*/
getLastTxFetch() {
return this._lastTxFetch;
}

getID() {
return createHash('sha256').update(this.getSecret()).digest().toString('hex');
}
Expand Down
8 changes: 8 additions & 0 deletions class/wallets/watch-only-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ export class WatchOnlyWallet extends LegacyWallet {
this.masterFingerprint = false;
}

/**
* @inheritDoc
*/
getLastTxFetch() {
if (this._hdWalletInstance) return this._hdWalletInstance.getLastTxFetch();
return super.getLastTxFetch();
}

allowSend() {
return this.useWithHardwareWalletEnabled() && this.isHd() && this._hdWalletInstance.allowSend();
}
Expand Down
2 changes: 1 addition & 1 deletion screen/wallets/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const WalletTransactions = () => {

// refresh transactions if it never hasn't been done. It could be a fresh imported wallet
useEffect(() => {
if (wallet._lastTxFetch === 0) {
if (wallet.getLastTxFetch() === 0) {
refreshTransactions();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down

0 comments on commit bdb2bd9

Please sign in to comment.