diff --git a/lib/hdprivatekey.js b/lib/hdprivatekey.js index b1b4862..8c0591a 100644 --- a/lib/hdprivatekey.js +++ b/lib/hdprivatekey.js @@ -387,6 +387,14 @@ HDPrivateKey.prototype.toString = function() { return this.xprivkey; }; +/** + * Returns the console representation of this extended private key. + * @return string + */ +HDPrivateKey.prototype.inspect = function() { + return ''; +}; + /** * Returns a plain object with a representation of this private key. * diff --git a/lib/hdpublickey.js b/lib/hdpublickey.js index 2c0ff6e..419e989 100644 --- a/lib/hdpublickey.js +++ b/lib/hdpublickey.js @@ -350,6 +350,14 @@ HDPublicKey.prototype.toString = function () { return this.xpubkey; }; +/** + * Returns the console representation of this extended public key. + * @return string + */ +HDPublicKey.prototype.inspect = function() { + return ''; +}; + /** * Returns a plain javascript object with information to reconstruct a key. * diff --git a/lib/script.js b/lib/script.js index fb5cfe4..598f4b0 100644 --- a/lib/script.js +++ b/lib/script.js @@ -196,6 +196,10 @@ Script.prototype.toString = function() { return str.substr(1); }; +Script.prototype.inspect = function() { + return ''; +}; + // script classification methods /** diff --git a/lib/transaction/transaction.js b/lib/transaction/transaction.js index 654efe7..0aa0f7a 100644 --- a/lib/transaction/transaction.js +++ b/lib/transaction/transaction.js @@ -75,10 +75,14 @@ Transaction.prototype._getHash = function() { return Hash.sha256sha256(this.toBuffer()); }; -Transaction.prototype.serialize = function() { +Transaction.prototype.serialize = Transaction.prototype.toString = function() { return this.toBuffer().toString('hex'); }; +Transaction.prototype.inspect = function () { + return ''; +}; + Transaction.prototype.toBuffer = function() { var writer = new BufferWriter(); return this.toBufferWriter(writer).toBuffer(); diff --git a/test/hdprivatekey.js b/test/hdprivatekey.js index b55d1f0..c81b37b 100644 --- a/test/hdprivatekey.js +++ b/test/hdprivatekey.js @@ -83,6 +83,10 @@ describe('HDPrivate key interface', function() { HDPrivateKey(xprivkey).toString().should.equal(xprivkey); }); + it('inspect() displays correctly', function() { + HDPrivateKey(xprivkey).inspect().should.equal(''); + }); + it('allows the use of a copy constructor', function() { HDPrivateKey(HDPrivateKey(xprivkey)) .xprivkey.should.equal(xprivkey); diff --git a/test/hdpublickey.js b/test/hdpublickey.js index 3deb3db..67c31e0 100644 --- a/test/hdpublickey.js +++ b/test/hdpublickey.js @@ -148,6 +148,11 @@ describe('HDPublicKey interface', function() { pubKey.toString().should.equal(pubKey.xpubkey); }); + it('inspect() displays correctly', function() { + var pubKey = new HDPublicKey(xpubkey); + pubKey.inspect().should.equal(''); + }); + describe('derivation', function() { it('derivation is the same whether deriving with number or string', function() { var pubkey = new HDPublicKey(xpubkey); diff --git a/test/transaction.js b/test/transaction.js index 9af3b56..ffe3d2b 100644 --- a/test/transaction.js +++ b/test/transaction.js @@ -16,6 +16,11 @@ describe('Transaction', function() { transaction.serialize().should.equal(tx_1_hex); }); + it('should display correctly in console', function() { + var transaction = new Transaction(tx_1_hex); + transaction.inspect().should.equal(''); + }); + it('standard hash of transaction should be decoded correctly', function() { var transaction = new Transaction(tx_1_hex); transaction.id.should.equal(tx_1_id);