|
|
@ -51,37 +51,53 @@ class WalletService { |
|
|
|
const walletInfo = new WalletInfo(active) |
|
|
|
|
|
|
|
try { |
|
|
|
// Add the new xpubs
|
|
|
|
await util.seriesCall(legacy.xpubs, this._newBIP44) |
|
|
|
await util.seriesCall(bip49.xpubs, this._newBIP49) |
|
|
|
await util.seriesCall(bip84.xpubs, this._newBIP84) |
|
|
|
// Load hd accounts info
|
|
|
|
await walletInfo.ensureHdAccounts() |
|
|
|
await walletInfo.loadHdAccountsInfo() |
|
|
|
// Add the new addresses
|
|
|
|
await db.addAddresses(legacy.addrs) |
|
|
|
await db.addAddresses(bip49.addrs) |
|
|
|
await db.addAddresses(bip84.addrs) |
|
|
|
await db.addAddresses(pubkeys.addrs) |
|
|
|
// Ensure addresses exist
|
|
|
|
await walletInfo.ensureAddresses() |
|
|
|
await Promise.all([ |
|
|
|
|
|
|
|
// Add the new xpubs
|
|
|
|
util.parallelCall(legacy.xpubs, this._newBIP44), |
|
|
|
util.parallelCall(bip49.xpubs, this._newBIP49), |
|
|
|
util.parallelCall(bip84.xpubs, this._newBIP84), |
|
|
|
// Add the new addresses
|
|
|
|
db.addAddresses(legacy.addrs), |
|
|
|
db.addAddresses(bip49.addrs), |
|
|
|
db.addAddresses(bip84.addrs), |
|
|
|
db.addAddresses(pubkeys.addrs), |
|
|
|
]) |
|
|
|
|
|
|
|
// Ensure hd accounts and addresses exist
|
|
|
|
await Promise.all([ |
|
|
|
walletInfo.ensureHdAccounts(), |
|
|
|
walletInfo.ensureAddresses(), |
|
|
|
]) |
|
|
|
|
|
|
|
// Force import of addresses associated to paynyms
|
|
|
|
// if dojo relies on a local index
|
|
|
|
if (keys.indexer.active != 'third_party_explorer') |
|
|
|
await this._forceEnsureAddressesForActivePubkeys(active) |
|
|
|
|
|
|
|
// Filter the addresses
|
|
|
|
await walletInfo.filterAddresses() |
|
|
|
// Load the utxos
|
|
|
|
await walletInfo.loadUtxos() |
|
|
|
// Load the addresses
|
|
|
|
await walletInfo.loadAddressesInfo() |
|
|
|
// Load the most recent transactions
|
|
|
|
await walletInfo.loadTransactions(0, null, true) |
|
|
|
// Load feerates
|
|
|
|
await walletInfo.loadFeesInfo() |
|
|
|
|
|
|
|
// Load wallet information
|
|
|
|
await Promise.all([ |
|
|
|
// Load the hd accounts,
|
|
|
|
walletInfo.loadHdAccountsInfo(), |
|
|
|
// Load the utxos
|
|
|
|
walletInfo.loadUtxos(), |
|
|
|
// Load the addresses
|
|
|
|
walletInfo.loadAddressesInfo(), |
|
|
|
// Load the most recent transactions
|
|
|
|
walletInfo.loadTransactions(0, null, true), |
|
|
|
// Load feerates
|
|
|
|
walletInfo.loadFeesInfo(), |
|
|
|
]) |
|
|
|
|
|
|
|
// Postprocessing
|
|
|
|
await walletInfo.postProcessAddresses() |
|
|
|
await walletInfo.postProcessHdAccounts() |
|
|
|
await Promise.all([ |
|
|
|
walletInfo.postProcessAddresses(), |
|
|
|
walletInfo.postProcessHdAccounts(), |
|
|
|
]) |
|
|
|
|
|
|
|
// Format the result
|
|
|
|
return this._formatGetFullWalletInfoResult(walletInfo) |
|
|
|
|
|
|
@ -250,7 +266,7 @@ class WalletService { |
|
|
|
return ret |
|
|
|
|
|
|
|
} catch(e) { |
|
|
|
Logger.error(e, 'WalletService.getWalletUtxos()') |
|
|
|
Logger.error(e, 'WalletService.getWalletUtxos()') |
|
|
|
return Promise.reject({status: 'error', error: 'internal server error'}) |
|
|
|
} |
|
|
|
} |
|
|
@ -280,20 +296,25 @@ class WalletService { |
|
|
|
try { |
|
|
|
// Filter the addresses
|
|
|
|
await walletInfo.filterAddresses() |
|
|
|
// Load the number of transactions
|
|
|
|
await walletInfo.loadNbTransactions() |
|
|
|
// Load the requested page of transactions
|
|
|
|
await walletInfo.loadTransactions(page, count, false) |
|
|
|
|
|
|
|
await Promise.all([ |
|
|
|
// Load the number of transactions
|
|
|
|
walletInfo.loadNbTransactions(), |
|
|
|
// Load the requested page of transactions
|
|
|
|
walletInfo.loadTransactions(page, count, false), |
|
|
|
]) |
|
|
|
|
|
|
|
// Postprocessing
|
|
|
|
await walletInfo.postProcessAddresses() |
|
|
|
await walletInfo.postProcessHdAccounts() |
|
|
|
|
|
|
|
// Format the result
|
|
|
|
ret.n_tx = walletInfo.nTx |
|
|
|
ret.txs = walletInfo.txs |
|
|
|
return ret |
|
|
|
|
|
|
|
} catch(e) { |
|
|
|
Logger.error(e, 'WalletService.getWalletTransactions()') |
|
|
|
Logger.error(e, 'WalletService.getWalletTransactions()') |
|
|
|
return Promise.reject({status:'error', error:'internal server error'}) |
|
|
|
} |
|
|
|
} |
|
|
|