const AdoracoreLibCash = require('@adora-wallet/adoracore-lib-cash'); import { AbstractAdoracoreLibDeriver } from '../btc'; export class BchDeriver extends AbstractAdoracoreLibDeriver { adoracoreLib = AdoracoreLibCash; deriveAddress(network, pubKey, addressIndex, isChange) { const xpub = new this.adoracoreLib.HDPublicKey(pubKey, network); const changeNum = isChange ? 1 : 0; const path = `m/${changeNum}/${addressIndex}`; return this.adoracoreLib.Address(xpub.derive(path).publicKey, network).toString(true); } derivePrivateKey(network, xPriv, addressIndex, isChange) { const xpriv = new this.adoracoreLib.HDPrivateKey(xPriv, network); const changeNum = isChange ? 1 : 0; const path = `m/${changeNum}/${addressIndex}`; const privKey = xpriv.deriveChild(path).privateKey; const pubKey = privKey.publicKey; const address = this.adoracoreLib.Address(pubKey, network).toString(true); return { address, privKey: privKey.toString(), pubKey: pubKey.toString() }; } }