6 The purpose of this library is to make the verification functionality that is critical to Bitcoin's consensus available to other applications, e.g. to language bindings.
10 The interface is defined in the C header `bitcoinconsensus.h` located in `src/script/bitcoinconsensus.h`.
14 `bitcoinconsensus_version` returns an `unsigned int` with the API version *(currently at an experimental `0`)*.
16 #### Script Validation
18 `bitcoinconsensus_verify_script` returns an `int` with the status of the verification. It will be `1` if the input script correctly spends the previous output `scriptPubKey`.
21 - `const unsigned char *scriptPubKey` - The previous output script that encumbers spending.
22 - `unsigned int scriptPubKeyLen` - The number of bytes for the `scriptPubKey`.
23 - `const unsigned char *txTo` - The transaction with the input that is spending the previous output.
24 - `unsigned int txToLen` - The number of bytes for the `txTo`.
25 - `unsigned int nIn` - The index of the input in `txTo` that spends the `scriptPubKey`.
26 - `unsigned int flags` - The script validation flags *(see below)*.
27 - `bitcoinconsensus_error* err` - Will have the error/success code for the operation *(see below)*.
30 - `bitcoinconsensus_SCRIPT_FLAGS_VERIFY_NONE`
31 - `bitcoinconsensus_SCRIPT_FLAGS_VERIFY_P2SH` - Evaluate P2SH ([BIP16](https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki)) subscripts
32 - `bitcoinconsensus_SCRIPT_FLAGS_VERIFY_DERSIG` - Enforce strict DER ([BIP66](https://github.com/bitcoin/bips/blob/master/bip-0066.mediawiki)) compliance
33 - `bitcoinconsensus_SCRIPT_FLAGS_VERIFY_NULLDUMMY` - Enforce NULLDUMMY ([BIP147](https://github.com/bitcoin/bips/blob/master/bip-0147.mediawiki))
34 - `bitcoinconsensus_SCRIPT_FLAGS_VERIFY_CHECKLOCKTIMEVERIFY` - Enable CHECKLOCKTIMEVERIFY ([BIP65](https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki))
35 - `bitcoinconsensus_SCRIPT_FLAGS_VERIFY_CHECKSEQUENCEVERIFY` - Enable CHECKSEQUENCEVERIFY ([BIP112](https://github.com/bitcoin/bips/blob/master/bip-0112.mediawiki))
36 - `bitcoinconsensus_SCRIPT_FLAGS_VERIFY_WITNESS` - Enable WITNESS ([BIP141](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki))
39 - `bitcoinconsensus_ERR_OK` - No errors with input parameters *(see the return value of `bitcoinconsensus_verify_script` for the verification status)*
40 - `bitcoinconsensus_ERR_TX_INDEX` - An invalid index for `txTo`
41 - `bitcoinconsensus_ERR_TX_SIZE_MISMATCH` - `txToLen` did not match with the size of `txTo`
42 - `bitcoinconsensus_ERR_DESERIALIZE` - An error deserializing `txTo`
43 - `bitcoinconsensus_ERR_AMOUNT_REQUIRED` - Input amount is required if WITNESS is used
45 ### Example Implementations
46 - [NBitcoin](https://github.com/NicolasDorier/NBitcoin/blob/master/NBitcoin/Script.cs#L814) (.NET Bindings)
47 - [node-libbitcoinconsensus](https://github.com/bitpay/node-libbitcoinconsensus) (Node.js Bindings)
48 - [java-libbitcoinconsensus](https://github.com/dexX7/java-libbitcoinconsensus) (Java Bindings)
49 - [bitcoinconsensus-php](https://github.com/Bit-Wasp/bitcoinconsensus-php) (PHP Bindings)