remove PeerManager exception, no necesary anymore
This commit is contained in:
parent
e2c775e17f
commit
5be37f2c7b
2
Key.js
2
Key.js
|
@ -50,6 +50,8 @@ if (process.versions) {
|
|||
};
|
||||
|
||||
kSpec.prototype.regenerateSync = function() {
|
||||
|
||||
console.log('[Key.js.53]', this); //TODO
|
||||
if (!this.private) {
|
||||
throw new Error('Key does not have a private key set');
|
||||
}
|
||||
|
|
|
@ -21,7 +21,9 @@ WalletKey.prototype.generate = function() {
|
|||
|
||||
WalletKey.prototype.storeObj = function() {
|
||||
var pubKey = this.privKey.public.toString('hex');
|
||||
console.log('[WalletKey.js.23:pubKey:]',pubKey); //TODO
|
||||
var pubKeyHash = coinUtil.sha256ripe160(this.privKey.public);
|
||||
console.log('[WalletKey.js.25:pubKeyHash:]',pubKeyHash); //TODO
|
||||
var addr = new Address(this.network.addressPubkey, pubKeyHash);
|
||||
var priv = new PrivateKey(this.network.keySecret, this.privKey.private, this.privKey.compressed);
|
||||
var obj = {
|
||||
|
|
|
@ -37,14 +37,11 @@ requireWhenAccessed('PrivateKey', './PrivateKey');
|
|||
requireWhenAccessed('RpcClient', './RpcClient');
|
||||
requireWhenAccessed('Wallet', './Wallet');
|
||||
requireWhenAccessed('WalletKey', './WalletKey');
|
||||
requireWhenAccessed('PeerManager', './PeerManager');
|
||||
module.exports.Buffer = Buffer;
|
||||
|
||||
if (typeof process.versions === 'undefined') {
|
||||
// Browser specific
|
||||
module.exports.bignum.config({EXPONENTIAL_AT: 9999999, DECIMAL_PLACES: 0, ROUNDING_MODE: 1});
|
||||
}
|
||||
else {
|
||||
// Nodejs specific
|
||||
requireWhenAccessed('PeerManager', './PeerManager');
|
||||
}
|
||||
|
||||
|
|
|
@ -40,32 +40,34 @@
|
|||
});
|
||||
print('<hr>');
|
||||
|
||||
var Key = require('KeyModule').Key;
|
||||
var buffertools = require('buffertools');
|
||||
var k = Key.generateSync();
|
||||
|
||||
print ('Generate Key Pair:');
|
||||
print ('Private:' + buffertools.toHex(k.private));
|
||||
print ('Public:' + buffertools.toHex(k.public));
|
||||
|
||||
print('<hr>');
|
||||
/*
|
||||
Using bitcore root module
|
||||
*/
|
||||
|
||||
var bitcore = require('bitcore');
|
||||
var k = bitcore.KeyModule.Key.generateSync();
|
||||
|
||||
print ('Generate Key Pair:');
|
||||
print ('Private:' + buffertools.toHex(k.private));
|
||||
print ('Public:' + buffertools.toHex(k.public));
|
||||
print ('Private:' + bitcore.buffertools.toHex(k.private));
|
||||
print ('Public:' + bitcore.buffertools.toHex(k.public));
|
||||
|
||||
print('<hr>');
|
||||
|
||||
console.log('[example.html.65:PeerManager:]'); //TODO
|
||||
var p = new bitcore.PeerManager();
|
||||
|
||||
var pm = require('PeerManager');
|
||||
print('<hr>');
|
||||
|
||||
var WalletKey = bitcore.WalletKey;
|
||||
var networks = bitcore.networks;
|
||||
|
||||
var priv = 'cU5NxfpfecLCUWnJyoUF6dCZqCfLSAZnTBPraCPis2if8iHHbNk1';
|
||||
var s = new WalletKey({
|
||||
network: networks.testnet
|
||||
});
|
||||
s.fromObj({ priv: priv});
|
||||
var o = s.storeObj();
|
||||
print("Private: " + o.priv);
|
||||
print("Public: " + o.pub);
|
||||
print("Addr: " + o.addr);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -75,9 +75,9 @@ describe('WalletKey', function() {
|
|||
s.fromObj({ priv: priv});
|
||||
s.privKey.compressed.should.equal(false);
|
||||
var o = s.storeObj();
|
||||
o.priv.should.equal(priv);
|
||||
o.pub.should.equal('04470bbc100896e4df317526efa22f15aac3681ef02d230d00d15b4cba8eea1e88477523d644f20edb6b344f06bba77a9dff81be69d74282866b0b7f3e9d0d910b');
|
||||
o.addr.should.equal('1v5GwPNomikEqmMe7h6q1jRw62WKTD6Xo');
|
||||
o.priv.should.equal(priv);
|
||||
});
|
||||
|
||||
|
||||
|
@ -94,7 +94,6 @@ describe('WalletKey', function() {
|
|||
o.priv.should.equal(priv);
|
||||
o.pub.should.equal('03d95e184cce34c3cfa58e9a277a09a7c5ed1b2a8134ea1e52887bc66fa3f47071');
|
||||
o.addr.should.equal('1JEgFNDmEUdd6FvNhDBqSuw2uZ4yisSr7A');
|
||||
o.priv.should.equal(priv);
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue