@dashevo/dashcore-lib
Advanced tools
Comparing version 0.20.5 to 0.20.6
@@ -10,2 +10,3 @@ /* eslint-disable */ | ||
var utils = require('../../util/js'); | ||
var BN = require('../../crypto/bn'); | ||
@@ -24,2 +25,5 @@ var isUnsignedInteger = utils.isUnsignedInteger; | ||
* @property {string} merkleRootQuorums | ||
* @property {number} bestCLHeight | ||
* @property {Buffer} bestCLSignature | ||
* @property {number} assetLockedAmount | ||
*/ | ||
@@ -33,2 +37,5 @@ | ||
* @property {string} merkleRootQuorums | ||
* @property {number} bestCLHeight | ||
* @property {Buffer} bestCLSignature | ||
* @property {number} assetLockedAmount | ||
*/ | ||
@@ -66,2 +73,8 @@ function CoinbasePayload() { | ||
if (payload.version >= 3) { | ||
payload.bestCLHeight = payloadBufferReader.readVarintNum(); | ||
payload.bestCLSignature = payloadBufferReader.read(96); | ||
payload.assetLockedAmount = payloadBufferReader.readUInt64LEBN(); | ||
} | ||
if (!payloadBufferReader.finished()) { | ||
@@ -91,2 +104,8 @@ throw new Error( | ||
if (payload.version >= 3) { | ||
payload.bestCLHeight = payloadJson.bestCLHeight; | ||
payload.bestCLSignature = Buffer.from(payloadJson.bestCLSignature, 'hex'); | ||
payload.assetLockedAmount = payloadJson.assetLockedAmount; | ||
} | ||
payload.validate(); | ||
@@ -131,2 +150,24 @@ return payload; | ||
} | ||
if (this.version >= 3) { | ||
Preconditions.checkArgument( | ||
isUnsignedInteger(this.bestCLHeight), | ||
'Expect bestCLHeight to be an unsigned integer' | ||
); | ||
Preconditions.checkArgument( | ||
Buffer.isBuffer(this.bestCLSignature), | ||
'Expect bestCLSignature to be a buffer' | ||
); | ||
Preconditions.checkArgument( | ||
this.bestCLSignature.length === 96, | ||
'Invalid bestCLSignature size' | ||
); | ||
Preconditions.checkArgument( | ||
BN.isBN(this.assetLockedAmount), | ||
'Expect assetLockedAmount to be an instance of BN' | ||
); | ||
Preconditions.checkArgument( | ||
isUnsignedInteger(this.assetLockedAmount.toNumber()), | ||
'Expect assetLockedAmount to be an unsigned integer' | ||
); | ||
} | ||
return true; | ||
@@ -149,2 +190,7 @@ }; | ||
} | ||
if (this.version >= 3) { | ||
json.bestCLHeight = this.bestCLHeight; | ||
json.bestCLSignature = this.bestCLSignature.toString('hex'); | ||
json.assetLockedAmount = this.assetLockedAmount; | ||
} | ||
return json; | ||
@@ -172,2 +218,8 @@ }; | ||
if (this.version >= 3) { | ||
payloadBufferWriter.writeVarintNum(this.bestCLHeight); | ||
payloadBufferWriter.write(this.bestCLSignature); | ||
payloadBufferWriter.writeUInt64LEBN(new BN(this.assetLockedAmount)); | ||
} | ||
return payloadBufferWriter.toBuffer(); | ||
@@ -174,0 +226,0 @@ }; |
{ | ||
"name": "@dashevo/dashcore-lib", | ||
"version": "0.20.5", | ||
"version": "0.20.6", | ||
"description": "A pure and powerful JavaScript Dash library.", | ||
@@ -5,0 +5,0 @@ "author": "Dash Core Group, Inc. <dev@dash.org>", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2740053
37432
8456