Browse Source

some more passing tests

patch-2
Manuel Araoz 10 years ago
parent
commit
a761ac91c2
  1. 1
      lib/script_interpreter.js
  2. 9
      lib/transaction/sighash.js
  3. 3
      test/script_interpreter.js

1
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();

9
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:');

3
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);

Loading…
Cancel
Save