From ba36dc6aa790a0f4619d2155a2db4c24a3895ac3 Mon Sep 17 00:00:00 2001 From: overtorment Date: Fri, 17 Mar 2023 12:56:35 +0000 Subject: [PATCH] FIX: skip faulty bip47 notification transactions --- class/wallets/abstract-hd-electrum-wallet.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/class/wallets/abstract-hd-electrum-wallet.ts b/class/wallets/abstract-hd-electrum-wallet.ts index 393b9c58e..c408a55bd 100644 --- a/class/wallets/abstract-hd-electrum-wallet.ts +++ b/class/wallets/abstract-hd-electrum-wallet.ts @@ -1487,6 +1487,14 @@ export class AbstractHDElectrumWallet extends AbstractHDWallet { try { const paymentCode = bip47_instance.getPaymentCodeFromRawNotificationTransaction(txHex); if (this._sender_payment_codes.includes(paymentCode)) continue; // already have it + + // final check if PC is even valid (could've been constructed by a buggy code, and our code would crash with that): + try { + BIP47Factory(ecc).fromPaymentCode(paymentCode); + } catch (_) { + continue; + } + this._sender_payment_codes.push(paymentCode); this._next_free_payment_code_address_index[paymentCode] = 0; // initialize this._balances_by_payment_code_index[paymentCode] = { c: 0, u: 0 };