Skip to content

Commit b01981e

Browse files
committed
Merge pull request #6430
3361edd doc: Add NBitcoin to bitcoinconsensus examples (Braydon Fuller) b1bac4e Add description for bitcoinconsensus_ERR_OK (Braydon Fuller) c156ada doc: add documentation for shared library libbitcoinconsensus (Braydon Fuller)
2 parents ed789ce + 3361edd commit b01981e

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

doc/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ The Bitcoin repo's [root README](https://github.com/bitcoin/bitcoin/blob/master/
5858
- [Translation Strings Policy](translation_strings_policy.md)
5959
- [Unit Tests](unit-tests.md)
6060
- [Unauthenticated REST Interface](REST-interface.md)
61+
- [Shared Libraries](shared-libraries.md)
6162
- [BIPS](bips.md)
6263
- [Dnsseed Policy](dnsseed-policy.md)
6364

doc/shared-libraries.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Shared Libraries
2+
================
3+
4+
## bitcoinconsensus
5+
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.
7+
8+
### API
9+
10+
The interface is defined in the C header `bitcoinconsensus.h` located in `src/script/bitcoinconsensus.h`.
11+
12+
#### Version
13+
14+
`bitcoinconsensus_version` returns an `unsigned int` with the the API version *(currently at an experimental `0`)*.
15+
16+
#### Script Validation
17+
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`.
19+
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)*.
28+
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
33+
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`
39+
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)

0 commit comments

Comments
 (0)