diff --git a/src/script.js b/src/script.js index 7958d12..c47945c 100644 --- a/src/script.js +++ b/src/script.js @@ -150,7 +150,7 @@ Script.prototype.toScriptHash = function() { return util.sha256ripe160(this.buffer) } -Script.prototype.toAddress = function() { +Script.prototype.getToAddress = function() { var outType = this.getOutType(); if (outType == 'Pubkey') { diff --git a/src/transaction.js b/src/transaction.js index 20d03dd..3cbf5b0 100644 --- a/src/transaction.js +++ b/src/transaction.js @@ -415,7 +415,7 @@ var TransactionOut = function (data) { : data.address ? Script.createOutputScript(data.address) : new Script(); - if (this.script.buffer.length > 0) this.address = this.script.toAddress(); + if (this.script.buffer.length > 0) this.address = this.script.getToAddress(); this.value = Array.isArray(data.value) ? convert.bytesToNum(data.value) diff --git a/test/script.js b/test/script.js index 73cf257..76f3a6f 100644 --- a/test/script.js +++ b/test/script.js @@ -63,15 +63,15 @@ describe('Script', function() { }) }) - describe('toAddress', function() { + describe('getToAddress', function() { it('works for p2sh type output', function() { var script = Script.fromHex("a914e8c300c87986efa84c37c0519929019ef86eb5b487") - assert.equal(script.toAddress(), '3NukJ6fYZJ5Kk8bPjycAnruZkE5Q7UW7i8') + assert.equal(script.getToAddress(), '3NukJ6fYZJ5Kk8bPjycAnruZkE5Q7UW7i8') }) it('works for pubkey type output', function() { var script = Script.fromHex("76a9145a3acbc7bbcc97c5ff16f5909c9d7d3fadb293a888ac") - assert.equal(script.toAddress(), '19E6FV3m3kEPoJD5Jz6dGKdKwTVvjsWUvu') + assert.equal(script.getToAddress(), '19E6FV3m3kEPoJD5Jz6dGKdKwTVvjsWUvu') }) }) })