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

c32check

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

c32check - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

.nyc_output/0765215622bc74a75296469e91fa6cee.json

99

lib/address.js

@@ -9,5 +9,13 @@ 'use strict';

exports.c32addressDecode = c32addressDecode;
exports.b58ToC32 = b58ToC32;
exports.c32ToB58 = c32ToB58;
var _checksum = require('./checksum');
var _base58check = require('base58check');
var _base58check2 = _interopRequireDefault(_base58check);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var versions = exports.versions = {

@@ -23,11 +31,24 @@ mainnet: {

/**
* Make a c32check address with the given version and hash160
* The only difference between a c32check string and c32 address
* is that the letter 'S' is pre-pended.
* @param {number} version - the address version number
* @param {string} hash160hex - the hash160 to encode (must be a hash160)
* @returns {string} the address
*/
};
// address conversion : bitcoin to stacks
};var ADDR_BITCOIN_TO_STACKS = {};
ADDR_BITCOIN_TO_STACKS[0] = versions.mainnet.p2pkh;
ADDR_BITCOIN_TO_STACKS[5] = versions.mainnet.p2sh;
ADDR_BITCOIN_TO_STACKS[111] = versions.testnet.p2pkh;
ADDR_BITCOIN_TO_STACKS[196] = versions.testnet.p2sh;
// address conversion : stacks to bitcoin
var ADDR_STACKS_TO_BITCOIN = {};
ADDR_STACKS_TO_BITCOIN[versions.mainnet.p2pkh] = 0;
ADDR_STACKS_TO_BITCOIN[versions.mainnet.p2sh] = 5;
ADDR_STACKS_TO_BITCOIN[versions.testnet.p2pkh] = 111;
ADDR_STACKS_TO_BITCOIN[versions.testnet.p2sh] = 196;
/**
* Make a c32check address with the given version and hash160
* The only difference between a c32check string and c32 address
* is that the letter 'S' is pre-pended.
* @param {number} version - the address version number
* @param {string} hash160hex - the hash160 to encode (must be a hash160)
* @returns {string} the address
*/
function c32address(version, hash160hex) {

@@ -52,2 +73,62 @@ if (!hash160hex.match(/^[0-9a-fA-F]{40}$/)) {

return (0, _checksum.c32checkDecode)(c32addr.slice(1));
}
/*
* Convert a base58check address to a c32check address.
* Try to convert the version number if one is not given.
* @param {string} b58check - the base58check encoded address
* @param {number} version - the version number, if not inferred from the address
* @returns {string} the c32 address with the given version number (or the
* semantically-equivalent c32 version number, if not given)
*/
function b58ToC32(b58check) {
var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
var addrInfo = _base58check2.default.decode(b58check);
var hash160String = addrInfo.data.toString('hex');
var addrVersion = parseInt(addrInfo.prefix.toString('hex'), 16);
var stacksVersion = void 0;
if (version < 0) {
stacksVersion = addrVersion;
if (ADDR_BITCOIN_TO_STACKS[addrVersion] !== undefined) {
stacksVersion = ADDR_BITCOIN_TO_STACKS[addrVersion];
}
} else {
stacksVersion = version;
}
return c32address(stacksVersion, hash160String);
}
/*
* Convert a c32check address to a base58check address.
* @param {string} c32string - the c32check address
* @param {number} version - the version number, if not inferred from the address
* @returns {string} the base58 address with the given version number (or the
* semantically-equivalent bitcoin version number, if not given)
*/
function c32ToB58(c32string) {
var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
var addrInfo = c32addressDecode(c32string);
var stacksVersion = addrInfo[0];
var hash160String = addrInfo[1];
var bitcoinVersion = void 0;
if (version < 0) {
bitcoinVersion = stacksVersion;
if (ADDR_STACKS_TO_BITCOIN[stacksVersion] !== undefined) {
bitcoinVersion = ADDR_STACKS_TO_BITCOIN[stacksVersion];
}
} else {
bitcoinVersion = version;
}
var prefix = bitcoinVersion.toString(16);
if (prefix.length === 1) {
prefix = '0' + prefix;
}
return _base58check2.default.encode(hash160String, prefix);
}

6

lib/index.js

@@ -6,3 +6,3 @@ 'use strict';

});
exports.versions = exports.c32normalize = exports.c32addressDecode = exports.c32address = exports.c32checkDecode = exports.c32checkEncode = exports.c32decode = exports.c32encode = undefined;
exports.b58ToC32 = exports.c32ToB58 = exports.versions = exports.c32normalize = exports.c32addressDecode = exports.c32address = exports.c32checkDecode = exports.c32checkEncode = exports.c32decode = exports.c32encode = undefined;

