Only return unique address prefix autocomplete

fixes #1290
This commit is contained in:
softsimon 2022-02-27 15:54:18 +03:00
parent 5f19b6dd07
commit 056a31fc79
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7

View File

@ -84,19 +84,19 @@ class BitcoinApi implements AbstractBitcoinApi {
}
$getAddressPrefix(prefix: string): string[] {
const found: string[] = [];
const found: { [address: string]: string } = {};
const mp = mempool.getMempool();
for (const tx in mp) {
for (const vout of mp[tx].vout) {
if (vout.scriptpubkey_address.indexOf(prefix) === 0) {
found.push(vout.scriptpubkey_address);
if (found.length >= 10) {
return found;
found[vout.scriptpubkey_address] = '';
if (Object.keys(found).length >= 10) {
return Object.keys(found);
}
}
}
}
return found;
return Object.keys(found);
}
$sendRawTransaction(rawTransaction: string): Promise<string> {