[#btck_script_pubkey_verify]
= btck&lowbar;script&lowbar;pubkey&lowbar;verify
:mrdocs:

Verify if the input at input&lowbar;index of tx&lowbar;to spends the script pubkey under the constraints specified by flags&period; If the `btck&lowbar;ScriptVerificationFlags&lowbar;WITNESS` flag is set in the flags bitfield, the amount parameter is used&period; If the taproot flag is set, the precomputed data must contain the spent outputs&period;

== Synopsis

Declared in `&lt;kernel&sol;bitcoinkernel&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard, &lowbar;&lowbar;nonnull&lowbar;&lowbar;&rsqb;&rsqb;
int
btck&lowbar;script&lowbar;pubkey&lowbar;verify(
    xref:btck_ScriptPubkey-0e.adoc[btck&lowbar;ScriptPubkey] const* script&lowbar;pubkey,
    int64&lowbar;t amount,
    xref:btck_Transaction-08.adoc[btck&lowbar;Transaction] const* tx&lowbar;to,
    xref:btck_PrecomputedTransactionData-00.adoc[btck&lowbar;PrecomputedTransactionData] const* precomputed&lowbar;txdata,
    unsigned int input&lowbar;index,
    xref:btck_ScriptVerificationFlags.adoc[btck&lowbar;ScriptVerificationFlags] flags,
    xref:btck_ScriptVerifyStatus.adoc[btck&lowbar;ScriptVerifyStatus]* status);
----

== Return Value

1 if the script is valid, 0 otherwise&period;

[NOTE]
====
The return value https://en.cppreference.com/cpp/language/attributes/nodiscard[should not be discarded^].
====
== Parameters

[cols="1,4"]
|===
| Name| Description
| *script&lowbar;pubkey* [in]
| Non&hyphen;null, script pubkey to be spent&period;
| *amount* [in]
| Amount of the script pubkey&apos;s associated output&period; May be zero if the witness flag is not set&period;
| *tx&lowbar;to* [in]
| Non&hyphen;null, transaction spending the script&lowbar;pubkey&period;
| *precomputed&lowbar;txdata* [in]
| Nullable if the taproot flag is not set&period; Otherwise, precomputed data for tx&lowbar;to with the spent outputs must be provided&period;
| *input&lowbar;index* [in]
| Index of the input in tx&lowbar;to spending the script&lowbar;pubkey&period;
| *flags* [in]
| Bitfield of btck&lowbar;ScriptVerificationFlags controlling validation constraints&period;
| *status* [out]
| Nullable, will be set to an error code if the operation fails, or OK otherwise&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
