From a761ac91c2c2f8f72e95f731681bcd8c3d6145d7 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Mon, 15 Dec 2014 19:14:55 -0300 Subject: [PATCH] some more passing tests --- lib/script_interpreter.js | 1 + lib/transaction/sighash.js | 9 ++++----- test/script_interpreter.js | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/script_interpreter.js b/lib/script_interpreter.js index 9a135aa67..89dab4178 100644 --- a/lib/script_interpreter.js +++ b/lib/script_interpreter.js @@ -897,6 +897,7 @@ ScriptInterpreter.prototype.step = function() { console.log('FALSEEEEEEEEEEEEEEEEee ' + e); fSuccess = false; } + this.tx.verify(sig, pubkey, this.nin, subscript); this.stack.pop(); this.stack.pop(); diff --git a/lib/transaction/sighash.js b/lib/transaction/sighash.js index d2bec4a27..d20a4cef1 100644 --- a/lib/transaction/sighash.js +++ b/lib/transaction/sighash.js @@ -84,10 +84,10 @@ function sighash(transaction, sighashType, inputNumber, subscript) { .write(txcopy.toBuffer()) .writeInt32LE(sighashType) .toBuffer(); - console.log('actual:'); - console.log(buf.toString('hex')); - console.log('expected:'); - console.log('01000000019ce5586f04dd407719ab7e2ed3583583b9022f29652702cfac5ed082013461fe0000000043410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8acffffffff010000000000000000000000000001000000'); + //console.log('actual:'); + //console.log(buf.toString('hex')); + //console.log('expected:'); + //console.log('01000000019ce5586f04dd407719ab7e2ed3583583b9022f29652702cfac5ed082013461fe0000000043410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8acffffffff010000000000000000000000000001000000'); return BufferReader(Hash.sha256sha256(buf)).readReverse(); } @@ -100,7 +100,6 @@ function sign(transaction, keypair, nhashtype, nin, subscript) { function verify(transaction, sig, pubkey, nin, subscript) { var hashbuf = sighash(transaction, sig.nhashtype, nin, subscript); - hashbuf = new BufferReader(hashbuf).readReverse(); console.log('actual:'); console.log(hashbuf.toString('hex')); console.log('expected:'); diff --git a/test/script_interpreter.js b/test/script_interpreter.js index 3b43a2d5a..ba6d37d4a 100644 --- a/test/script_interpreter.js +++ b/test/script_interpreter.js @@ -269,10 +269,11 @@ describe('ScriptInterpreter', function() { script: scriptSig })); //spendtx.addTxout(BN(0), Script()); - credtx._addOutput(new Transaction.Output({ + spendtx._addOutput(new Transaction.Output({ script: Script(), satoshis: 0 })); + var interp = ScriptInterpreter(); console.log(scriptSig.toString() + ' ' + scriptPubkey.toString()); var verified = interp.verify(scriptSig, scriptPubkey, spendtx, 0, flags);