MCPcopy Create free account
hub / github.com/CashScript/cashscript / verifyFullTransaction

Function verifyFullTransaction

packages/cashscript/src/debugging.ts:373–391  ·  view source on GitHub ↗
(template: WalletTemplate)

Source from the content-addressed store, hash-verified

371// After debugging, we want to verify the full transaction to ensure it is valid (this catches any errors that are not
372// necessarily script errors)
373const verifyFullTransaction = (template: WalletTemplate): void => {
374 const placeholderScriptId = Object.keys(template.scripts).find((key) => 'unlocks' in template.scripts[key]);
375 const placeholderScenarioId = (template.scripts[placeholderScriptId ?? ''] as WalletTemplateScriptUnlocking)?.passes?.[0];
376
377 if (!placeholderScenarioId || !placeholderScriptId) {
378 throw new Error('No placeholder scenario ID or script ID found');
379 }
380
381 const { vm, program } = createProgram(template, placeholderScriptId, placeholderScenarioId);
382
383 const verificationResult = vm.verify({
384 sourceOutputs: program.sourceOutputs,
385 transaction: program.transaction,
386 });
387
388 if (typeof verificationResult === 'string') {
389 throw new FailedTransactionError(verificationResult, getBitauthUri(template));
390 }
391};
392
393const isSignatureCheckWithoutVerify = (instruction: AuthenticationInstruction): boolean => {
394 return [Op.OP_CHECKSIG, Op.OP_CHECKMULTISIG, Op.OP_CHECKDATASIG].includes(instruction.opcode);

Callers 1

debugTemplateFunction · 0.85

Calls 2

createProgramFunction · 0.85
getBitauthUriFunction · 0.85

Tested by

no test coverage detected