PHP WebShell
Текущая директория: /usr/lib/node_modules/bitgo/node_modules/@celo/utils/lib
Просмотр файла: address.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isValidAddress = exports.isValidPrivateKey = exports.publicKeyToAddress = exports.privateKeyToPublicKey = exports.privateKeyToAddress = exports.toChecksumAddress = exports.isValidChecksumAddress = exports.trimLeading0x = exports.NULL_ADDRESS = exports.normalizeAddressWith0x = exports.normalizeAddress = exports.mapAddressListOnto = exports.mapAddressListDataOnto = exports.isHexString = exports.hexToBuffer = exports.getAddressChunks = exports.findAddressIndex = exports.eqAddress = exports.ensureLeading0x = exports.bufferToHex = void 0;
var address_1 = require("@celo/base/lib/address");
var ethereumjs_util_1 = require("ethereumjs-util");
// Exports moved to @celo/base, forwarding them
// here for backwards compatibility
var address_2 = require("@celo/base/lib/address");
Object.defineProperty(exports, "bufferToHex", { enumerable: true, get: function () { return address_2.bufferToHex; } });
Object.defineProperty(exports, "ensureLeading0x", { enumerable: true, get: function () { return address_2.ensureLeading0x; } });
Object.defineProperty(exports, "eqAddress", { enumerable: true, get: function () { return address_2.eqAddress; } });
Object.defineProperty(exports, "findAddressIndex", { enumerable: true, get: function () { return address_2.findAddressIndex; } });
Object.defineProperty(exports, "getAddressChunks", { enumerable: true, get: function () { return address_2.getAddressChunks; } });
Object.defineProperty(exports, "hexToBuffer", { enumerable: true, get: function () { return address_2.hexToBuffer; } });
Object.defineProperty(exports, "isHexString", { enumerable: true, get: function () { return address_2.isHexString; } });
Object.defineProperty(exports, "mapAddressListDataOnto", { enumerable: true, get: function () { return address_2.mapAddressListDataOnto; } });
Object.defineProperty(exports, "mapAddressListOnto", { enumerable: true, get: function () { return address_2.mapAddressListOnto; } });
Object.defineProperty(exports, "normalizeAddress", { enumerable: true, get: function () { return address_2.normalizeAddress; } });
Object.defineProperty(exports, "normalizeAddressWith0x", { enumerable: true, get: function () { return address_2.normalizeAddressWith0x; } });
Object.defineProperty(exports, "NULL_ADDRESS", { enumerable: true, get: function () { return address_2.NULL_ADDRESS; } });
Object.defineProperty(exports, "trimLeading0x", { enumerable: true, get: function () { return address_2.trimLeading0x; } });
var ethereumjs_util_2 = require("ethereumjs-util");
Object.defineProperty(exports, "isValidChecksumAddress", { enumerable: true, get: function () { return ethereumjs_util_2.isValidChecksumAddress; } });
Object.defineProperty(exports, "toChecksumAddress", { enumerable: true, get: function () { return ethereumjs_util_2.toChecksumAddress; } });
var privateKeyToAddress = function (privateKey) {
return (0, ethereumjs_util_1.toChecksumAddress)((0, address_1.ensureLeading0x)((0, ethereumjs_util_1.privateToAddress)((0, address_1.hexToBuffer)(privateKey)).toString('hex')));
};
exports.privateKeyToAddress = privateKeyToAddress;
var privateKeyToPublicKey = function (privateKey) {
return (0, ethereumjs_util_1.toChecksumAddress)((0, address_1.ensureLeading0x)((0, ethereumjs_util_1.privateToPublic)((0, address_1.hexToBuffer)(privateKey)).toString('hex')));
};
exports.privateKeyToPublicKey = privateKeyToPublicKey;
var publicKeyToAddress = function (publicKey) {
return (0, ethereumjs_util_1.toChecksumAddress)((0, address_1.ensureLeading0x)((0, ethereumjs_util_1.pubToAddress)((0, ethereumjs_util_1.toBuffer)((0, address_1.ensureLeading0x)(publicKey)), true).toString('hex')));
};
exports.publicKeyToAddress = publicKeyToAddress;
var isValidPrivateKey = function (privateKey) {
return privateKey.startsWith('0x') && (0, ethereumjs_util_1.isValidPrivate)((0, address_1.hexToBuffer)(privateKey));
};
exports.isValidPrivateKey = isValidPrivateKey;
var isValidAddress = function (input) {
if ('string' !== typeof input) {
return false;
}
if (!/^(0x)?[0-9a-f]{40}$/i.test(input)) {
return false;
}
if (/^(0x|0X)?[0-9A-F]{40}$/.test(input.toUpperCase())) {
return true;
}
if ((0, ethereumjs_util_1.toChecksumAddress)(input) === input) {
return true;
}
return false;
};
exports.isValidAddress = isValidAddress;
//# sourceMappingURL=address.js.mapВыполнить команду
Для локальной разработки. Не используйте в интернете!