Calculate the size of floData and add it to the bufferwriter initial size
This commit is contained in:
parent
36f88b398f
commit
4d7b920048
@ -698,7 +698,22 @@ TX.prototype.signatureHashV1 = function signatureHashV1(index, prev, value, type
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const size = 156 + prev.getVarSize();
|
// Calculate the size of the transaction including the Flo Data
|
||||||
|
let fOmitTxComment = !!(type & hashType.OMIT_TX_COMMENT);
|
||||||
|
let floDataSize = 0
|
||||||
|
if (!fOmitTxComment){
|
||||||
|
let bufferLength = Buffer.from(this.strFloData).length;
|
||||||
|
|
||||||
|
if (this.strFloData.length > 0){
|
||||||
|
floDataSize += encoding.sizeVarint(bufferLength);
|
||||||
|
floDataSize += bufferLength
|
||||||
|
} else {
|
||||||
|
floDataSize += encoding.sizeVarint(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const size = 156 + prev.getVarSize() + floDataSize;
|
||||||
|
|
||||||
const bw = StaticWriter.pool(size);
|
const bw = StaticWriter.pool(size);
|
||||||
|
|
||||||
bw.writeU32(this.version);
|
bw.writeU32(this.version);
|
||||||
@ -712,14 +727,14 @@ TX.prototype.signatureHashV1 = function signatureHashV1(index, prev, value, type
|
|||||||
bw.writeBytes(outputs);
|
bw.writeBytes(outputs);
|
||||||
bw.writeU32(this.locktime);
|
bw.writeU32(this.locktime);
|
||||||
|
|
||||||
var fOmitTxComment = !!(type & hashType.OMIT_TX_COMMENT);
|
// Add the FloData to the transaction
|
||||||
|
|
||||||
if (this.version >= 2 && !fOmitTxComment) {
|
if (this.version >= 2 && !fOmitTxComment) {
|
||||||
bw.writeVarBytes(Buffer.from(this.strFloData));
|
bw.writeVarBytes(Buffer.from(this.strFloData));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove the OMIT_TX_COMMENT flag if included
|
||||||
type &= ~hashType.OMIT_TX_COMMENT;
|
type &= ~hashType.OMIT_TX_COMMENT;
|
||||||
|
|
||||||
bw.writeU32(type);
|
bw.writeU32(type);
|
||||||
|
|
||||||
return digest.hash256(bw.render());
|
return digest.hash256(bw.render());
|
||||||
|
|||||||
@ -1175,14 +1175,19 @@ Script.prototype.execute = function execute(stack, flags, tx, index, value, vers
|
|||||||
try {
|
try {
|
||||||
hash = tx.signatureHash(index, subscript, value, type, version);
|
hash = tx.signatureHash(index, subscript, value, type, version);
|
||||||
res = checksig(hash, sig, key);
|
res = checksig(hash, sig, key);
|
||||||
} catch (e) {}
|
} catch (e) {
|
||||||
|
// Having issues with signatures? Log this error then!
|
||||||
|
}
|
||||||
|
|
||||||
if (!res){
|
if (!res){
|
||||||
type ^= Script.hashType.OMIT_TX_COMMENT;
|
type ^= Script.hashType.OMIT_TX_COMMENT;
|
||||||
try {
|
try {
|
||||||
hash = tx.signatureHash(index, subscript, value, type, version);
|
hash = tx.signatureHash(index, subscript, value, type, version);
|
||||||
res = checksig(hash, sig, key);
|
res = checksig(hash, sig, key);
|
||||||
} catch (e) {}
|
} catch (e) {
|
||||||
|
// Having issues with signatures? Log this error then!
|
||||||
|
throw new ScriptError('CHECKSIGVERIFY_ERROR', e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user