@@ -22,2 +22,4 @@ var _encoding = require('./encoding');

exports.c32normalize = _encoding.c32normalize;
exports.versions = _address.versions;
exports.versions = _address.versions;
exports.c32ToB58 = _address.c32ToB58;
exports.b58ToC32 = _address.b58ToC32;
{
"name": "c32check",
"version": "0.0.5",
"version": "0.0.6",
"description": "Crockford base-32 checksum encoding",

@@ -79,2 +79,3 @@ "main": "lib/index",

"dependencies": {
"base58check": "^2.0.0",
"ripemd160": "^2.0.1"

@@ -81,0 +82,0 @@ },

@@ -49,3 +49,5 @@ # c32check

{ mainnet: { p2pkh: 22, p2sh: 20 },
testnet: { p2pkh: 26, p2sh: 21 } } }
testnet: { p2pkh: 26, p2sh: 21 } },
c32ToB58: [Function: c32ToB58],
b58ToC32: [Function: b58ToC32] }
```

@@ -91,1 +93,23 @@

```
## c32ToB58, b58ToC32
**NOTE**: Common address versions are converted between c32check
and base58check seamlessly, in order to accomodate Stacks addresses.
```
> b58addr = '16EMaNw3pkn3v6f2BgnSSs53zAKH4Q8YJg'
'16EMaNw3pkn3v6f2BgnSSs53zAKH4Q8YJg'
> c32check.b58ToC32(b58addr)
'SPWNYDJ3STG7XH7ERWXMV6MQ7Q6EATWVY5Q1QMP8'
> c32check.c32ToB58('SPWNYDJ3STG7XH7ERWXMV6MQ7Q6EATWVY5Q1QMP8')
'16EMaNw3pkn3v6f2BgnSSs53zAKH4Q8YJg'
```
```
> b58addr = '3D2oetdNuZUqQHPJmcMDDHYoqkyNVsFk9r'
'3D2oetdNuZUqQHPJmcMDDHYoqkyNVsFk9r'
> c32check.b58ToC32(b58addr)
'SM1Y6EXF21RZ9739DFTEQKB1H044BMM0XVCM4A4NY'
> c32check.c32ToB58('SM1Y6EXF21RZ9739DFTEQKB1H044BMM0XVCM4A4NY')
3D2oetdNuZUqQHPJmcMDDHYoqkyNVsFk9r'
```

@@ -10,2 +10,3 @@ 'use strict';

exports.c32addressTests = c32addressTests;
exports.c32ToB58Test = c32ToB58Test;

@@ -262,2 +263,42 @@ var _tape = require('tape-promise/tape');

