mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-20 10:12:01 +01:00
25 lines
583 B
TypeScript
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;
|
|
}
|
|
}
|
|
}
|