From f75e9496dfd6ff7770d233db7cb69f03f41ee5f8 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Tue, 6 Apr 2021 17:20:43 +0300 Subject: [PATCH 1/2] increase address depth lookup for airdrop coins --- electron/package.json | 2 +- package.json | 2 +- src/App.js | 8 +++++--- src/CheckAllBalancesButton.js | 2 +- src/checkBalanceButton.js | 2 +- src/lib/account-discovery.js | 18 ++++++++++++------ src/lib/coins.js | 5 +++++ 7 files changed, 26 insertions(+), 13 deletions(-) diff --git a/electron/package.json b/electron/package.json index 37bc5671..569805e2 100755 --- a/electron/package.json +++ b/electron/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "hw-kmd-wallet-electron", - "version": "0.2.4", + "version": "0.2.5", "description": "Komodo Hardware Wallet Electron App", "main": "main.js", "scripts": { diff --git a/package.json b/package.json index 22c0c654..4a68429e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hw-kmd-wallet", - "version": "0.2.4", + "version": "0.2.5", "author": "Luke Childs (http://lukechilds.co.uk), Komodo Platform (https://komodoplatform.com)", "repository": "pbca26/hw-kmd-wallet", "homepage": "https://pbca26.github.io/hw-kmd-wallet", diff --git a/src/App.js b/src/App.js index 33de40d0..b2fc4d81 100755 --- a/src/App.js +++ b/src/App.js @@ -185,7 +185,7 @@ class App extends React.Component { console.warn('sync data called'); let [accounts, tiptime] = await Promise.all([ - accountDiscovery(), + accountDiscovery(this.state.vendor, this.state.coin), blockchain.getTipTime() ]); @@ -377,14 +377,16 @@ class App extends React.Component { + vendor={this.state.vendor} + coin={this.state.coin}> Check Balance + explorerEndpoint={this.state.explorerEndpoint} + coin={this.state.coin}> Check All diff --git a/src/CheckAllBalancesButton.js b/src/CheckAllBalancesButton.js index 2a683935..7eddab88 100644 --- a/src/CheckAllBalancesButton.js +++ b/src/CheckAllBalancesButton.js @@ -119,7 +119,7 @@ class CheckAllBalancesButton extends React.Component { currentAction = 'approve'; updateActionState(this, currentAction, 'loading'); let [accounts, tiptime] = await Promise.all([ - accountDiscovery(this.props.vendor), + accountDiscovery(this.props.vendor, this.props.coin), blockchain.getTipTime() ]); diff --git a/src/checkBalanceButton.js b/src/checkBalanceButton.js index 381b82ae..65b9c519 100644 --- a/src/checkBalanceButton.js +++ b/src/checkBalanceButton.js @@ -63,7 +63,7 @@ class CheckBalanceButton extends React.Component { currentAction = 'approve'; updateActionState(this, currentAction, 'loading'); let [accounts, tiptime] = await Promise.all([ - accountDiscovery(this.props.vendor), + accountDiscovery(this.props.vendor, this.props.coin), blockchain.getTipTime() ]); diff --git a/src/lib/account-discovery.js b/src/lib/account-discovery.js index b2e24b29..8f999498 100755 --- a/src/lib/account-discovery.js +++ b/src/lib/account-discovery.js @@ -4,13 +4,14 @@ import getAddress from './get-address'; import bitcoin from 'bitcoinjs-lib'; import parseHistory from './history-parser'; import asyncForEach from './async'; +import {airDropCoins} from './coins'; let pubKeysCache = {}; +let gapLimit = 20; const walkDerivationPath = async node => { const addresses = []; let addressConcurrency = 10; - let gapLimit = 20; let consecutiveUnusedAddresses = 0; let addressIndex = 0; @@ -182,10 +183,17 @@ export const getAddressHistoryOld = async addresses => { }; }; -const accountDiscovery = async vendor => { +const accountDiscovery = async (vendor, coin) => { const accounts = []; let accountIndex = 0; + if (airDropCoins.indexOf(coin) > -1 && + window.location.href.indexOf('extgap=') === -1) { + gapLimit = 50; + } else { + gapLimit = 20; + } + while (true) { const account = await getAccountAddresses(accountIndex, vendor); @@ -198,19 +206,17 @@ const accountDiscovery = async vendor => { }; account.accountIndex = accountIndex; accounts.push(account); - return accounts; + if (airDropCoins.indexOf(coin) === -1 || accountIndex === 4) return accounts; } else { account.utxos = await getAddressUtxos(account.addresses); account.history = await getAddressHistory(account.addresses); account.accountIndex = accountIndex; + accounts.push(account); } - accounts.push(account); accountIndex++; } - console.warn('accounts', accounts); - return accounts; }; diff --git a/src/lib/coins.js b/src/lib/coins.js index f245a216..7defd064 100644 --- a/src/lib/coins.js +++ b/src/lib/coins.js @@ -173,4 +173,9 @@ const coins = { */ }; +export const airDropCoins = [ + 'WSB', + 'VOTE2021', +]; + export default sortObject(coins); \ No newline at end of file From e0dab34f976ccee4ae89d25abe344705df5e493b Mon Sep 17 00:00:00 2001 From: pbca26 Date: Tue, 6 Apr 2021 18:13:35 +0300 Subject: [PATCH 2/2] reduce address concurrency if address gap is not default val --- src/lib/account-discovery.js | 2 ++ src/lib/coins.js | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/account-discovery.js b/src/lib/account-discovery.js index 8f999498..175540ec 100755 --- a/src/lib/account-discovery.js +++ b/src/lib/account-discovery.js @@ -23,6 +23,8 @@ const walkDerivationPath = async node => { if (window.location.href.indexOf('timeout=s') > -1) addressConcurrency = 2; if (window.location.href.indexOf('timeout=m') > -1) addressConcurrency = 5; + if (gapLimit > 20) addressConcurrency = 5; + while (consecutiveUnusedAddresses < gapLimit) { const addressApiRequests = []; diff --git a/src/lib/coins.js b/src/lib/coins.js index 7defd064..7d94fa6b 100644 --- a/src/lib/coins.js +++ b/src/lib/coins.js @@ -111,8 +111,8 @@ const coins = { VOTE2021: { explorer: 'https://vote2021.explorer.dexstats.info/', api: [ + 'https://explorer.komodoplatform.com:10000/vote2021/api/', 'https://vote2021.explorer.dexstats.info/insight-api-komodo/', - 'https://vote.kmdexplorer.io/insight-api-komodo/', ], }, RICK: { @@ -141,7 +141,10 @@ const coins = { }, WSB: { explorer: 'https://wsb.explorer.dexstats.info/', - api: ['https://wsb.explorer.dexstats.info/insight-api-komodo/'], + api: [ + 'https://wsb.explorer.dexstats.info/insight-api-komodo/', + 'https://explorer.komodoplatform.com:10000/wsb/api/', + ], }, SPACE: { explorer: 'https://space.explorer.dexstats.info/',