package
JavaScript component for private keys, public keys, and addresess for crypto currencies such as Bitcoin, Litecoin, and Dogecoin
npm install coinkeyGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
JavaScript component for private keys, public keys, and addresses for crypto currencies such as Bitcoin, Litecoin, and Dogecoin. Works in both Node.js and the browser.
npm i --save coinkeyvar CoinKey = require('coinkey')
var bitcoinKeys = []
for (var i = 0; i < 10; ++i) {
// bitcoin supported by default
bitcoinKeys.push(CoinKey.createRandom())
}var CoinKey = require('coinkey')
// npm install --save coininfo
var ci = require('coininfo')
var namecoins = []
for (var i = 0; i < 10; ++i) {
namecoins.push(CoinKey.createRandom(ci('NMC')))
}var CoinKey = require('coinkey')
var ci = require('coininfo')
var ck = CoinKey.fromWif('QVD3x1RPiWPvyxbTsfxVwaYLyeBZrQvjhZ2aZJUsbuRgsEAGpNQ2')
console.log(ck.privateKey.toString('hex')) // => c4bbcb1fbec99d65bf59d85c8cb62ee2db963f0fe106f483d9afa73bd4e39a8a
console.log(ck.publicAddress) // => DGG6AicS4Qg8Y3UFtcuwJqbuRZ3Q7WtYXv
console.log(ck.compressed) // => true
console.log(ck.versions.public === ci('DOGE').versions.public) // => truevar CoinKey = require('coinkey')
var ci = require('coininfo')
var ck = new CoinKey(new Buffer('1184cd2cdd640ca42cfc3a091c51d549b2f016d454b2774019c2b2d2e08529fd', 'hex'))
console.log(ck.publicAddress) // => 16UjcYNBG9GTK4uq2f7yYEbuifqCzoLMGS
//change to Testnet
ck.versions = ci('BTC-TEST')
console.log(ck.publicAddress) // => mkzgubTA5Ahi6BPSkE6MN9pEafRutznkMeConstructor function.
Array, Uint8Array, or a Buffer.mainnet.Keys are default set to compressed is true.
var CoinKey = require('coinkey')
//npm install --save secure-random@1.x
var secureRandom = require('secure-random')
var bytes = secureRandom.randomBuffer(32)
var key1 = new CoinKey(bytes)
console.log(key1.compressed) // => trueInherited from ECKey. eckey.compressed
Inherited from ECKey. eckey.privateKey
Inherited from ECKey. eckey.privateExportKey
Get the private WIF (Wallet Import Format).
var CoinKey = require('coinkey')
var privateKeyHex = "1184cd2cdd640ca42cfc3a091c51d549b2f016d454b2774019c2b2d2e08529fd"
//Bitcoin WIF
var key = new CoinKey(new Buffer(privateKeyHex, 'hex'))
key.compressed = false
console.log(key.privateWif) // => 5Hx15HFGyep2CfPxsJKe2fXJsCVn5DEiyoeGGF6JZjGbTRnqfiD
//Litecoin WIF
var key = new CoinKey(new Buffer(privateKeyHex, 'hex'), {private: 0xB0, public: 0x30})
key.compressed = false
console.log(key.privateWif) // => 6uFjYQnot5Gtg3HpP87bp4JUpg4FH1gkkV3RyS7LHBbD9Hpt1naInherited from ECKey. eckey.publicKey
Get the public address.
var CoinKey = require('coinkey')
var privateKeyHex = "1184cd2cdd640ca42cfc3a091c51d549b2f016d454b2774019c2b2d2e08529fd"
// Bitcoin Address
var key = new CoinKey(new Buffer(privatKeyHex, 'hex'))
console.log(key.publicAddress) // => 16UjcYNBG9GTK4uq2f7yYEbuifqCzoLMGS
// Litecoin Address
var key = new CoinKey(new Buffer(privateKeyHex, 'hex'), {private: 0xB0, public: 0x30})
console.log(key.publicAddress) // => 'LZyGd5dCPVkVUjA5QbpuUfMNgcmNDLjswH'Alias: pubKeyHash
Inherited from ECKey. eckey.publicHash
Inherited from ECKey. eckey.publicPoint
Returns the string representation.
var CoinKey = require('coinkey')
var privateKeyHex = "1184cd2cdd640ca42cfc3a091c51d549b2f016d454b2774019c2b2d2e08529fd"
//Litecoin Address
var key = new CoinKey(new Buffer(privateKeyHex, 'hex'), {private: 0xB0, public: 0x30})
console.log(key.toString())
// => T3e2me1BvRs95K7E8eQ8eha9oRPL1g2U6vmjE5px6RjzbUTvKZsf: LZyGd5dCPVkVUjA5QbpuUfMNgcmNDLjswHClass method to create a CoinKey from a wif.
var ck = CoinKey.fromWif('KwomKti1X3tYJUUMb1TGSM2mrZk1wb1aHisUNHCQXTZq5auC2qc3');
console.log(ck.compressed) // => true
console.log(ck.privateKey.toString('hex')) // => 1184cd2cdd640ca42cfc3a091c51d549b2f016d454b2774019c2b2d2e08529fd
console.log(ck.publicAddress) // => 1FkKMsKNJqWSDvTvETqcCeHcUQQ64kSC6sClone the repo:
git clone https://github.com/cryptocoinjs/coinkeyInstall Browserify
npm install -g browserifyNav to repo:
cd coinkeyInstall dependencies:
npm installRun browserify:
browserify --standalone coinkey lib/coinkey.js > lib/coinkey.bundle.jsYou can now drop coinkey.bundle.js in a <script> tag.
midnightlightning
brooks@midnight.design
Estimated unpacked size across 16 packages.
2.5 MB
Includes dependencies.
4 direct dependencies.