Skip to content

Commit

Permalink
fix duplicated addresses in qi hd wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
alejoacosta74 committed Dec 19, 2024
1 parent 13b3a11 commit b0ef5d2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/wallet/qi-hdwallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1458,12 +1458,18 @@ export class QiHDWallet extends AbstractHDWallet<QiAddressInfo> {
}
}

// update addresses map
const updatedAddressesForMap = addresses.map((addr) => {
// Create a map to track unique addresses
const uniqueAddressMap = new Map<string, QiAddressInfo>();

// 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 () => {
Expand Down

0 comments on commit b0ef5d2

Please sign in to comment.