more serialization.
This commit is contained in:
parent
132798e898
commit
c2baa09b1f
@ -1075,18 +1075,26 @@ TX.prototype.toExtended = function toExtended(coins) {
|
|||||||
var buf = new Buffer(tx.length + 4 + 32 + 4 + 4 + 4);
|
var buf = new Buffer(tx.length + 4 + 32 + 4 + 4 + 4);
|
||||||
var block = this.block ? new Buffer(this.block, 'hex') : constants.zeroHash;
|
var block = this.block ? new Buffer(this.block, 'hex') : constants.zeroHash;
|
||||||
var height = this.height;
|
var height = this.height;
|
||||||
|
var index = this.index;
|
||||||
|
var changeIndex = this.changeIndex != null ? this.changeIndex : -1;
|
||||||
var off = 0;
|
var off = 0;
|
||||||
|
|
||||||
if (height === -1)
|
if (height === -1)
|
||||||
height = 0x7fffffff;
|
height = 0x7fffffff;
|
||||||
|
|
||||||
|
if (index === -1)
|
||||||
|
index = 0x7fffffff;
|
||||||
|
|
||||||
|
if (changeIndex === -1)
|
||||||
|
changeIndex = 0x7fffffff;
|
||||||
|
|
||||||
off += utils.copy(tx, buf, off);
|
off += utils.copy(tx, buf, off);
|
||||||
off += utils.writeU32(buf, height, off);
|
off += utils.writeU32(buf, height, off);
|
||||||
off += utils.copy(block, buf, off);
|
off += utils.copy(block, buf, off);
|
||||||
off += utils.writeU32(buf, this.index, off);
|
off += utils.writeU32(buf, this.index, off);
|
||||||
off += utils.writeU32(buf, this.ts, off);
|
off += utils.writeU32(buf, this.ts, off);
|
||||||
off += utils.writeU32(buf, this.ps, off);
|
off += utils.writeU32(buf, this.ps, off);
|
||||||
// off += utils.writeU32(buf, this.changeIndex || -1, off);
|
// off += utils.writeU32(buf, changeIndex, off);
|
||||||
|
|
||||||
if (coins) {
|
if (coins) {
|
||||||
off += utils.writeIntv(buf, this.inputs.length, off);
|
off += utils.writeIntv(buf, this.inputs.length, off);
|
||||||
@ -1131,6 +1139,8 @@ TX._fromExtended = function _fromExtended(buf, coins) {
|
|||||||
off += 4;
|
off += 4;
|
||||||
tx.ps = utils.readU32(buf, off);
|
tx.ps = utils.readU32(buf, off);
|
||||||
off += 4;
|
off += 4;
|
||||||
|
// tx.changeIndex = utils.readU32(buf, off);
|
||||||
|
// off += 4;
|
||||||
|
|
||||||
if (+tx.block === 0)
|
if (+tx.block === 0)
|
||||||
tx.block = null;
|
tx.block = null;
|
||||||
@ -1138,6 +1148,12 @@ TX._fromExtended = function _fromExtended(buf, coins) {
|
|||||||
if (tx.height === 0x7fffffff)
|
if (tx.height === 0x7fffffff)
|
||||||
tx.height = -1;
|
tx.height = -1;
|
||||||
|
|
||||||
|
if (tx.index === 0x7fffffff)
|
||||||
|
tx.index = -1;
|
||||||
|
|
||||||
|
if (tx.changeIndex === 0x7fffffff)
|
||||||
|
tx.changeIndex = -1;
|
||||||
|
|
||||||
if (coins) {
|
if (coins) {
|
||||||
coinCount = utils.readIntv(buf, off);
|
coinCount = utils.readIntv(buf, off);
|
||||||
off = coinCount.off;
|
off = coinCount.off;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user