Skip to content

Commit c1399ff

Browse files
author
Tom Wu
committed
Merge branch 'master' of https://github.com/siminchen/bitcoinIDE
2 parents 197e582 + e885227 commit c1399ff

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

build/script_interpreter/interpreter.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ interpreter.prototype.nextStep = function (mainstack, altstack, script, index) {
260260
if (mainstack.pop() == null) return -1;
261261
break;
262262
case "OP_DUP":
263-
var toPeek = mainstack.peek(0);
263+
var toPeek = mainstack.peek(1);
264264
if (toPeek == null) return -1;
265265
mainstack.push(toPeek);
266266
break;
@@ -633,8 +633,11 @@ interpreter.prototype.nextStep = function (mainstack, altstack, script, index) {
633633
code_separator_index = index;
634634
break;
635635
case "OP_CHECKSIG":
636-
//var pubKey = mainstack.pop();
637-
//var sig = mainstack.pop();
636+
var pubKey = mainstack.pop();
637+
if (pubKey == null) return -1;
638+
639+
var sig = mainstack.pop();
640+
if (sig == null) return -1;
638641

639642
//var sub_script = new Array();
640643
//for (var i = code_separator_index; i < script.length; i++) {
@@ -645,8 +648,20 @@ interpreter.prototype.nextStep = function (mainstack, altstack, script, index) {
645648
// see https://en.bitcoin.it/wiki/OP_CHECKSIG
646649
// use secp256k1 elliptic curve for signature verification
647650
case "OP_CHECKSIGVERIFY":
648-
mainstack.push(1);
649-
mainstack.pop();
651+
var pubKey = mainstack.pop();
652+
if (pubKey == null) return -1;
653+
654+
var sig = mainstack.pop();
655+
if (sig == null) return -1;
656+
657+
//var sub_script = new Array();
658+
//for (var i = code_separator_index; i < script.length; i++) {
659+
// if (script[i] !== sig) sub_script.push(script[i]);
660+
//}
661+
mainstack.push("1");
662+
663+
if (mainstack.pop() === 0)
664+
return -1;
650665
break;
651666
case "OP_CHECKMULTISIG":
652667
mainstack.push(1);

0 commit comments

Comments
 (0)