<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "BitcoinKernel",
  "identifier" : "/documentation/BitcoinKernel/ScriptPubkey",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "BitcoinKernel"
    ],
    "preciseIdentifier" : "s:13BitcoinKernel12ScriptPubkeyC"
  },
  "title" : "ScriptPubkey"
}
-->

# ScriptPubkey

A script pubkey — the locking script attached to a transaction
output, defining the conditions under which that output can be spent.

```
final class ScriptPubkey
```

## Overview

In Bitcoin, every output carries a scriptPubkey and a satoshi amount.
Common scriptPubkey patterns: P2PKH, P2SH, P2WPKH, P2WSH, P2TR. The
kernel treats the script as opaque bytes here — the semantic meaning
emerges at [`verify(amount:transaction:precomputedData:inputIndex:flags:)`](/documentation/BitcoinKernel/ScriptPubkey/verify(amount:transaction:precomputedData:inputIndex:flags:))
time, when script-interpreter flags (see [`ScriptVerificationFlags`](/documentation/BitcoinKernel/ScriptVerificationFlags))
determine which BIP-governed rules apply.

Wraps the opaque `btck_ScriptPubkey` type; `deinit` calls
`btck_script_pubkey_destroy` when the last Swift reference drops.