You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

shared-libraries.md 3.1KB

5 vuotta sitten
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. Shared Libraries
  2. ================
  3. ## bitcoinconsensus
  4. 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.
  5. ### API
  6. The interface is defined in the C header `bitcoinconsensus.h` located in `src/script/bitcoinconsensus.h`.
  7. #### Version
  8. `bitcoinconsensus_version` returns an `unsigned int` with the API version *(currently at an experimental `0`)*.
  9. #### Script Validation
  10. `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`.
  11. ##### Parameters
  12. - `const unsigned char *scriptPubKey` - The previous output script that encumbers spending.
  13. - `unsigned int scriptPubKeyLen` - The number of bytes for the `scriptPubKey`.
  14. - `const unsigned char *txTo` - The transaction with the input that is spending the previous output.
  15. - `unsigned int txToLen` - The number of bytes for the `txTo`.
  16. - `unsigned int nIn` - The index of the input in `txTo` that spends the `scriptPubKey`.
  17. - `unsigned int flags` - The script validation flags *(see below)*.
  18. - `bitcoinconsensus_error* err` - Will have the error/success code for the operation *(see below)*.
  19. ##### Script Flags
  20. - `bitcoinconsensus_SCRIPT_FLAGS_VERIFY_NONE`
  21. - `bitcoinconsensus_SCRIPT_FLAGS_VERIFY_P2SH` - Evaluate P2SH ([BIP16](https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki)) subscripts
  22. - `bitcoinconsensus_SCRIPT_FLAGS_VERIFY_DERSIG` - Enforce strict DER ([BIP66](https://github.com/bitcoin/bips/blob/master/bip-0066.mediawiki)) compliance
  23. - `bitcoinconsensus_SCRIPT_FLAGS_VERIFY_NULLDUMMY` - Enforce NULLDUMMY ([BIP147](https://github.com/bitcoin/bips/blob/master/bip-0147.mediawiki))
  24. - `bitcoinconsensus_SCRIPT_FLAGS_VERIFY_CHECKLOCKTIMEVERIFY` - Enable CHECKLOCKTIMEVERIFY ([BIP65](https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki))
  25. - `bitcoinconsensus_SCRIPT_FLAGS_VERIFY_CHECKSEQUENCEVERIFY` - Enable CHECKSEQUENCEVERIFY ([BIP112](https://github.com/bitcoin/bips/blob/master/bip-0112.mediawiki))
  26. - `bitcoinconsensus_SCRIPT_FLAGS_VERIFY_WITNESS` - Enable WITNESS ([BIP141](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki))
  27. ##### Errors
  28. - `bitcoinconsensus_ERR_OK` - No errors with input parameters *(see the return value of `bitcoinconsensus_verify_script` for the verification status)*
  29. - `bitcoinconsensus_ERR_TX_INDEX` - An invalid index for `txTo`
  30. - `bitcoinconsensus_ERR_TX_SIZE_MISMATCH` - `txToLen` did not match with the size of `txTo`
  31. - `bitcoinconsensus_ERR_DESERIALIZE` - An error deserializing `txTo`
  32. - `bitcoinconsensus_ERR_AMOUNT_REQUIRED` - Input amount is required if WITNESS is used
  33. ### Example Implementations
  34. - [NBitcoin](https://github.com/NicolasDorier/NBitcoin/blob/master/NBitcoin/Script.cs#L814) (.NET Bindings)
  35. - [node-libbitcoinconsensus](https://github.com/bitpay/node-libbitcoinconsensus) (Node.js Bindings)
  36. - [java-libbitcoinconsensus](https://github.com/dexX7/java-libbitcoinconsensus) (Java Bindings)
  37. - [bitcoinconsensus-php](https://github.com/Bit-Wasp/bitcoinconsensus-php) (PHP Bindings)