more serialization.

This commit is contained in:
Christopher Jeffrey 2016-03-06 12:36:07 -08:00
parent 132798e898
commit c2baa09b1f

View File

@ -1075,18 +1075,26 @@ TX.prototype.toExtended = function toExtended(coins) {
var buf = new Buffer(tx.length + 4 + 32 + 4 + 4 + 4);
var block = this.block ? new Buffer(this.block, 'hex') : constants.zeroHash;
var height = this.height;
var index = this.index;
var changeIndex = this.changeIndex != null ? this.changeIndex : -1;
var off = 0;
if (height === -1)
height = 0x7fffffff;
if (index === -1)
index = 0x7fffffff;
if (changeIndex === -1)
changeIndex = 0x7fffffff;
off += utils.copy(tx, buf, off);
off += utils.writeU32(buf, height, off);
off += utils.copy(block, buf, off);
off += utils.writeU32(buf, this.index, off);
off += utils.writeU32(buf, this.ts, off);
off += utils.writeU32(buf, this.ps, off);
// off += utils.writeU32(buf, this.changeIndex || -1, off);
// off += utils.writeU32(buf, changeIndex, off);
if (coins) {
off += utils.writeIntv(buf, this.inputs.length, off);
@ -1131,6 +1139,8 @@ TX._fromExtended = function _fromExtended(buf, coins) {
off += 4;
tx.ps = utils.readU32(buf, off);
off += 4;
// tx.changeIndex = utils.readU32(buf, off);
// off += 4;
if (+tx.block === 0)
tx.block = null;
@ -1138,6 +1148,12 @@ TX._fromExtended = function _fromExtended(buf, coins) {
if (tx.height === 0x7fffffff)
tx.height = -1;
if (tx.index === 0x7fffffff)
tx.index = -1;
if (tx.changeIndex === 0x7fffffff)
tx.changeIndex = -1;
if (coins) {
coinCount = utils.readIntv(buf, off);
off = coinCount.off;