[#ScriptCompression]
= ScriptCompression
:mrdocs:

Compact serializer for scripts&period;

== Synopsis

Declared in `&lt;compressor&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
struct ScriptCompression;
----

== Description

It detects common cases and encodes them much more efficiently&period; 3 special cases are defined&colon; &ast; Pay to pubkey hash (encoded as 21 bytes) &ast; Pay to script hash (encoded as 21 bytes) &ast; Pay to pubkey starting with 0x02, 0x03 or 0x04 (encoded as 33 bytes)

Other scripts up to 121 bytes require 1 byte &plus; script length&period; Above that, scripts up to 16505 bytes require 2 bytes &plus; script length&period;

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:ScriptCompression/Ser.adoc[`Ser`] 
| Serializes a script to the stream using the compact encoding&period;
| xref:ScriptCompression/Unser.adoc[`Unser`] 
| Deserializes a compact&hyphen;encoded script from the stream&period;
|===


== Static Data Members

[cols="1,4"]
|===
| Name| Description
| xref:ScriptCompression/nSpecialScripts.adoc[`nSpecialScripts`] 
| make this static for now (there are only 6 special scripts defined) this can potentially be extended together with a new version for transactions, in which case this value becomes dependent on version and nHeight of the enclosing transaction&period;
|===



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