diff --git a/Script.js b/Script.js index b46a86875..a4ffbd2cd 100644 --- a/Script.js +++ b/Script.js @@ -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; }; diff --git a/ScriptInterpreter.js b/ScriptInterpreter.js index ae0857464..0c54c1413 100644 --- a/ScriptInterpreter.js +++ b/ScriptInterpreter.js @@ -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)); diff --git a/src/eckey.cc b/src/eckey.cc index 9f0886e82..a41d3194d 100644 --- a/src/eckey.cc +++ b/src/eckey.cc @@ -309,9 +309,11 @@ Key::SetPublic(Local property, Local value, const AccessorInfo& i Key* key = node::ObjectWrap::Unwrap(info.Holder()); Handle 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; } diff --git a/test/test.Transaction.js b/test/test.Transaction.js index e676c7406..f1621e3dd 100644 --- a/test/test.Transaction.js +++ b/test/test.Transaction.js @@ -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, {