|
|
@ -124,7 +124,7 @@ Script.fromString = function(str) { |
|
|
|
}); |
|
|
|
i = i + 2; |
|
|
|
} else { |
|
|
|
throw new Error('Invalid script: '+JSON.stringify(str)); |
|
|
|
throw new Error('Invalid script: ' + JSON.stringify(str)); |
|
|
|
} |
|
|
|
} else if (opcodenum === Opcode.map.OP_PUSHDATA1 || |
|
|
|
opcodenum === Opcode.map.OP_PUSHDATA2 || |
|
|
@ -200,14 +200,19 @@ Script.prototype.isPublicKeyHashIn = function() { |
|
|
|
* @returns true if this is a public key output script |
|
|
|
*/ |
|
|
|
Script.prototype.isPublicKeyOut = function() { |
|
|
|
return false; |
|
|
|
return this.chunks.length === 2 && |
|
|
|
Buffer.isBuffer(this.chunks[0].buf) && |
|
|
|
this.chunks[0].buf.length === 0x41 && |
|
|
|
this.chunks[1] === Opcode('OP_CHECKSIG').toNumber(); |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* @returns true if this is a pay to public key input script |
|
|
|
*/ |
|
|
|
Script.prototype.isPublicKeyIn = function() { |
|
|
|
return false; |
|
|
|
return this.chunks.length === 1 && |
|
|
|
Buffer.isBuffer(this.chunks[0].buf) && |
|
|
|
this.chunks[0].buf.length === 0x47; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -238,11 +243,8 @@ Script.prototype.isScriptHashIn = function() { |
|
|
|
if (!scriptBuf) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
console.log(this.toString()); |
|
|
|
var redeemScript = new Script(scriptBuf); |
|
|
|
var type = redeemScript.classify(); |
|
|
|
console.log(redeemScript.toString()); |
|
|
|
console.log(redeemScript.classify()); |
|
|
|
return type !== Script.types.UNKNOWN; |
|
|
|
}; |
|
|
|
|
|
|
|