function c32ToB58Test() {
var hexStrings = ['a46ff88886c2ef9762d970b4d2c63678835bd39d', '0000000000000000000000000000000000000000', '0000000000000000000000000000000000000001', '1000000000000000000000000000000000000001', '1000000000000000000000000000000000000000'];
var versions = [22, 0, 31, 20, 26, 21];
var c32addresses = [['SP2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKNRV9EJ7', 'SP000000000000000000002Q6VF78', 'SP00000000000000000005JA84HQ', 'SP80000000000000000000000000000004R0CMNV', 'SP800000000000000000000000000000033H8YKK'], ['S02J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKPVKG2CE', 'S0000000000000000000002AA028H', 'S000000000000000000006EKBDDS', 'S080000000000000000000000000000007R1QC00', 'S080000000000000000000000000000003ENTGCQ'], ['SZ2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKQ9H6DPR', 'SZ000000000000000000002ZE1VMN', 'SZ00000000000000000005HZ3DVN', 'SZ80000000000000000000000000000004XBV6MS', 'SZ800000000000000000000000000000007VF5G0'], ['SM2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKQVX8X0G', 'SM0000000000000000000062QV6X', 'SM00000000000000000005VR75B2', 'SM80000000000000000000000000000004WBEWKC', 'SM80000000000000000000000000000000JGSYGV'], ['ST2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKQYAC0RQ', 'ST000000000000000000002AMW42H', 'ST000000000000000000042DB08Y', 'ST80000000000000000000000000000006BYJ4R4', 'ST80000000000000000000000000000002YBNPV3'], ['SN2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKP6D2ZK9', 'SN000000000000000000003YDHWKJ', 'SN00000000000000000005341MC8', 'SN800000000000000000000000000000066KZWY0', 'SN800000000000000000000000000000006H75AK']];
var b58addresses = [['A7RjcihhakxJfAqgwTVsLTyc8kbhDJPMVY', '9rSGfPZLcyCGzY4uYEL1fkzJr6fkicS2rs', '9rSGfPZLcyCGzY4uYEL1fkzJr6fkoGa2eS', '9stsUTaRHnyTRFWnbwiyCWwfpkkKCFYBD4', '9stsUTaRHnyTRFWnbwiyCWwfpkkK9ZxEPC'], ['1FzTxL9Mxnm2fdmnQEArfhzJHevwbvcH6d', '1111111111111111111114oLvT2', '11111111111111111111BZbvjr', '12Tbp525fpnBRiSt4iPxXkxMyf5Ze1UeZu', '12Tbp525fpnBRiSt4iPxXkxMyf5ZWzA5TC'], ['DjUAUhPHyP8C256UAEVjhbRgoHvBetzPRR', 'DUUhXNEw1bNAMSKgm1Kt2tSPWdzF8952Np', 'DUUhXNEw1bNAMSKgm1Kt2tSPWdzFCMncsE', 'DVwJLSG1gR9Ln9mZpiiqZePkVJ4obdg7UC', 'DVwJLSG1gR9Ln9mZpiiqZePkVJ4oTzMnyD'], ['9JkXeW78AQ2Z2JZWtcqENDS2sk5orG4ggw', '93m4hAxmCcGXMfnjVPfNhWSjb69sDziGSY', '93m4hAxmCcGXMfnjVPfNhWSjb69sPHPDTX', '95DfWEyqsS3hnPEcZ74LEGQ6ZkERn1FuUo', '95DfWEyqsS3hnPEcZ74LEGQ6ZkERexa3xe'], ['Bin9Z9trRUoovuQ338q9Gy4kemdU7ni2FG', 'BTngbpkVTh3nGGdFdufHcG5TN7hXYuX31z', 'BTngbpkVTh3nGGdFdufHcG5TN7hXbks9tq', 'BVFHQtma8Wpxgz58hd4F922pLmn65qtPy5', 'BVFHQtma8Wpxgz58hd4F922pLmn5zEwasC'], ['9i68dcQQsaVRqjhbv3AYrLhpWFLkWkzrCG', '9T6fgHG3unjQB6vpWozhBdiXDbQp3P7F8M', '9T6fgHG3unjQB6vpWozhBdiXDbQp5FwEH5', '9UZGVMH8acWabpNhaXPeiPftCFVNXQAYoZ', '9UZGVMH8acWabpNhaXPeiPftCFVNMacQDQ']];
var equivalentVersions = [22, 20, 26, 21];
var c32addressesEquivalentVersion = [['SP2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKNRV9EJ7', 'SP000000000000000000002Q6VF78', 'SP00000000000000000005JA84HQ', 'SP80000000000000000000000000000004R0CMNV', 'SP800000000000000000000000000000033H8YKK'], ['SM2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKQVX8X0G', 'SM0000000000000000000062QV6X', 'SM00000000000000000005VR75B2', 'SM80000000000000000000000000000004WBEWKC', 'SM80000000000000000000000000000000JGSYGV'], ['ST2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKQYAC0RQ', 'ST000000000000000000002AMW42H', 'ST000000000000000000042DB08Y', 'ST80000000000000000000000000000006BYJ4R4', 'ST80000000000000000000000000000002YBNPV3'], ['SN2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKP6D2ZK9', 'SN000000000000000000003YDHWKJ', 'SN00000000000000000005341MC8', 'SN800000000000000000000000000000066KZWY0', 'SN800000000000000000000000000000006H75AK']];
var b58addressesEquivalentVersion = [['1FzTxL9Mxnm2fdmnQEArfhzJHevwbvcH6d', '1111111111111111111114oLvT2', '11111111111111111111BZbvjr', '12Tbp525fpnBRiSt4iPxXkxMyf5Ze1UeZu', '12Tbp525fpnBRiSt4iPxXkxMyf5ZWzA5TC'], ['3GgUssdoWh5QkoUDXKqT6LMESBDf8aqp2y', '31h1vYVSYuKP6AhS86fbRdMw9XHieotbST', '31h1vYVSYuKP6AhS86fbRdMw9XHiiQ93Mb', '339cjcWXDj6ZWt9KBp4YxPKJ8BNH7gn2Nw', '339cjcWXDj6ZWt9KBp4YxPKJ8BNH14Nnx4'], ['mvWRFPELmpCHSkFQ7o9EVdCd9eXeUTa9T8', 'mfWxJ45yp2SFn7UciZyNpvDKrzbhyfKrY8', 'mfWxJ45yp2SFn7UciZyNpvDKrzbi36LaVX', 'mgyZ7874UrDSCpvVnHNLMgAgqegGZBks3w', 'mgyZ7874UrDSCpvVnHNLMgAgqegGQUXx9c'], ['2N8EgwcZq89akxb6mCTTKiHLVeXRpxjuy98', '2MsFDzHRUAMpjHxKyoEHU3aMCMsVtMqs1PV', '2MsFDzHRUAMpjHxKyoEHU3aMCMsVtXMsfu8', '2MthpoMSYqBbuifmrrwgRaLJZLXaSyK2Rai', '2MthpoMSYqBbuifmrrwgRaLJZLXaSoxBM5T']];
(0, _tape2.default)('c32ToB58 and b58ToC32', function (t) {
t.plan(hexStrings.length * versions.length * 2);
for (var i = 0; i < hexStrings.length; i++) {
for (var j = 0; j < versions.length; j++) {
var b58 = (0, _index.c32ToB58)(c32addresses[j][i], versions[j]);
var c32 = (0, _index.b58ToC32)(b58addresses[j][i], versions[j]);
t.equal(b58, b58addresses[j][i], 'c32ToB58: expect ' + b58addresses[j][i] + ', got ' + b58);
t.equal(c32, c32addresses[j][i], 'b58ToC32: expect ' + c32addresses[j][i] + ', got ' + c32);
}
}
});
(0, _tape2.default)('c32ToB58 and b58ToC32 equivalent versions', function (t) {
t.plan(hexStrings.length * equivalentVersions.length * 2);
for (var i = 0; i < hexStrings.length; i++) {
for (var j = 0; j < equivalentVersions.length; j++) {
var b58 = (0, _index.c32ToB58)(c32addressesEquivalentVersion[j][i]);
var c32 = (0, _index.b58ToC32)(b58addressesEquivalentVersion[j][i]);
t.equal(b58, b58addressesEquivalentVersion[j][i], 'c32ToB58: expect ' + b58addressesEquivalentVersion[j][i] + ', got ' + b58);
t.equal(c32, c32addressesEquivalentVersion[j][i], 'b58ToC32: expect ' + c32addressesEquivalentVersion[j][i] + ', got ' + c32);
}
}
});
}
if (_process2.default.env.BIG_DATA_TESTS) {

@@ -269,2 +310,3 @@ c32encodingRandomBytes();

c32addressTests();
c32ToB58Test();
}

