|
|
@ -98,6 +98,9 @@ export async function getAccount({ |
|
|
|
}), |
|
|
|
}) |
|
|
|
|
|
|
|
const getAsyncAddress = params => |
|
|
|
new Promise(resolve => setTimeout(() => resolve(getAddress(params)), 100)) |
|
|
|
|
|
|
|
const getLastAddress = (addresses, txs) => { |
|
|
|
const txsAddresses = [...txs.inputs.map(tx => tx.prev_out.addr), ...txs.out.map(tx => tx.addr)] |
|
|
|
const lastAddress = addresses.reverse().find(a => txsAddresses.includes(a.address)) || { |
|
|
@ -110,14 +113,19 @@ export async function getAccount({ |
|
|
|
} |
|
|
|
|
|
|
|
const nextPath = (index = 0) => |
|
|
|
Promise.all( |
|
|
|
Array.from(new Array(gapLimit).keys()).map(v => |
|
|
|
Promise.all([ |
|
|
|
getAddress({ type: 'external', index: v + index }), |
|
|
|
getAddress({ type: 'internal', index: v + index }), |
|
|
|
]), |
|
|
|
), |
|
|
|
).then(async results => { |
|
|
|
Array.from(new Array(gapLimit).keys()) |
|
|
|
.reduce( |
|
|
|
(promise, v) => |
|
|
|
promise.then(async results => { |
|
|
|
const result = await Promise.all([ |
|
|
|
getAsyncAddress({ type: 'external', index: v + index }), |
|
|
|
getAsyncAddress({ type: 'internal', index: v + index }), |
|
|
|
]) |
|
|
|
return [...results, result] |
|
|
|
}), |
|
|
|
Promise.resolve([]), |
|
|
|
) |
|
|
|
.then(async results => { |
|
|
|
const addresses = results.reduce((result, v) => [...result, ...v], []) |
|
|
|
const listAddresses = addresses.map(a => a.address) |
|
|
|
|
|
|
|