sendover
Version:
Tools for creating and paying invoices privately on Bitcoin SV
34 lines • 1.21 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateKeypair = void 0;
const babbage_bsv_1 = __importDefault(require("babbage-bsv"));
/**
* Generates a public/private keypair for the sending and receiving of invoices.
*
* @param params All parameters are given in an object
* @param params.returnType='hex' Return type, either "hex" or "babbage-bsv"
*
* @returns The generated keypair, with `privateKey` and `publicKey` properties.
*/
function generateKeypair(params) {
params || (params = {});
params.returnType || (params.returnType = 'hex');
const privateKey = babbage_bsv_1.default.PrivateKey.fromRandom();
if (params.returnType === 'babbage-bsv') {
return {
privateKey,
publicKey: privateKey.publicKey
};
}
else {
return {
privateKey: privateKey.bn.toHex({ size: 32 }),
publicKey: privateKey.publicKey.toString()
};
}
}
exports.generateKeypair = generateKeypair;
//# sourceMappingURL=generateKeypair.js.map