Skip to content

Commit b9e69df

Browse files
committed
docs: correctly document all library constants and flags, other minor fixes
Constants and groups of constants (such as flags) are now are now linked in the generated API documentation.
1 parent d5d7508 commit b9e69df

15 files changed

+395
-386
lines changed

include/wally_address.h

+39-29
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ struct ext_key;
1616
#define WALLY_CA_PREFIX_LIQUID_REGTEST 0x04 /** Liquid v1 confidential address prefix for regtest */
1717
#define WALLY_CA_PREFIX_LIQUID_TESTNET 0x17 /** Liquid v1 confidential address prefix for testnet */
1818

19+
/*** address-networks Address network constants */
1920
#define WALLY_NETWORK_NONE 0x00 /** Used for miniscript parsing only */
2021
#define WALLY_NETWORK_BITCOIN_MAINNET 0x01 /** Bitcoin mainnet */
2122
#define WALLY_NETWORK_BITCOIN_REGTEST 0xff /** Bitcoin regtest: Behaves as testnet except for segwit */
@@ -28,6 +29,7 @@ struct ext_key;
2829
#define WALLY_ADDRESS_TYPE_P2SH_P2WPKH 0x02 /** P2SH-P2WPKH wrapped SegWit address ("3...") */
2930
#define WALLY_ADDRESS_TYPE_P2WPKH 0x04 /** P2WPKH native SegWit address ("bc1...)" */
3031

