@ducatus/ducatus-wallet-service-rev
Version:
A service for Mutisig HD Bitcoin Wallets
32 lines (28 loc) • 811 B
text/typescript
import { BitcoreLibCash } from '@ducatus/ducatus-crypto-wallet-core-rev';
import { IChain } from '..';
import { BtcChain } from '../btc';
const Errors = require('../../errors/errordefinitions');
export class BchChain extends BtcChain implements IChain {
constructor() {
super(BitcoreLibCash);
}
validateAddress(wallet, inaddr, opts) {
const A = BitcoreLibCash.Address;
let addr: {
network?: string;
toString?: (cashAddr: boolean) => string;
} = {};
try {
addr = new A(inaddr);
} catch (ex) {
throw Errors.INVALID_ADDRESS;
}
if (addr.network.toString() != wallet.network) {
throw Errors.INCORRECT_ADDRESS_NETWORK;
}
if (!opts.noCashAddr) {
if (addr.toString(true) != inaddr) throw Errors.ONLY_CASHADDR;
}
return;
}
}