Added hash flipping to serialization and deserialization

This commit is contained in:
vub 2013-10-08 07:05:21 -04:00
parent 50f6333b0e
commit 2bfa783be2
2 changed files with 5 additions and 5 deletions

2
bitcoinjs-min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -132,9 +132,9 @@ Transaction.prototype.serialize = function ()
for (var i = 0; i < this.ins.length; i++) {
var txin = this.ins[i];
// the hash is flipped to what the fuck here?
// this seems to be the only thing that I don't understand
buffer = buffer.concat(conv.hexToBytes(txin.outpoint.hash));
// Why do blockchain.info, blockexplorer.com, sx and just about everybody
// else use little-endian hashes? No idea...
buffer = buffer.concat(conv.hexToBytes(txin.outpoint.hash).reverse());
buffer = buffer.concat(util.numToBytes(parseInt(txin.outpoint.index),4));
var scriptBytes = txin.script.buffer;
@ -454,7 +454,7 @@ Transaction.deserialize = function(buffer) {
for (var i = 0; i < ins; i++) {
obj.ins.push({
outpoint: {
hash: conv.bytesToHex(readBytes(32)),
hash: conv.bytesToHex(readBytes(32).reverse()),
index: readAsInt(4)
},
script: new Script(readVarString()),