tx_valid tests passing!
This commit is contained in:
parent
d56fb04575
commit
b3be9461cf
@ -162,6 +162,7 @@ ScriptInterpreter.prototype.checkPubkeyEncoding = function(buf) {
|
|||||||
* bitcoind commit: b5d1b1092998bc95313856d535c632ea5a8f9104
|
* bitcoind commit: b5d1b1092998bc95313856d535c632ea5a8f9104
|
||||||
*/
|
*/
|
||||||
ScriptInterpreter.prototype.evaluate = function() {
|
ScriptInterpreter.prototype.evaluate = function() {
|
||||||
|
console.log(this.script.toString());
|
||||||
if (this.script.toBuffer().length > 10000) {
|
if (this.script.toBuffer().length > 10000) {
|
||||||
this.errstr = 'SCRIPT_ERR_SCRIPT_SIZE';
|
this.errstr = 'SCRIPT_ERR_SCRIPT_SIZE';
|
||||||
return false;
|
return false;
|
||||||
@ -883,7 +884,6 @@ ScriptInterpreter.prototype.step = function() {
|
|||||||
subscript.findAndDelete(tmpScript);
|
subscript.findAndDelete(tmpScript);
|
||||||
|
|
||||||
if (!this.checkSignatureEncoding(bufSig) || !this.checkPubkeyEncoding(bufPubkey)) {
|
if (!this.checkSignatureEncoding(bufSig) || !this.checkPubkeyEncoding(bufPubkey)) {
|
||||||
// serror is set
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -973,7 +973,6 @@ ScriptInterpreter.prototype.step = function() {
|
|||||||
var bufPubkey = this.stack[this.stack.length - ikey];
|
var bufPubkey = this.stack[this.stack.length - ikey];
|
||||||
|
|
||||||
if (!this.checkSignatureEncoding(bufSig) || !this.checkPubkeyEncoding(bufPubkey)) {
|
if (!this.checkSignatureEncoding(bufSig) || !this.checkPubkeyEncoding(bufPubkey)) {
|
||||||
// serror is set
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1141,7 +1140,6 @@ ScriptInterpreter.prototype.verify = function(scriptSig, scriptPubkey, tx, nin,
|
|||||||
|
|
||||||
// evaluate redeemScript
|
// evaluate redeemScript
|
||||||
if (!this.evaluate())
|
if (!this.evaluate())
|
||||||
// serror is set
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (stackCopy.length === 0) {
|
if (stackCopy.length === 0) {
|
||||||
|
|||||||
@ -11,6 +11,7 @@ var BN = require('../crypto/bn');
|
|||||||
var Hash = require('../crypto/hash');
|
var Hash = require('../crypto/hash');
|
||||||
var ECDSA = require('../crypto/ecdsa');
|
var ECDSA = require('../crypto/ecdsa');
|
||||||
var $ = require('../util/preconditions');
|
var $ = require('../util/preconditions');
|
||||||
|
var _ = require('lodash');
|
||||||
|
|
||||||
var SIGHASH_SINGLE_BUG = '0000000000000000000000000000000000000000000000000000000000000001';
|
var SIGHASH_SINGLE_BUG = '0000000000000000000000000000000000000000000000000000000000000001';
|
||||||
var BITS_64_ON = 'ffffffffffffffff';
|
var BITS_64_ON = 'ffffffffffffffff';
|
||||||
@ -122,8 +123,8 @@ function sign(transaction, privateKey, sighashType, inputIndex, subscript) {
|
|||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
*/
|
*/
|
||||||
function verify(transaction, signature, publicKey, inputIndex, subscript) {
|
function verify(transaction, signature, publicKey, inputIndex, subscript) {
|
||||||
$.checkArgument(transaction);
|
$.checkArgument(!_.isUndefined(transaction));
|
||||||
$.checkArgument(signature && signature.nhashtype);
|
$.checkArgument(!_.isUndefined(signature) && !_.isUndefined(signature.nhashtype));
|
||||||
var hashbuf = sighash(transaction, signature.nhashtype, inputIndex, subscript);
|
var hashbuf = sighash(transaction, signature.nhashtype, inputIndex, subscript);
|
||||||
return ECDSA.verify(hashbuf, signature, publicKey, 'little');
|
return ECDSA.verify(hashbuf, signature, publicKey, 'little');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -247,7 +247,6 @@ describe('ScriptInterpreter', function() {
|
|||||||
|
|
||||||
var tx = Transaction(txhex);
|
var tx = Transaction(txhex);
|
||||||
tx.inputs.forEach(function(txin, j) {
|
tx.inputs.forEach(function(txin, j) {
|
||||||
console.log('input ' + j);
|
|
||||||
var scriptSig = txin.script;
|
var scriptSig = txin.script;
|
||||||
var txidhex = txin.prevTxId.toString('hex');
|
var txidhex = txin.prevTxId.toString('hex');
|
||||||
var txoutnum = txin.outputIndex;
|
var txoutnum = txin.outputIndex;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user