32+
/*** address-versions Address versions */
3133
#define WALLY_ADDRESS_VERSION_P2PKH_MAINNET 0x00 /** P2PKH address on mainnet */
3234
#define WALLY_ADDRESS_VERSION_P2PKH_TESTNET 0x6F /** P2PKH address on testnet */
3335
#define WALLY_ADDRESS_VERSION_P2PKH_LIQUID 0x39 /** P2PKH address on liquid v1 */
@@ -51,11 +53,12 @@ struct ext_key;
5153
* Create a segwit native address from a v0 or later witness program.
5254
*
5355
* :param bytes: Witness program bytes, including the version and data push opcode.
54-
* :param bytes_len: Length of ``bytes`` in bytes. Must be ``HASH160_LEN``
55-
*| or ``SHA256_LEN`` for v0 witness programs.
56+
* :param bytes_len: Length of ``bytes`` in bytes. Must be `HASH160_LEN`
57+
*| or `SHA256_LEN` for v0 witness programs.
5658
* :param addr_family: Address family to generate, e.g. "bc" or "tb".
5759
* :param flags: For future use. Must be 0.
5860
* :param output: Destination for the resulting segwit native address string.
61+
*| The string returned should be freed using `wally_free_string`.
5962
*/
6063
WALLY_CORE_API int wally_addr_segwit_from_bytes(
6164
const unsigned char *bytes,
@@ -130,10 +133,9 @@ WALLY_CORE_API int wally_addr_segwit_n_get_version(
130133
* Infer a scriptPubKey from an address.
131134
*
132135
* :param addr: Base58 encoded address to infer the scriptPubKey from.
133-
*| For confidential Liquid addresses first call :c:func:`wally_confidential_addr_to_addr`
134-
* :param network: One of ``WALLY_NETWORK_BITCOIN_MAINNET``, ``WALLY_NETWORK_BITCOIN_TESTNET``,
135-
*| ``WALLY_NETWORK_LIQUID``, ``WALLY_NETWORK_LIQUID_REGTEST``.
136-
* :param bytes_out: Destination for the resulting scriptPubKey
136+
*| For confidential Liquid addresses first call `wally_confidential_addr_to_addr`.
137+
* :param network: Network the address is for. One of the :ref:`address-networks`.
138+
* :param bytes_out: Destination for the resulting scriptPubKey.
137139
* MAX_SIZED_OUTPUT(len, bytes_out, WALLY_ADDRESS_PUBKEY_MAX_LEN)
138140
* :param written: Destination for the number of bytes written to ``bytes_out``.
139141
*/
@@ -145,14 +147,16 @@ WALLY_CORE_API int wally_address_to_scriptpubkey(
145147
size_t *written);
146148

147149
/**
148-
* Infer address from a scriptPubKey. For SegWit addresses, use `wally_addr_segwit_from_bytes`
149-
* instead. To find out if an address is SegWit, use `wally_scriptpubkey_get_type`.
150+
* Infer an address from a scriptPubKey.
150151
*
151152
* :param scriptpubkey: scriptPubKey bytes.
152153
* :param scriptpubkey_len: Length of ``scriptpubkey`` in bytes.
153-
* :param network: One of ``WALLY_NETWORK_BITCOIN_MAINNET``, ``WALLY_NETWORK_BITCOIN_TESTNET``,
154-
*| ``WALLY_NETWORK_LIQUID``, ``WALLY_NETWORK_LIQUID_REGTEST``.
154+
* :param network: Network to generate the address for. One of the :ref:`address-networks`.
155155
* :param output: Destination for the resulting Base58 encoded address string.
156+
*| The string returned should be freed using `wally_free_string`.
157+
*
158+
* For SegWit addresses, use `wally_addr_segwit_from_bytes` instead. To
159+
* determine if a scriptPubKey is SegWit, use `wally_scriptpubkey_get_type`.
156160
*/
157161
WALLY_CORE_API int wally_scriptpubkey_to_address(
158162
const unsigned char *scriptpubkey,
@@ -164,12 +168,13 @@ WALLY_CORE_API int wally_scriptpubkey_to_address(
164168
* Convert a private key to Wallet Import Format.
165169
*
166170
* :param priv_key: Private key bytes.
167-
* :param priv_key_len: The length of ``priv_key`` in bytes. Must be ``EC_PRIVATE_KEY_LEN``.
168-
* :param prefix: Expected prefix byte, e.g. ``WALLY_ADDRESS_VERSION_WIF_MAINNET``
169-
*| or ``WALLY_ADDRESS_VERSION_WIF_TESTNET``.
170-
* :param flags: Pass ``WALLY_WIF_FLAG_COMPRESSED`` if the corresponding pubkey is compressed,
171-
*| otherwise ``WALLY_WIF_FLAG_UNCOMPRESSED``.
171+
* :param priv_key_len: The length of ``priv_key`` in bytes. Must be `EC_PRIVATE_KEY_LEN`.
172+
* :param prefix: Expected prefix byte, e.g. `WALLY_ADDRESS_VERSION_WIF_MAINNET`
173+
*| or `WALLY_ADDRESS_VERSION_WIF_TESTNET`.
174+
* :param flags: Pass `WALLY_WIF_FLAG_COMPRESSED` if the corresponding pubkey is compressed,
175+
*| otherwise `WALLY_WIF_FLAG_UNCOMPRESSED`.
172176
* :param output: Destination for the resulting Wallet Import Format string.
177+
*| The string returned should be freed using `wally_free_string`.
173178
*/
174179
WALLY_CORE_API int wally_wif_from_bytes(
175180
const unsigned char *priv_key,
@@ -182,10 +187,10 @@ WALLY_CORE_API int wally_wif_from_bytes(
182187
* Convert a Wallet Import Format string to a private key.
183188
*
184189
* :param wif: Private key in Wallet Import Format.
185-
* :param prefix: Prefix byte to use, e.g. ``WALLY_ADDRESS_VERSION_WIF_MAINNET``
186-
*| or ``WALLY_ADDRESS_VERSION_WIF_TESTNET``.
187-
* :param flags: Pass ``WALLY_WIF_FLAG_COMPRESSED`` if the corresponding pubkey is compressed,
188-
*| otherwise ``WALLY_WIF_FLAG_UNCOMPRESSED``.
190+
* :param prefix: Prefix byte to use, e.g. `WALLY_ADDRESS_VERSION_WIF_MAINNET`
191+
*| or `WALLY_ADDRESS_VERSION_WIF_TESTNET`.
192+
* :param flags: Pass `WALLY_WIF_FLAG_COMPRESSED` if the corresponding pubkey is compressed,
193+
*| otherwise `WALLY_WIF_FLAG_UNCOMPRESSED`.
189194
* :param bytes_out: Destination for the private key.
190195
* FIXED_SIZED_OUTPUT(len, bytes_out, EC_PRIVATE_KEY_LEN)
191196
*/
@@ -210,7 +215,8 @@ WALLY_CORE_API int wally_wif_is_uncompressed(
210215
* Create a public key corresponding to a private key in Wallet Import Format.
211216
*
212217
* :param wif: Private key in Wallet Import Format.
213-
* :param prefix: Prefix byte to use, e.g. 0x80, 0xef.
218+
* :param prefix: Expected prefix byte, e.g. `WALLY_ADDRESS_VERSION_WIF_MAINNET`
219+
*| or `WALLY_ADDRESS_VERSION_WIF_TESTNET`.
214220
* :param bytes_out: Destination for the resulting public key.
215221
* :param len: The length of ``bytes_out``.
216222
* :param written: Destination for the number of bytes written to ``bytes_out``.
@@ -226,11 +232,11 @@ WALLY_CORE_API int wally_wif_to_public_key(
226232
* Create a legacy or wrapped SegWit address corresponding to a BIP32 key.
227233
*
228234
* :param hdkey: The extended key to use.
229-
* :param flags: ``WALLY_ADDRESS_TYPE_P2PKH`` for a legacy address, ``WALLY_ADDRESS_TYPE_P2SH_P2WPKH``
235+
* :param flags: `WALLY_ADDRESS_TYPE_P2PKH` for a legacy address, `WALLY_ADDRESS_TYPE_P2SH_P2WPKH`
230236
*| for P2SH-wrapped SegWit.
231-
* :param version: Version byte to generate address, e.g. with Bitcoin: ``WALLY_ADDRESS_VERSION_P2PKH_MAINNET``,
232-
*| ``WALLY_ADDRESS_VERSION_P2PKH_TESTNET``, ``WALLY_ADDRESS_VERSION_P2SH_MAINNET`` and ``WALLY_ADDRESS_VERSION_P2SH_TESTNET``.
237+
* :param version: Address version to generate. One of the :ref:`address-versions`.
233238
* :param output: Destination for the resulting address string.
239+
*| The string returned should be freed using `wally_free_string`.
234240
*/
235241
WALLY_CORE_API int wally_bip32_key_to_address(
236242
const struct ext_key *hdkey,
@@ -245,6 +251,7 @@ WALLY_CORE_API int wally_bip32_key_to_address(
245251
* :param addr_family: Address family to generate, e.g. "bc" or "tb".
246252
* :param flags: For future use. Must be 0.
247253
* :param output: Destination for the resulting segwit native address string.
254+
*| The string returned should be freed using `wally_free_string`.
248255
*/
249256
WALLY_CORE_API int wally_bip32_key_to_addr_segwit(
250257
const struct ext_key *hdkey,
@@ -257,8 +264,9 @@ WALLY_CORE_API int wally_bip32_key_to_addr_segwit(
257264
*
258265
* :param wif: Private key in Wallet Import Format.
259266
* :param prefix: Prefix byte to use, e.g. 0x80, 0xef.
260-
* :param version: Version byte to generate address, e.g. ``WALLY_ADDRESS_VERSION_P2PKH_MAINNET``, ``WALLY_ADDRESS_VERSION_P2PKH_TESTNET``.
267+
* :param version: Address version to generate. One of the :ref:`address-versions`.
261268
* :param output: Destination for the resulting address string.
269+
*| The string returned should be freed using `wally_free_string`.
262270
*/
263271
WALLY_CORE_API int wally_wif_to_address(
264272
const char *wif,
@@ -271,8 +279,9 @@ WALLY_CORE_API int wally_wif_to_address(
271279
* Extract the address from a confidential address.
272280
*
273281
* :param address: The base58 encoded confidential address to extract the address from.
274-
* :param prefix: The confidential address prefix byte, e.g. ``WALLY_CA_PREFIX_LIQUID``.
282+
* :param prefix: The confidential address prefix byte, e.g. `WALLY_CA_PREFIX_LIQUID`.
275283
* :param output: Destination for the resulting address string.
284+
*| The string returned should be freed using `wally_free_string`.
276285
*/
277286
WALLY_CORE_API int wally_confidential_addr_to_addr(
278287
const char *address,
@@ -283,7 +292,7 @@ WALLY_CORE_API int wally_confidential_addr_to_addr(
283292
* Extract the blinding public key from a confidential address.
284293
*
285294
* :param address: The base58 encoded confidential address to extract the public key from.
286-
* :param prefix: The confidential address prefix byte, e.g. ``WALLY_CA_PREFIX_LIQUID``.
295+
* :param prefix: The confidential address prefix byte, e.g. `WALLY_CA_PREFIX_LIQUID`.
287296
* :param bytes_out: Destination for the public key.
288297
* FIXED_SIZED_OUTPUT(len, bytes_out, EC_PUBLIC_KEY_LEN)
289298
*/
@@ -297,10 +306,11 @@ WALLY_CORE_API int wally_confidential_addr_to_ec_public_key(
297306
* Create a confidential address from an address and blinding public key.
298307
*
299308
* :param address: The base58 encoded address to make confidential.
300-
* :param prefix: The confidential address prefix byte, e.g. ``WALLY_CA_PREFIX_LIQUID``.
309+
* :param prefix: The confidential address prefix byte, e.g. `WALLY_CA_PREFIX_LIQUID`.
301310
* :param pub_key: The blinding public key to associate with ``address``.
302-
* :param pub_key_len: The length of ``pub_key`` in bytes. Must be ``EC_PUBLIC_KEY_LEN``.
311+
* :param pub_key_len: The length of ``pub_key`` in bytes. Must be `EC_PUBLIC_KEY_LEN`.
303312
* :param output: Destination for the resulting address string.
313+
*| The string returned should be freed using `wally_free_string`.
304314
*/
305315
WALLY_CORE_API int wally_confidential_addr_from_addr(
306316
const char *address,
@@ -345,7 +355,7 @@ WALLY_CORE_API int wally_confidential_addr_segwit_to_ec_public_key(
345355
* :param addr_family: The address family to generate.
346356
* :param confidential_addr_family: The confidential address family to generate.
347357
* :param pub_key: The blinding public key to associate with ``address``.
348-
* :param pub_key_len: The length of ``pub_key`` in bytes. Must be ``EC_PUBLIC_KEY_LEN``.
358+
* :param pub_key_len: The length of ``pub_key`` in bytes. Must be `EC_PUBLIC_KEY_LEN`.
349359
* :param output: Destination for the resulting address string.
350360
*| The string returned should be freed using `wally_free_string`.
351361
*/

include/wally_anti_exfil.h

+17-17
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ extern "C" {
2020
*| be revealed to the client until after the host has received the client
2121
*| commitment.
2222
* :param entropy_len: The length of ``entropy`` in bytes. Must be
23-
*| ``WALLY_S2C_DATA_LEN``.
24-
* :param flags: Must be ``EC_FLAG_ECDSA``.
23+
*| `WALLY_S2C_DATA_LEN`.
24+
* :param flags: Must be `EC_FLAG_ECDSA`.
2525
* :param bytes_out: Destination for the resulting compact signature.
2626
* FIXED_SIZED_OUTPUT(len, bytes_out, WALLY_HOST_COMMITMENT_LEN)
2727
*/
@@ -36,13 +36,13 @@ WALLY_CORE_API int wally_ae_host_commit_from_bytes(
3636
* Compute signer's original nonce.
3737
*
3838
* :param priv_key: The private key used for signing.
39-
* :param priv_key_len: The length of ``priv_key`` in bytes. Must be ``EC_PRIVATE_KEY_LEN``.
39+
* :param priv_key_len: The length of ``priv_key`` in bytes. Must be `EC_PRIVATE_KEY_LEN`.
4040
* :param bytes: The message hash to be signed.
41-
* :param bytes_len: The length of ``bytes`` in bytes. Must be ``EC_MESSAGE_HASH_LEN``.
41+
* :param bytes_len: The length of ``bytes`` in bytes. Must be `EC_MESSAGE_HASH_LEN`.
4242
* :param commitment: Randomness commitment from the host.
4343
* :param commitment_len: The length of ``commitment`` in bytes. Must be
44-
*| ``WALLY_HOST_COMMITMENT_LEN``.
45-
* :param flags: Must be ``EC_FLAG_ECDSA``.
44+
*| `WALLY_HOST_COMMITMENT_LEN`.
45+
* :param flags: Must be `EC_FLAG_ECDSA`.
4646
* :param s2c_opening_out: Destination for the resulting opening information.
4747
* FIXED_SIZED_OUTPUT(s2c_opening_out_len, s2c_opening_out, WALLY_S2C_OPENING_LEN)
4848
*/
@@ -58,15 +58,15 @@ WALLY_CORE_API int wally_ae_signer_commit_from_bytes(
5858
size_t s2c_opening_out_len);
5959

6060
/**
61-
* Same as ``wally_ec_sig_from_bytes``, but commits to the host randomness.
61+
* Same as `wally_ec_sig_from_bytes`, but commits to the host randomness.
6262
*
6363
* :param priv_key: The private key to sign with.
64-
* :param priv_key_len: The length of ``priv_key`` in bytes. Must be ``EC_PRIVATE_KEY_LEN``.
64+
* :param priv_key_len: The length of ``priv_key`` in bytes. Must be `EC_PRIVATE_KEY_LEN`.
6565
* :param bytes: The message hash to sign.
66-
* :param bytes_len: The length of ``bytes`` in bytes. Must be ``EC_MESSAGE_HASH_LEN``.
66+
* :param bytes_len: The length of ``bytes`` in bytes. Must be `EC_MESSAGE_HASH_LEN`.
6767
* :param entropy: Host provided randomness.
68-
* :param entropy_len: The length of ``entropy`` in bytes. Must be ``WALLY_S2C_DATA_LEN``.
69-
* :param flags: Must be ``EC_FLAG_ECDSA``.
68+
* :param entropy_len: The length of ``entropy`` in bytes. Must be `WALLY_S2C_DATA_LEN`.
69+
* :param flags: Must be `EC_FLAG_ECDSA`.
7070
* :param bytes_out: Destination for the resulting compact signature.
7171
* FIXED_SIZED_OUTPUT(len, bytes_out, EC_SIGNATURE_LEN)
7272
*/
@@ -85,17 +85,17 @@ WALLY_CORE_API int wally_ae_sig_from_bytes(
8585
* Verify a signature was correctly constructed using the Anti-Exfil Protocol.
8686
*
8787
* :param pub_key: The public key to verify with.
88-
* :param pub_key_len: The length of ``pub_key`` in bytes. Must be ``EC_PUBLIC_KEY_LEN``.
88+
* :param pub_key_len: The length of ``pub_key`` in bytes. Must be `EC_PUBLIC_KEY_LEN`.
8989
* :param bytes: The message hash to verify.
90-
* :param bytes_len: The length of ``bytes`` in bytes. Must be ``EC_MESSAGE_HASH_LEN``.
90+
* :param bytes_len: The length of ``bytes`` in bytes. Must be `EC_MESSAGE_HASH_LEN`.
9191
* :param entropy: Randomness provided by the host.
92-
* :param entropy_len: The length of ``entropy`` in bytes. Must be ``WALLY_S2C_DATA_LEN``.
92+
* :param entropy_len: The length of ``entropy`` in bytes. Must be `WALLY_S2C_DATA_LEN`.
9393
* :param s2c_opening: Opening information provided by the signer.
9494
* :param s2c_opening_len: The length of ``s2c_opening`` in bytes. Must be
95-
*| ``WALLY_S2C_OPENING_LEN``.
96-
* :param flags: Must be ``EC_FLAG_ECDSA``.
95+
*| `WALLY_S2C_OPENING_LEN`.
96+
* :param flags: Must be `EC_FLAG_ECDSA`.
9797
* :param sig: The compact signature of the message in ``bytes``.
98-
* :param sig_len: The length of ``sig`` in bytes. Must be ``EC_SIGNATURE_LEN``.
98+
* :param sig_len: The length of ``sig`` in bytes. Must be `EC_SIGNATURE_LEN`.
9999
*/
100100
WALLY_CORE_API int wally_ae_verify(
101101
const unsigned char *pub_key,

0 commit comments

Comments
 (0)