diff --git a/src/wallet/qi-hdwallet.ts b/src/wallet/qi-hdwallet.ts index ccb30aa7..fa6a01a1 100644 --- a/src/wallet/qi-hdwallet.ts +++ b/src/wallet/qi-hdwallet.ts @@ -1458,12 +1458,18 @@ export class QiHDWallet extends AbstractHDWallet { } } - // update addresses map - const updatedAddressesForMap = addresses.map((addr) => { + // Create a map to track unique addresses + const uniqueAddressMap = new Map(); + + // Process addresses in order, with updated addresses taking precedence + addresses.forEach((addr) => { const updatedAddr = updatedAddresses.find((a) => a.address === addr.address); - return updatedAddr || addr; + uniqueAddressMap.set(addr.address, updatedAddr || addr); }); + // Convert map values back to array + const updatedAddressesForMap = Array.from(uniqueAddressMap.values()); + this._addressesMap.set(path, updatedAddressesForMap); const executeCreatedOutpointsCallback = async () => {