@@ -18,6 +18,7 @@ var CURRENT_PAYLOAD_VERSION = 1;
18
18
* @property {number } qfcVersion uint16_t 2 Version of the final commitment message
19
19
* @property {number } llmqtype uint8_t 1 type of the long living masternode quorum
20
20
* @property {string } quorumHash uint256 32 The quorum identifier
21
+ * @property {number } quorumIndex int16 2 The quorum index
21
22
* @property {number } signersSize compactSize uint 1-9 Bit size of the signers bitvector
22
23
* @property {string } signers byte[] (bitSize + 7) / 8 Bitset representing the aggregated signers of this final commitment
23
24
* @property {number } validMembersSize compactSize uint 1-9 Bit size of the validMembers bitvector
@@ -35,6 +36,7 @@ var CURRENT_PAYLOAD_VERSION = 1;
35
36
* @property {number } qfcVersion
36
37
* @property {number } llmqtype
37
38
* @property {string } quorumHash
39
+ * @property {number } quorumIndex
38
40
* @property {number } signersSize
39
41
* @property {string } signers
40
42
* @property {number } validMembersSize
@@ -54,6 +56,7 @@ function CommitmentTxPayload(options) {
54
56
this . qfcVersion = options . qfcVersion ;
55
57
this . llmqtype = options . llmqtype ;
56
58
this . quorumHash = options . quorumHash ;
59
+ this . quorumIndex = options . quorumIndex ;
57
60
this . signers = options . signers ;
58
61
this . validMembers = options . validMembers ;
59
62
this . quorumPublicKey = options . quorumPublicKey ;
@@ -84,6 +87,10 @@ CommitmentTxPayload.fromBuffer = function fromBuffer(rawPayload) {
84
87
. read ( constants . SHA256_HASH_SIZE )
85
88
. toString ( 'hex' ) ;
86
89
90
+ if ( payload . version >= constants . HASH_QUORUM_INDEX_REQUIRED_VERSION ) {
91
+ payload . quorumIndex = payloadBufferReader . readInt16LE ( ) ;
92
+ }
93
+
87
94
payload . signersSize = payloadBufferReader . readVarintNum ( ) ;
88
95
var signersBytesToRead = Math . floor ( ( payload . signersSize + 7 ) / 8 ) || 1 ;
89
96
payload . signers = payloadBufferReader
@@ -157,6 +164,14 @@ CommitmentTxPayload.prototype.validate = function () {
157
164
utils . isHexaString ( this . quorumHash ) ,
158
165
'Expect quorumHash to be a hex string'
159
166
) ;
167
+
168
+ if ( this . version >= constants . HASH_QUORUM_INDEX_REQUIRED_VERSION ) {
169
+ Preconditions . checkArgument (
170
+ Number . isInteger ( this . quorumIndex ) ,
171
+ 'Expect quorumHash to be an integer'
172
+ ) ;
173
+ }
174
+
160
175
Preconditions . checkArgument (
161
176
utils . isHexaString ( this . signers ) ,
162
177
'Expect signers to be a hex string'
@@ -206,6 +221,10 @@ CommitmentTxPayload.prototype.toJSON = function toJSON(options) {
206
221
sig : this . sig ,
207
222
} ;
208
223
224
+ if ( this . version >= constants . HASH_QUORUM_INDEX_REQUIRED_VERSION ) {
225
+ payloadJSON . quorumIndex = this . quorumIndex ;
226
+ }
227
+
209
228
return payloadJSON ;
210
229
} ;
211
230
@@ -226,7 +245,13 @@ CommitmentTxPayload.prototype.toBuffer = function toBuffer(options) {
226
245
. writeUInt32LE ( this . height )
227
246
. writeUInt16LE ( this . qfcVersion )
228
247
. writeUInt8 ( this . llmqtype )
229
- . write ( Buffer . from ( this . quorumHash , 'hex' ) )
248
+ . write ( Buffer . from ( this . quorumHash , 'hex' ) ) ;
249
+
250
+ if ( this . version >= constants . HASH_QUORUM_INDEX_REQUIRED_VERSION ) {
251
+ payloadBufferWriter . writeInt16LE ( this . quorumIndex ) ;
252
+ }
253
+
254
+ payloadBufferWriter
230
255
. writeVarintNum ( this . signersSize )
231
256
. write ( Buffer . from ( this . signers , 'hex' ) )
232
257
. writeVarintNum ( this . validMembersSize )
0 commit comments