From 056a31fc793562a54dc980da9a215411f4043ebb Mon Sep 17 00:00:00 2001 From: softsimon Date: Sun, 27 Feb 2022 15:54:18 +0300 Subject: [PATCH] Only return unique address prefix autocomplete fixes #1290 --- backend/src/api/bitcoin/bitcoin-api.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/src/api/bitcoin/bitcoin-api.ts b/backend/src/api/bitcoin/bitcoin-api.ts index 9950cdcb3..e6d74ddf0 100644 --- a/backend/src/api/bitcoin/bitcoin-api.ts +++ b/backend/src/api/bitcoin/bitcoin-api.ts @@ -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 {