|
|
@ -182,8 +182,9 @@ Script.fromString = function(str) { |
|
|
|
return script; |
|
|
|
}; |
|
|
|
|
|
|
|
Script.prototype._chunkToString = function(chunk) { |
|
|
|
Script.prototype._chunkToString = function(chunk, type) { |
|
|
|
var opcodenum = chunk.opcodenum; |
|
|
|
var asm = (type === 'asm'); |
|
|
|
var str = ''; |
|
|
|
if (!chunk.buf) { |
|
|
|
// no data chunk
|
|
|
@ -194,7 +195,11 @@ Script.prototype._chunkToString = function(chunk) { |
|
|
|
if (numstr.length % 2 !== 0) { |
|
|
|
numstr = '0' + numstr; |
|
|
|
} |
|
|
|
str = str + ' ' + '0x' + numstr; |
|
|
|
if (asm) { |
|
|
|
str = str + ' ' + numstr; |
|
|
|
} else { |
|
|
|
str = str + ' ' + '0x' + numstr; |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
// data chunk
|
|
|
@ -203,14 +208,27 @@ Script.prototype._chunkToString = function(chunk) { |
|
|
|
opcodenum === Opcode.OP_PUSHDATA4) { |
|
|
|
str = str + ' ' + Opcode(opcodenum).toString(); |
|
|
|
} |
|
|
|
str = str + ' ' + chunk.len; |
|
|
|
if (chunk.len > 0) { |
|
|
|
str = str + ' ' + '0x' + chunk.buf.toString('hex'); |
|
|
|
if (asm) { |
|
|
|
str = str + ' ' + chunk.buf.toString('hex'); |
|
|
|
} else { |
|
|
|
str = str + ' ' + chunk.len + ' ' + '0x' + chunk.buf.toString('hex'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return str; |
|
|
|
}; |
|
|
|
|
|
|
|
Script.prototype.toASM = function() { |
|
|
|
var str = ''; |
|
|
|
for (var i = 0; i < this.chunks.length; i++) { |
|
|
|
var chunk = this.chunks[i]; |
|
|
|
str += this._chunkToString(chunk, 'asm'); |
|
|
|
} |
|
|
|
|
|
|
|
return str.substr(1); |
|
|
|
}; |
|
|
|
|
|
|
|
Script.prototype.toString = function() { |
|
|
|
var str = ''; |
|
|
|
for (var i = 0; i < this.chunks.length; i++) { |
|
|
|