Browse Source

Merge pull request #70 from caedesvvv/master

fix transaction hashing (was using Message.getHash incorrectly).
hk-custom-address
Wei Lu 11 years ago
parent
commit
b93a774414
  1. 8
      src/transaction.js

8
src/transaction.js

@ -7,6 +7,7 @@ var ECKey = require('./eckey').ECKey;
var ECDSA = require('./ecdsa'); var ECDSA = require('./ecdsa');
var Address = require('./address'); var Address = require('./address');
var Message = require('./message'); var Message = require('./message');
var SHA256 = require('crypto-js/sha256');
var Transaction = function (doc) { var Transaction = function (doc) {
if (!(this instanceof Transaction)) { return new Transaction(doc); } if (!(this instanceof Transaction)) { return new Transaction(doc); }
@ -207,7 +208,8 @@ function (connectedScript, inIndex, hashType)
buffer = buffer.concat(convert.numToBytes(parseInt(hashType),4)); buffer = buffer.concat(convert.numToBytes(parseInt(hashType),4));
return Message.getHash(buffer) buffer = convert.bytesToWordArray(buffer);
return convert.wordArrayToBytes(SHA256(SHA256(buffer)));
}; };
/** /**
@ -217,8 +219,8 @@ function (connectedScript, inIndex, hashType)
*/ */
Transaction.prototype.getHash = function () Transaction.prototype.getHash = function ()
{ {
var buffer = this.serialize(); var buffer = convert.bytesToWordArray(this.serialize());
return Message.getHash(buffer).reverse() return convert.wordArrayToBytes(SHA256(SHA256(buffer))).reverse();
}; };
/** /**

Loading…
Cancel
Save