Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dashkeys

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dashkeys - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

12

base58check.types.js

@@ -128,2 +128,5 @@ module.exports._types = true;

* @param {String} base58check - WIF, Payment Address, xPrv, or xPub
* @param {Object} opts
* @param {[String, String]} opts.versions
* @param {[String, String]} opts.xversions
* @returns {Parts}

@@ -135,2 +138,3 @@ */

* @param {String} hex - magic version bytes + data + checksum
* @param {DecodeOpts} [opts]
* @returns {Parts}

@@ -140,2 +144,8 @@ */

/**
* @typedef DecodeOpts
* @prop {[String, String]} [versions]
* @prop {[String, String]} [xversions]
*/
/**
* @callback Verify

@@ -159,2 +169,4 @@ * @param {String} base58check - WIF, Payment Address, xPrv, or xPub

* @prop {Boolean} [verify] - set 'false' to set 'valid' false rather than throw
* @param {[String, String]} [versions]
* @param {[String, String]} [xversions]
*/

@@ -161,0 +173,0 @@

101

dashkeys.js

@@ -460,3 +460,3 @@ /** @typedef {import('./base-x.types.js').BaseX} BaseX */

b58c.verify = async function (b58Addr, opts) {
let bytes = bs58.decode(b58Addr);
let bytes = bs58.decode(b58Addr, opts);
let hex = Utils.bytesToHex(bytes);

@@ -468,3 +468,3 @@ return await b58c.verifyHex(hex, opts);

b58c.verifyHex = async function (base58check, opts) {
let parts = b58c.decodeHex(base58check);
let parts = b58c.decodeHex(base58check, opts);
let check = await b58c.checksum(parts);

@@ -484,13 +484,13 @@ let valid = parts.check === check;

/** @type {Base58CheckDecode} */
b58c.decode = function (b58Addr) {
b58c.decode = function (b58Addr, opts) {
let bytes = bs58.decode(b58Addr);
let hex = Utils.bytesToHex(bytes);
return b58c.decodeHex(hex);
return b58c.decodeHex(hex, opts);
};
/** @type {Base58CheckDecodeHex} */
b58c.decodeHex = function (addr) {
b58c.decodeHex = function (addr, opts) {
let version = addr.slice(0, privateKeyVersion.length);
let versions = [pubKeyHashVersion, privateKeyVersion];
let xversions = [xpubVersion, xprvVersion];
let versions = opts?.versions || [pubKeyHashVersion, privateKeyVersion];
let xversions = opts?.xversions || [xpubVersion, xprvVersion];
let isXKey = false;

@@ -522,3 +522,3 @@

return {
version: version,
version: opts?.version || version,
pubKeyHash: rawAddr,

@@ -532,3 +532,3 @@ check: addr.slice(-8),

return {
version: version,
version: opts?.version || version,
xprv: rawAddr,

@@ -539,3 +539,3 @@ check: addr.slice(-8),

return {
version: version,
version: opts?.version || version,
xpub: rawAddr,

@@ -547,3 +547,3 @@ check: addr.slice(-8),

return {
version: version,
version: opts?.version || version,
privateKey: rawAddr.slice(0, 64),

@@ -974,4 +974,4 @@ compressed: true, // "01" === rawAddr.slice(64),

/** @type {AddressToPubKeyHash} */
_DashKeys.addrToPkh = async function (address) {
let addrParts = await _DashKeys.decode(address);
_DashKeys.addrToPkh = async function (address, opts) {
let addrParts = await _DashKeys.decode(address, opts);
let shaRipeBytes = Utils.hexToBytes(addrParts.pubKeyHash);

@@ -984,3 +984,68 @@

_DashKeys.decode = async function (keyB58c, opts) {
let parts = await dash58check.decode(keyB58c);
console.log("################ found it!");
let _opts = {};
if (opts?.version) {
switch (opts.version) {
case XPRV:
/* fallsthrough */
case "xprv":
/* fallsthrough */
case 0x0488ade4:
/* fallsthrough */
case XPUB:
/* fallsthrough */
case "xpub":
/* fallsthrough */
case 0x0488b21e:
/* fallsthrough */
case DASH_PRIV_KEY:
/* fallsthrough */
case 0xcc:
/* fallsthrough */
case DASH_PKH:
/* fallsthrough */
case 0x4c:
/* fallsthrough */
case "mainnet":
Object.assign(_opts, {
versions: [DASH_PKH, DASH_PRIV_KEY],
xversions: [XPRV, XPUB],
});
break;
case TPRV:
/* fallsthrough */
case "tprv":
/* fallsthrough */
case 0x04358394:
/* fallsthrough */
case TPUB:
/* fallsthrough */
case "tpub":
/* fallsthrough */
case 0x043587cf:
/* fallsthrough */
case DASH_PRIV_KEY_TESTNET:
/* fallsthrough */
case 0xef:
/* fallsthrough */
case DASH_PKH_TESTNET:
/* fallsthrough */
case 0x8c:
/* fallsthrough */
case "testnet":
Object.assign(_opts, {
versions: [DASH_PKH_TESTNET, DASH_PRIV_KEY_TESTNET],
xversions: [TPRV, TPUB],
});
break;
default:
throw new Error(`unknown version ${opts.version}`);
}
}
if (opts.versions) {
Object.assign(_opts, opts);
}
let parts = await dash58check.decode(keyB58c, _opts);
let check = await dash58check.checksum(parts);

@@ -991,3 +1056,3 @@ let valid = parts.check === check;

// to throw the inner error
await dash58check.verify(keyB58c);
await dash58check.verify(keyB58c, _opts);
}

@@ -1206,4 +1271,5 @@ }

/** @type {WifToAddress} */
_DashKeys.wifToAddr = async function (wif) {
_DashKeys.wifToAddr = async function (wif, opts) {
let privBytes = await _DashKeys.wifToPrivKey(wif);
let version = opts?.version;

@@ -1216,2 +1282,3 @@ let pubBytes = await Utils.toPublicKey(privBytes);

pubKeyHash: pubKeyHashHex,
version: version,
});

@@ -1277,2 +1344,4 @@ return addr;

* @prop {Boolean} validate - throw if check fails, true by default
* @prop {Array<VERSION|Number>} [versions]
* @prop {VERSION|Number} [version]
*/

@@ -1279,0 +1348,0 @@

2

package.json
{
"name": "dashkeys",
"version": "1.1.0",
"version": "1.1.1",
"description": "Generate, validate, create, and convert WIFs and PayAddress.",

@@ -5,0 +5,0 @@ "main": "dashkeys.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc