valid tx tests passing!

This commit is contained in:
Manuel Araoz 2014-04-04 18:06:34 -03:00
parent 34ed503830
commit 406600720e
4 changed files with 10 additions and 6 deletions

View File

@ -74,9 +74,12 @@ Script.prototype.parse = function() {
};
Script.prototype.isPushOnly = function() {
for (var i = 0; i < this.chunks.length; i++)
if (!Buffer.isBuffer(this.chunks[i]))
for (var i = 0; i < this.chunks.length; i++) {
var op = this.chunks[i];
if (!Buffer.isBuffer(op) && op > OP_16) {
return false;
}
}
return true;
};

View File

@ -938,6 +938,7 @@ ScriptInterpreter.prototype.verifyStep3 = function(scriptSig,
// if P2SH, scriptSig should be push-only
if (!scriptSig.isPushOnly()) {
console.log('3rd step: scriptSig should be push only');
console.log();
callback(null, false);
return;
}
@ -1028,7 +1029,7 @@ var checkSig = ScriptInterpreter.checkSig =
// Verify signature
var key = new Key();
//pubkey = buffertools.reverse(pubkey);
if (pubkey.length === 0) pubkey = new Buffer('00', 'hex');
key.public = pubkey;
console.log('pubkey before verification: '+buffertools.toHex(key.public));

View File

@ -309,9 +309,11 @@ Key::SetPublic(Local<String> property, Local<Value> value, const AccessorInfo& i
Key* key = node::ObjectWrap::Unwrap<Key>(info.Holder());
Handle<Object> buffer = value->ToObject();
const unsigned char *data = (const unsigned char*) Buffer::Data(buffer);
ec_key_st* ret = o2i_ECPublicKey(&(key->ec), &data, Buffer::Length(buffer));
if (!o2i_ECPublicKey(&(key->ec), &data, Buffer::Length(buffer))) {
if (!ret) {
// TODO: Error
std::cout << ret << "C++++++++++++++++++++++++++++++++++++++\n";
return;
}

View File

@ -86,7 +86,6 @@ describe('Transaction', function() {
var i = j;
j += 1;
it('should validate input #' + i, function(done) {
console.log('inputs foreach '+i+': '+tx.serialize().toHex());
var outpointHash = new Buffer(input[0].length);
input[0].copy(outpointHash);
@ -96,7 +95,6 @@ describe('Transaction', function() {
var mapKey = [input];
var scriptPubKey = testTx.inputs[mapKey];
if (!scriptPubKey) throw new Error('Bad test: ' + datum);
console.log('PRE TX:'+buffertools.toHex(tx.serialize()));
tx.verifyInput(
i,
scriptPubKey, {