@@ -9,3 +9,5 @@ import test from 'tape-promise/tape'

c32address,
c32addressDecode
c32addressDecode,
c32ToB58,
b58ToC32
} from '../../../lib/index.js'

@@ -581,2 +583,208 @@

export function c32ToB58Test() {
const hexStrings = [
'a46ff88886c2ef9762d970b4d2c63678835bd39d',
'0000000000000000000000000000000000000000',
'0000000000000000000000000000000000000001',
'1000000000000000000000000000000000000001',
'1000000000000000000000000000000000000000'
]
const versions = [
22,
0,
31,
20,
26,
21
]
const c32addresses = [
[
'SP2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKNRV9EJ7',
'SP000000000000000000002Q6VF78',
'SP00000000000000000005JA84HQ',
'SP80000000000000000000000000000004R0CMNV',
'SP800000000000000000000000000000033H8YKK'
],
[
'S02J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKPVKG2CE',
'S0000000000000000000002AA028H',
'S000000000000000000006EKBDDS',
'S080000000000000000000000000000007R1QC00',
'S080000000000000000000000000000003ENTGCQ'
],
[
'SZ2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKQ9H6DPR',
'SZ000000000000000000002ZE1VMN',
'SZ00000000000000000005HZ3DVN',
'SZ80000000000000000000000000000004XBV6MS',
'SZ800000000000000000000000000000007VF5G0'
],
[
'SM2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKQVX8X0G',
'SM0000000000000000000062QV6X',
'SM00000000000000000005VR75B2',
'SM80000000000000000000000000000004WBEWKC',
'SM80000000000000000000000000000000JGSYGV'
],
[
'ST2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKQYAC0RQ',
'ST000000000000000000002AMW42H',
'ST000000000000000000042DB08Y',
'ST80000000000000000000000000000006BYJ4R4',
'ST80000000000000000000000000000002YBNPV3'
],
[
'SN2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKP6D2ZK9',
'SN000000000000000000003YDHWKJ',
'SN00000000000000000005341MC8',
'SN800000000000000000000000000000066KZWY0',
'SN800000000000000000000000000000006H75AK'
]
]
const b58addresses = [
[
'A7RjcihhakxJfAqgwTVsLTyc8kbhDJPMVY',
'9rSGfPZLcyCGzY4uYEL1fkzJr6fkicS2rs',
'9rSGfPZLcyCGzY4uYEL1fkzJr6fkoGa2eS',
'9stsUTaRHnyTRFWnbwiyCWwfpkkKCFYBD4',
'9stsUTaRHnyTRFWnbwiyCWwfpkkK9ZxEPC'
],
[
'1FzTxL9Mxnm2fdmnQEArfhzJHevwbvcH6d',
'1111111111111111111114oLvT2',
'11111111111111111111BZbvjr',
'12Tbp525fpnBRiSt4iPxXkxMyf5Ze1UeZu',
'12Tbp525fpnBRiSt4iPxXkxMyf5ZWzA5TC'
],
[
'DjUAUhPHyP8C256UAEVjhbRgoHvBetzPRR',
'DUUhXNEw1bNAMSKgm1Kt2tSPWdzF8952Np',
'DUUhXNEw1bNAMSKgm1Kt2tSPWdzFCMncsE',
'DVwJLSG1gR9Ln9mZpiiqZePkVJ4obdg7UC',
'DVwJLSG1gR9Ln9mZpiiqZePkVJ4oTzMnyD'
],
[
'9JkXeW78AQ2Z2JZWtcqENDS2sk5orG4ggw',
'93m4hAxmCcGXMfnjVPfNhWSjb69sDziGSY',
'93m4hAxmCcGXMfnjVPfNhWSjb69sPHPDTX',
'95DfWEyqsS3hnPEcZ74LEGQ6ZkERn1FuUo',
'95DfWEyqsS3hnPEcZ74LEGQ6ZkERexa3xe'
],
[
'Bin9Z9trRUoovuQ338q9Gy4kemdU7ni2FG',
'BTngbpkVTh3nGGdFdufHcG5TN7hXYuX31z',
'BTngbpkVTh3nGGdFdufHcG5TN7hXbks9tq',
'BVFHQtma8Wpxgz58hd4F922pLmn65qtPy5',
'BVFHQtma8Wpxgz58hd4F922pLmn5zEwasC'
],
[
'9i68dcQQsaVRqjhbv3AYrLhpWFLkWkzrCG',
'9T6fgHG3unjQB6vpWozhBdiXDbQp3P7F8M',
'9T6fgHG3unjQB6vpWozhBdiXDbQp5FwEH5',
'9UZGVMH8acWabpNhaXPeiPftCFVNXQAYoZ',
'9UZGVMH8acWabpNhaXPeiPftCFVNMacQDQ'
]
]
const equivalentVersions = [
22,
20,
26,
21
]
const c32addressesEquivalentVersion = [
[
'SP2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKNRV9EJ7',
'SP000000000000000000002Q6VF78',
'SP00000000000000000005JA84HQ',
'SP80000000000000000000000000000004R0CMNV',
'SP800000000000000000000000000000033H8YKK'
],
[
'SM2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKQVX8X0G',
'SM0000000000000000000062QV6X',
'SM00000000000000000005VR75B2',
'SM80000000000000000000000000000004WBEWKC',
'SM80000000000000000000000000000000JGSYGV'
],
[
'ST2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKQYAC0RQ',
'ST000000000000000000002AMW42H',
'ST000000000000000000042DB08Y',
'ST80000000000000000000000000000006BYJ4R4',
'ST80000000000000000000000000000002YBNPV3'
],
[
'SN2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKP6D2ZK9',
'SN000000000000000000003YDHWKJ',
'SN00000000000000000005341MC8',
'SN800000000000000000000000000000066KZWY0',
'SN800000000000000000000000000000006H75AK'
]
]
const b58addressesEquivalentVersion = [
[
'1FzTxL9Mxnm2fdmnQEArfhzJHevwbvcH6d',
'1111111111111111111114oLvT2',
'11111111111111111111BZbvjr',
'12Tbp525fpnBRiSt4iPxXkxMyf5Ze1UeZu',
'12Tbp525fpnBRiSt4iPxXkxMyf5ZWzA5TC'
],
[
'3GgUssdoWh5QkoUDXKqT6LMESBDf8aqp2y',
'31h1vYVSYuKP6AhS86fbRdMw9XHieotbST',
'31h1vYVSYuKP6AhS86fbRdMw9XHiiQ93Mb',
'339cjcWXDj6ZWt9KBp4YxPKJ8BNH7gn2Nw',
'339cjcWXDj6ZWt9KBp4YxPKJ8BNH14Nnx4'
],
[
'mvWRFPELmpCHSkFQ7o9EVdCd9eXeUTa9T8',
'mfWxJ45yp2SFn7UciZyNpvDKrzbhyfKrY8',
'mfWxJ45yp2SFn7UciZyNpvDKrzbi36LaVX',
'mgyZ7874UrDSCpvVnHNLMgAgqegGZBks3w',
'mgyZ7874UrDSCpvVnHNLMgAgqegGQUXx9c'
],
[
'2N8EgwcZq89akxb6mCTTKiHLVeXRpxjuy98',
'2MsFDzHRUAMpjHxKyoEHU3aMCMsVtMqs1PV',
'2MsFDzHRUAMpjHxKyoEHU3aMCMsVtXMsfu8',
'2MthpoMSYqBbuifmrrwgRaLJZLXaSyK2Rai',
'2MthpoMSYqBbuifmrrwgRaLJZLXaSoxBM5T'
]
]
test('c32ToB58 and b58ToC32', t => {
t.plan(hexStrings.length * versions.length * 2)
for (let i = 0; i < hexStrings.length; i++) {
for (let j = 0; j < versions.length; j++) {
const b58 = c32ToB58(c32addresses[j][i], versions[j])
const c32 = b58ToC32(b58addresses[j][i], versions[j])
t.equal(b58, b58addresses[j][i], `c32ToB58: expect ${b58addresses[j][i]}, got ${b58}`)
t.equal(c32, c32addresses[j][i], `b58ToC32: expect ${c32addresses[j][i]}, got ${c32}`)
}
}
})
test('c32ToB58 and b58ToC32 equivalent versions', t => {
t.plan(hexStrings.length * equivalentVersions.length * 2)
for (let i = 0; i < hexStrings.length; i++) {
for (let j = 0; j < equivalentVersions.length; j++) {
const b58 = c32ToB58(c32addressesEquivalentVersion[j][i])
const c32 = b58ToC32(b58addressesEquivalentVersion[j][i])
t.equal(b58, b58addressesEquivalentVersion[j][i],
`c32ToB58: expect ${b58addressesEquivalentVersion[j][i]}, got ${b58}`)
t.equal(c32, c32addressesEquivalentVersion[j][i],
`b58ToC32: expect ${c32addressesEquivalentVersion[j][i]}, got ${c32}`)
}
}
})
}
if (process.env.BIG_DATA_TESTS) {

@@ -588,2 +796,3 @@ c32encodingRandomBytes()

c32addressTests()
c32ToB58Test()
}

Sorry, the diff of this file is too big to display

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