@@ -112,6 +112,24 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
112112 return nullptr ;
113113 pblock = &pblocktemplate->block ; // pointer for convenience
114114
115+ std::vector<CScript> commitments;
116+
117+ // ELEMENTS: PAK
118+ // Create block pak commitment if set in conf file and validating pegouts
119+ if (!gArgs .GetBoolArg (" -acceptnonstdtxn" , !Params ().RequireStandard ())
120+ && g_paklist_config) {
121+ if (*g_paklist_config != g_paklist_blockchain) {
122+ g_paklist_config->CreateCommitments (commitments);
123+ }
124+ }
125+
126+ // Pad block weight to account for OP_RETURN commitments with two compressed pubkeys
127+ for (const auto & commitment : commitments) {
128+ CTxOut output (0 , commitment);
129+ nBlockWeight += ::GetSerializeSize (output, SER_NETWORK, PROTOCOL_VERSION)*WITNESS_SCALE_FACTOR;
130+ }
131+ // END PAK
132+
115133 // Add dummy coinbase tx as first transaction
116134 pblock->vtx .emplace_back ();
117135 pblocktemplate->vTxFees .push_back (-1 ); // updated at end
@@ -172,6 +190,12 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
172190 coinbaseTx.vout [0 ].scriptPubKey = scriptPubKeyIn;
173191 coinbaseTx.vout [0 ].nValue = nFees + GetBlockSubsidy (nHeight, chainparams.GetConsensus ());
174192 coinbaseTx.vin [0 ].scriptSig = CScript () << nHeight << OP_0;
193+ // ELEMENTS: PAK
194+ // Add PAK transition commitments
195+ for (unsigned int i = 0 ; i < commitments.size (); i++) {
196+ coinbaseTx.vout .push_back (CTxOut (0 , commitments[i]));
197+ }
198+ // END PAK
175199 pblock->vtx [0 ] = MakeTransactionRef (std::move (coinbaseTx));
176200 pblocktemplate->vchCoinbaseCommitment = GenerateCoinbaseCommitment (*pblock, pindexPrev, chainparams.GetConsensus ());
177201 pblocktemplate->vTxFees [0 ] = -nFees;
0 commit comments