UNPKG

etkframework

Version:

First test release of Etk over colored coins SDK

50 lines (43 loc) 2 kB
/** * Etk Helper library. * Utility functions to decode Base58 pvt key string to hex string * and vice versa. * * Copyright (C) 2015 Akul Mathur This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. Parts of the software are provided under separate licenses, as follows: "colu-nodejs" SDK is under the MIT License "pbkdf2-sha256" is under the BSD License "bip38" is under the MIT License "scryptsy" is under the MIT License "coinstring" is under the MIT License * Core Developer(s): @codecakesakurnya Akul Mathur * Maintainer(s): * @codecakes Akul Mathur * Description: * Utility functions to decode Base58 pvt key string to hex string * and vice versa. * */ "use strict"; const cs = require("coinstring"), pvtKeyWIFDecode = function pvtKeyWIFDecode(pvtKeyBase58, version) { //Decode the pvtKeyBase58 address or wallet import format into a Buffer of bytes to Hex String. return cs.decode(pvtKeyBase58, version || 0x80).toString('hex'); }, pvtKeyWIFEncode = function pvtKeyWIFEncode(privateKeyHex, version) { //Encode Private KeyHex to Buffered to BIP38 Base58 check enoded Bitcoin Wallet Import Format return cs.encode(new Buffer(privateKeyHex, 'hex'), version || 0x80); }; exports.pvtKeyWIFDecode = pvtKeyWIFDecode; exports.pvtKeyWIFEncode = pvtKeyWIFEncode;