btc-script
Advanced tools
Comparing version 0.1.7 to 0.1.8
@@ -0,1 +1,5 @@ | ||
0.1.8 / 2014-04-10 | ||
----------------- | ||
* ASM support | ||
0.1.7 / 2014-04-09 | ||
@@ -2,0 +6,0 @@ ----------------- |
@@ -535,2 +535,56 @@ var Opcode = require('btc-opcode'); | ||
return false | ||
} | ||
} | ||
Script.prototype.toASM = function(truncate, maxEl) { | ||
if (truncate === null) { | ||
truncate = true; | ||
} | ||
if ('undefined' === typeof maxEl) { | ||
maxEl = 20; | ||
} | ||
var type = this.getOutType() | ||
var s = ''; | ||
for (var i = 0, l = this.chunks.length; i < l; i++) { | ||
var chunk = this.chunks[i]; | ||
if (i > 0) { | ||
s += ' '; | ||
} | ||
if (Array.isArray(chunk)) { | ||
if (truncate === true) { | ||
var maxLen = chunk.length | ||
} else { | ||
var maxLen = 100 | ||
} | ||
s += new Buffer(chunk.splice(0, maxLen)).toString('hex'); | ||
if (truncate) { | ||
s += '...' | ||
} | ||
} else { | ||
if (type === 'multisig') { | ||
switch (chunk) { | ||
case 80: | ||
s += 'OP_0' | ||
break | ||
case 81: | ||
s += 'OP_1' | ||
break | ||
default: | ||
s += Opcode.reverseMap[chunk] | ||
} | ||
} else { | ||
s += Opcode.reverseMap[chunk]; | ||
} | ||
} | ||
if (maxEl && i > maxEl) { | ||
s += ' ...'; | ||
break; | ||
} | ||
} | ||
return s; | ||
}; |
{ | ||
"name": "btc-script", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"description": "Script support for Bitcoin.", | ||
@@ -29,2 +29,2 @@ "keywords": [ | ||
} | ||
} | ||
} |
18330
529