Browse Source

Change PrivateKey.toString from WIF to hex format

patch-2
Yemel Jardi 10 years ago
parent
commit
ff844e9935
  1. 11
      lib/privatekey.js
  2. 3
      lib/publickey.js

11
lib/privatekey.js

@ -283,12 +283,21 @@ PrivateKey.isValid = function(data, network){
return !PrivateKey.getValidationError(data, network); return !PrivateKey.getValidationError(data, network);
}; };
/**
* Will output the PublicKey encoded as hex string
*
* @returns {String}
*/
PrivateKey.prototype.toString = function() {
return this.toBuffer().toString('hex');
}
/** /**
* Will output the PrivateKey to a WIF string * Will output the PrivateKey to a WIF string
* *
* @returns {String} A WIP representation of the private key * @returns {String} A WIP representation of the private key
*/ */
PrivateKey.prototype.toString = PrivateKey.prototype.toWIF = function() { PrivateKey.prototype.toWIF = function() {
var network = this.network; var network = this.network;
var compressed = this.compressed; var compressed = this.compressed;

3
lib/publickey.js

@ -409,8 +409,7 @@ PublicKey.prototype.toAddress = function(network) {
* @returns {String} A DER hex encoded string * @returns {String} A DER hex encoded string
*/ */
PublicKey.prototype.toString = function() { PublicKey.prototype.toString = function() {
var compressed = _.isUndefined(this.compressed) || this.compressed; return this.toDER().toString('hex');
return this.toDER(compressed).toString('hex');
}; };
/** /**

Loading…
Cancel
Save