Skip to content

Commit

Permalink
remove PeerManager exception, no necesary anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
matiu committed Mar 12, 2014
1 parent e2c775e commit 5be37f2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 20 deletions.
2 changes: 2 additions & 0 deletions Key.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
2 changes: 2 additions & 0 deletions WalletKey.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
5 changes: 1 addition & 4 deletions bitcore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

30 changes: 16 additions & 14 deletions examples/example.html
Original file line number Diff line number Diff line change
Expand Up @@ -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();

print('<hr>');

var pm = require('PeerManager');
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>
3 changes: 1 addition & 2 deletions test/test.WalletKey.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});


Expand All @@ -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);
});


Expand Down

0 comments on commit 5be37f2

Please sign in to comment.