Bugfix: depends/Travis: Use --location (follow redirects) and --fail [on HTTP error...
[bitcoinplatinum.git] / doc / shared-libraries.md
blobf4ff53d6e925948fc08eb55aff2fb7e713556dcd
1 Shared Libraries
2 ================
4 ## bitcoinconsensus
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.
8 ### API
10 The interface is defined in the C header `bitcoinconsensus.h` located in  `src/script/bitcoinconsensus.h`.
12 #### Version
14 `bitcoinconsensus_version` returns an `unsigned int` with the 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`.
20 ##### Parameters
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)*.
29 ##### Script Flags
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
34 ##### Errors
35 - `bitcoinconsensus_ERR_OK` - No errors with input parameters *(see the return value of `bitcoinconsensus_verify_script` for the verification status)*
36 - `bitcoinconsensus_ERR_TX_INDEX` - An invalid index for `txTo`
37 - `bitcoinconsensus_ERR_TX_SIZE_MISMATCH` - `txToLen` did not match with the size of `txTo`
38 - `bitcoinconsensus_ERR_DESERIALIZE` - An error deserializing `txTo`
40 ### Example Implementations
41 - [NBitcoin](https://github.com/NicolasDorier/NBitcoin/blob/master/NBitcoin/Script.cs#L814) (.NET Bindings)
42 - [node-libbitcoinconsensus](https://github.com/bitpay/node-libbitcoinconsensus) (Node.js Bindings)
43 - [java-libbitcoinconsensus](https://github.com/dexX7/java-libbitcoinconsensus) (Java Bindings)
44 - [bitcoinconsensus-php](https://github.com/Bit-Wasp/bitcoinconsensus-php) (PHP Bindings)