BlueWallet/class/contact-list.ts
2024-05-21 11:56:10 +01:00

25 lines
583 B
TypeScript

import BIP47Factory from '@spsina/bip47';
import ecc from '../blue_modules/noble_ecc';
import { TWallet } from './wallets/types';
export class ContactList {
private _wallet: TWallet;
constructor(wallet: TWallet) {
if (!wallet.allowBIP47()) throw new Error('BIP47 is not allowed for the wallet');
if (!wallet.isBIP47Enabled()) throw new Error('BIP47 is not enabled');
this._wallet = wallet;
}
isPaymentCodeValid(pc: string): boolean {
try {
BIP47Factory(ecc).fromPaymentCode(pc);
return true;
} catch (_) {
return false;
}
}
}