Handle floData as a Buffer everywhere
This commit is contained in:
parent
632b62986c
commit
fef6643742
@ -50,7 +50,7 @@ class TX {
|
||||
this.outputs = [];
|
||||
this.locktime = 0;
|
||||
|
||||
this.strFloData = "";
|
||||
this.floData = Buffer.alloc(0);
|
||||
|
||||
this.mutable = false;
|
||||
|
||||
@ -145,7 +145,7 @@ class TX {
|
||||
for (const output of tx.outputs)
|
||||
this.outputs.push(output.clone());
|
||||
|
||||
this.strFloData = tx.strFloData;
|
||||
this.floData = tx.floData;
|
||||
|
||||
this.locktime = tx.locktime;
|
||||
|
||||
@ -577,7 +577,7 @@ class TX {
|
||||
bw.writeU32(this.locktime);
|
||||
|
||||
if (this.version >= 2 && includeFloData) {
|
||||
bw.writeVarBytes(Buffer.from(this.strFloData));
|
||||
bw.writeVarBytes(this.floData);
|
||||
}
|
||||
|
||||
// Append the hash type.
|
||||
@ -629,8 +629,8 @@ class TX {
|
||||
break;
|
||||
}
|
||||
|
||||
if (includeFloData){
|
||||
let bufferLength = Buffer.from(this.strFloData).length;
|
||||
if (this.version >= 2 && includeFloData){
|
||||
let bufferLength = this.floData.length;
|
||||
|
||||
size += encoding.sizeVarint(bufferLength);
|
||||
size += bufferLength
|
||||
@ -735,7 +735,7 @@ class TX {
|
||||
|
||||
// Add the FloData to the transaction
|
||||
if (this.version >= 2 && includeFloData) {
|
||||
bw.writeVarBytes(Buffer.from(this.strFloData));
|
||||
bw.writeVarBytes(this.floData);
|
||||
}
|
||||
|
||||
bw.writeU32(type);
|
||||
@ -2157,7 +2157,7 @@ class TX {
|
||||
}),
|
||||
outputs: this.outputs,
|
||||
locktime: this.locktime,
|
||||
floData: this.strFloData
|
||||
floData: this.floData.toString()
|
||||
};
|
||||
}
|
||||
|
||||
@ -2225,7 +2225,7 @@ class TX {
|
||||
}),
|
||||
locktime: this.locktime,
|
||||
hex: this.toRaw().toString('hex'),
|
||||
floData: this.strFloData
|
||||
floData: this.floData
|
||||
};
|
||||
}
|
||||
|
||||
@ -2251,7 +2251,7 @@ class TX {
|
||||
for (const output of json.outputs)
|
||||
this.outputs.push(Output.fromJSON(output));
|
||||
|
||||
this.strFloData = json.floData
|
||||
this.floData = json.floData
|
||||
|
||||
this.locktime = json.locktime;
|
||||
|
||||
@ -2336,8 +2336,7 @@ class TX {
|
||||
}
|
||||
|
||||
if (this.version >= 2){
|
||||
let floDataBuffer = br.readVarBytes();
|
||||
this.strFloData = Buffer.from(floDataBuffer).toString();
|
||||
this.floData = br.readVarBytes();
|
||||
}
|
||||
|
||||
if (!this.mutable) {
|
||||
@ -2408,9 +2407,7 @@ class TX {
|
||||
|
||||
this.locktime = br.readU32();
|
||||
if (this.version >= 2){
|
||||
var floDataLength = br.readVarint();
|
||||
var floDataBuffer = br.readBytes(floDataLength);
|
||||
this.strFloData = Buffer.from(floDataBuffer).toString();
|
||||
this.floData = br.readVarBytes();
|
||||
}
|
||||
|
||||
if (block) {
|
||||
@ -2484,7 +2481,7 @@ class TX {
|
||||
bw.writeU32(this.locktime);
|
||||
|
||||
if (this.version >= 2){
|
||||
bw.writeVarBytes(Buffer.from(this.strFloData));
|
||||
bw.writeVarBytes(this.floData);
|
||||
}
|
||||
|
||||
return bw;
|
||||
@ -2526,7 +2523,7 @@ class TX {
|
||||
bw.writeU32(this.locktime);
|
||||
|
||||
if (this.version >= 2){
|
||||
bw.writeVarBytes(Buffer.from(this.strFloData));
|
||||
bw.writeVarBytes(this.floData);
|
||||
}
|
||||
|
||||
if (witness === this.inputs.length)
|
||||
@ -2557,14 +2554,8 @@ class TX {
|
||||
base += output.getSize();
|
||||
|
||||
if (this.version >= 2){
|
||||
let bufferLength = Buffer.from(this.strFloData).length;
|
||||
|
||||
if (this.strFloData.length > 0){
|
||||
base += encoding.sizeVarint(bufferLength);
|
||||
base += bufferLength
|
||||
} else {
|
||||
base += encoding.sizeVarint(0);
|
||||
}
|
||||
base += encoding.sizeVarint(this.floData.length);
|
||||
base += this.floData.length
|
||||
}
|
||||
|
||||
base += 4;
|
||||
@ -2598,14 +2589,8 @@ class TX {
|
||||
base += output.getSize();
|
||||
|
||||
if (this.version >= 2){
|
||||
let bufferLength = Buffer.from(this.strFloData).length;
|
||||
|
||||
if (this.strFloData.length > 0){
|
||||
base += encoding.sizeVarint(bufferLength);
|
||||
base += bufferLength
|
||||
} else {
|
||||
base += encoding.sizeVarint(0);
|
||||
}
|
||||
base += encoding.sizeVarint(this.floData.length);
|
||||
base += this.floData.length
|
||||
}
|
||||
|
||||
base += 4;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user