MCPcopy Create free account
hub / github.com/ElementsProject/elements / copyOutput

Function copyOutput

src/simplicity/elements/env.c:248–259  ·  view source on GitHub ↗

Initialize a 'sigOutput' from a 'rawElementsOutput', copying or hashing the data as needed. * * '*allocation' is incremented by 'countNullDataCodes(&output->scriptPubKey)' * '*allocationLen' is decremented by 'countNullDataCodes(&output->scriptPubKey)'. * Values in the '*allocation' array may be modified. * * Precondition: NULL != result; * NULL != *allocation; *

Source from the content-addressed store, hash-verified

246 * countNullDataCodes(&output->scriptPubKey) <= *allocationLen
247 */
248static void copyOutput(sigOutput* result, opcode** allocation, size_t* allocationLen, const rawElementsOutput* output) {
249 hashBuffer(&result->scriptPubKey, &output->scriptPubKey);
250 result->emptyScript = 0 == output->scriptPubKey.len;
251 copyRawConfidential(&result->asset, output->asset);
252 copyRawAmt(&result->amt, output->value);
253 copyRawConfidential(&result->nonce, output->nonce);
254 parseNullData(&result->pnd, allocation, allocationLen, &output->scriptPubKey);
255 result->isNullData = NULL != result->pnd.op;
256 hashBuffer(&result->surjectionProofHash, is_confidential(result->asset.prefix) ? &output->surjectionProof : &(rawElementsBuffer){0});
257 hashBuffer(&result->rangeProofHash, is_confidential(result->amt.prefix) ? &output->rangeProof : &(rawElementsBuffer){0});
258 result->assetFee = 0;
259}
260
261/* Tally a sorted list of feeOutputs
262 *

Callers 1

Calls 5

copyRawConfidentialFunction · 0.85
copyRawAmtFunction · 0.85
parseNullDataFunction · 0.85
is_confidentialFunction · 0.85
hashBufferFunction · 0.70

Tested by

no test coverage detected