From 1af6437cb1ba49d6aa954c36835f5455aefd6cc6 Mon Sep 17 00:00:00 2001 From: Alejo Acosta Date: Wed, 13 Nov 2024 09:12:42 -0300 Subject: [PATCH] implement custom address validator and harden addAddress method --- src/wallet/qi-hdwallet.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wallet/qi-hdwallet.ts b/src/wallet/qi-hdwallet.ts index c0d73e9e..d8175a8c 100644 --- a/src/wallet/qi-hdwallet.ts +++ b/src/wallet/qi-hdwallet.ts @@ -1307,6 +1307,10 @@ export class QiHDWallet extends AbstractHDWallet { if (existingAddresses && existingAddresses.some((addr) => addr.address === addressInfo.address)) { throw new Error(`Address ${addressInfo.address} already exists in the wallet`); } + const existingAddresses = wallet._addressesMap.get(key); + if (existingAddresses && existingAddresses.some((addr) => addr.address === addressInfo.address)) { + throw new Error(`Address ${addressInfo.address} already exists in the wallet`); + } wallet._addressesMap.get(key)!.push(addressInfo); }