valid tx tests passing!
This commit is contained in:
parent
34ed503830
commit
406600720e
|
@ -74,9 +74,12 @@ Script.prototype.parse = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
Script.prototype.isPushOnly = function() {
|
Script.prototype.isPushOnly = function() {
|
||||||
for (var i = 0; i < this.chunks.length; i++)
|
for (var i = 0; i < this.chunks.length; i++) {
|
||||||
if (!Buffer.isBuffer(this.chunks[i]))
|
var op = this.chunks[i];
|
||||||
|
if (!Buffer.isBuffer(op) && op > OP_16) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
|
@ -938,6 +938,7 @@ ScriptInterpreter.prototype.verifyStep3 = function(scriptSig,
|
||||||
// if P2SH, scriptSig should be push-only
|
// if P2SH, scriptSig should be push-only
|
||||||
if (!scriptSig.isPushOnly()) {
|
if (!scriptSig.isPushOnly()) {
|
||||||
console.log('3rd step: scriptSig should be push only');
|
console.log('3rd step: scriptSig should be push only');
|
||||||
|
console.log();
|
||||||
callback(null, false);
|
callback(null, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1028,7 +1029,7 @@ var checkSig = ScriptInterpreter.checkSig =
|
||||||
|
|
||||||
// Verify signature
|
// Verify signature
|
||||||
var key = new Key();
|
var key = new Key();
|
||||||
//pubkey = buffertools.reverse(pubkey);
|
if (pubkey.length === 0) pubkey = new Buffer('00', 'hex');
|
||||||
key.public = pubkey;
|
key.public = pubkey;
|
||||||
|
|
||||||
console.log('pubkey before verification: '+buffertools.toHex(key.public));
|
console.log('pubkey before verification: '+buffertools.toHex(key.public));
|
||||||
|
|
|
@ -309,9 +309,11 @@ Key::SetPublic(Local<String> property, Local<Value> value, const AccessorInfo& i
|
||||||
Key* key = node::ObjectWrap::Unwrap<Key>(info.Holder());
|
Key* key = node::ObjectWrap::Unwrap<Key>(info.Holder());
|
||||||
Handle<Object> buffer = value->ToObject();
|
Handle<Object> buffer = value->ToObject();
|
||||||
const unsigned char *data = (const unsigned char*) Buffer::Data(buffer);
|
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
|
// TODO: Error
|
||||||
|
std::cout << ret << "C++++++++++++++++++++++++++++++++++++++\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,6 @@ describe('Transaction', function() {
|
||||||
var i = j;
|
var i = j;
|
||||||
j += 1;
|
j += 1;
|
||||||
it('should validate input #' + i, function(done) {
|
it('should validate input #' + i, function(done) {
|
||||||
console.log('inputs foreach '+i+': '+tx.serialize().toHex());
|
|
||||||
|
|
||||||
var outpointHash = new Buffer(input[0].length);
|
var outpointHash = new Buffer(input[0].length);
|
||||||
input[0].copy(outpointHash);
|
input[0].copy(outpointHash);
|
||||||
|
@ -96,7 +95,6 @@ describe('Transaction', function() {
|
||||||
var mapKey = [input];
|
var mapKey = [input];
|
||||||
var scriptPubKey = testTx.inputs[mapKey];
|
var scriptPubKey = testTx.inputs[mapKey];
|
||||||
if (!scriptPubKey) throw new Error('Bad test: ' + datum);
|
if (!scriptPubKey) throw new Error('Bad test: ' + datum);
|
||||||
console.log('PRE TX:'+buffertools.toHex(tx.serialize()));
|
|
||||||
tx.verifyInput(
|
tx.verifyInput(
|
||||||
i,
|
i,
|
||||||
scriptPubKey, {
|
scriptPubKey, {
|
||||||
|
|
Loading…
Reference in New Issue