Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 4x 4x 4x 6x 4x 4x 4x 4x | import { addressNListToBIP32, BTCInputScriptType, BTCOutputScriptType } from "@shapeshiftoss/hdwallet-core";
import * as bitcoin from "@bithighlander/bitcoin-cash-js-lib";
import { getNetwork } from "./networks";
type BTCScriptType = BTCInputScriptType | BTCOutputScriptType;
function getKeyPair(
seed: bitcoin.BIP32Interface,
addressNList: number[],
network = "bitcoin",
scriptType?: BTCScriptType
): { privateKey: string; publicKey: string } {
const path = addressNListToBIP32(addressNList);
const keypair = bitcoin.ECPair.fromWIF(seed.derivePath(path).toWIF(), getNetwork(network, scriptType));
return {
// @ts-ignore
privateKey: keypair.privateKey.toString("hex"),
publicKey: keypair.publicKey.toString("hex"),
};
}
// Prevent malicious JavaScript from replacing the method
export default Object.freeze({
getKeyPair,
});
|