[#btck_script_pubkey_to_bytes]
= btck&lowbar;script&lowbar;pubkey&lowbar;to&lowbar;bytes
:mrdocs:

Serializes the script pubkey through the passed in callback to bytes&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;to&lowbar;bytes(
    xref:btck_ScriptPubkey-0e.adoc[btck&lowbar;ScriptPubkey] const* script&lowbar;pubkey,
    xref:btck_WriteBytes.adoc[btck&lowbar;WriteBytes] writer,
    void* user&lowbar;data);
----

== Return Value

0 on success&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&period;
| *writer* [in]
| Non&hyphen;null, callback to a write bytes function&period;
| *user&lowbar;data* [in]
| Holds a user&hyphen;defined opaque structure that will be passed back through the writer callback&period;
|===


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