@@ -16,6 +16,7 @@ struct ext_key;
16
16
#define WALLY_CA_PREFIX_LIQUID_REGTEST 0x04 /** Liquid v1 confidential address prefix for regtest */
17
17
#define WALLY_CA_PREFIX_LIQUID_TESTNET 0x17 /** Liquid v1 confidential address prefix for testnet */
18
18
19
+ /*** address-networks Address network constants */
19
20
#define WALLY_NETWORK_NONE 0x00 /** Used for miniscript parsing only */
20
21
#define WALLY_NETWORK_BITCOIN_MAINNET 0x01 /** Bitcoin mainnet */
21
22
#define WALLY_NETWORK_BITCOIN_REGTEST 0xff /** Bitcoin regtest: Behaves as testnet except for segwit */
@@ -28,6 +29,7 @@ struct ext_key;
28
29
#define WALLY_ADDRESS_TYPE_P2SH_P2WPKH 0x02 /** P2SH-P2WPKH wrapped SegWit address ("3...") */
29
30
#define WALLY_ADDRESS_TYPE_P2WPKH 0x04 /** P2WPKH native SegWit address ("bc1...)" */
30
31
32
+ /*** address-versions Address versions */
31
33
#define WALLY_ADDRESS_VERSION_P2PKH_MAINNET 0x00 /** P2PKH address on mainnet */
32
34
#define WALLY_ADDRESS_VERSION_P2PKH_TESTNET 0x6F /** P2PKH address on testnet */
33
35
#define WALLY_ADDRESS_VERSION_P2PKH_LIQUID 0x39 /** P2PKH address on liquid v1 */
@@ -51,11 +53,12 @@ struct ext_key;
51
53
* Create a segwit native address from a v0 or later witness program.
52
54
*
53
55
* :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.
56
58
* :param addr_family: Address family to generate, e.g. "bc" or "tb".
57
59
* :param flags: For future use. Must be 0.
58
60
* :param output: Destination for the resulting segwit native address string.
61
+ *| The string returned should be freed using `wally_free_string`.
59
62
*/
60
63
WALLY_CORE_API int wally_addr_segwit_from_bytes (
61
64
const unsigned char * bytes ,
@@ -130,10 +133,9 @@ WALLY_CORE_API int wally_addr_segwit_n_get_version(
130
133
* Infer a scriptPubKey from an address.
131
134
*
132
135
* :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.
137
139
* MAX_SIZED_OUTPUT(len, bytes_out, WALLY_ADDRESS_PUBKEY_MAX_LEN)
138
140
* :param written: Destination for the number of bytes written to ``bytes_out``.
139
141
*/
@@ -145,14 +147,16 @@ WALLY_CORE_API int wally_address_to_scriptpubkey(
145
147
size_t * written );
146
148
147
149
/**
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.
150
151
*
151
152
* :param scriptpubkey: scriptPubKey bytes.
152
153
* :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`.
155
155
* :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`.
156
160
*/
157
161
WALLY_CORE_API int wally_scriptpubkey_to_address (
158
162
const unsigned char * scriptpubkey ,
@@ -164,12 +168,13 @@ WALLY_CORE_API int wally_scriptpubkey_to_address(
164
168
* Convert a private key to Wallet Import Format.
165
169
*
166
170
* :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`.
172
176
* :param output: Destination for the resulting Wallet Import Format string.
177
+ *| The string returned should be freed using `wally_free_string`.
173
178
*/
174
179
WALLY_CORE_API int wally_wif_from_bytes (
175
180
const unsigned char * priv_key ,
@@ -182,10 +187,10 @@ WALLY_CORE_API int wally_wif_from_bytes(
182
187
* Convert a Wallet Import Format string to a private key.
183
188
*
184
189
* :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`.
189
194
* :param bytes_out: Destination for the private key.
190
195
* FIXED_SIZED_OUTPUT(len, bytes_out, EC_PRIVATE_KEY_LEN)
191
196
*/
@@ -210,7 +215,8 @@ WALLY_CORE_API int wally_wif_is_uncompressed(
210
215
* Create a public key corresponding to a private key in Wallet Import Format.
211
216
*
212
217
* :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`.
214
220
* :param bytes_out: Destination for the resulting public key.
215
221
* :param len: The length of ``bytes_out``.
216
222
* :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(
226
232
* Create a legacy or wrapped SegWit address corresponding to a BIP32 key.
227
233
*
228
234
* :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`
230
236
*| 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`.
233
238
* :param output: Destination for the resulting address string.
239
+ *| The string returned should be freed using `wally_free_string`.
234
240
*/
235
241
WALLY_CORE_API int wally_bip32_key_to_address (
236
242
const struct ext_key * hdkey ,
@@ -245,6 +251,7 @@ WALLY_CORE_API int wally_bip32_key_to_address(
245
251
* :param addr_family: Address family to generate, e.g. "bc" or "tb".
246
252
* :param flags: For future use. Must be 0.
247
253
* :param output: Destination for the resulting segwit native address string.
254
+ *| The string returned should be freed using `wally_free_string`.
248
255
*/
249
256
WALLY_CORE_API int wally_bip32_key_to_addr_segwit (
250
257
const struct ext_key * hdkey ,
@@ -257,8 +264,9 @@ WALLY_CORE_API int wally_bip32_key_to_addr_segwit(
257
264
*
258
265
* :param wif: Private key in Wallet Import Format.
259
266
* :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 `.
261
268
* :param output: Destination for the resulting address string.
269
+ *| The string returned should be freed using `wally_free_string`.
262
270
*/
263
271
WALLY_CORE_API int wally_wif_to_address (
264
272
const char * wif ,
@@ -271,8 +279,9 @@ WALLY_CORE_API int wally_wif_to_address(
271
279
* Extract the address from a confidential address.
272
280
*
273
281
* :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`.
275
283
* :param output: Destination for the resulting address string.
284
+ *| The string returned should be freed using `wally_free_string`.
276
285
*/
277
286
WALLY_CORE_API int wally_confidential_addr_to_addr (
278
287
const char * address ,
@@ -283,7 +292,7 @@ WALLY_CORE_API int wally_confidential_addr_to_addr(
283
292
* Extract the blinding public key from a confidential address.
284
293
*
285
294
* :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`.
287
296
* :param bytes_out: Destination for the public key.
288
297
* FIXED_SIZED_OUTPUT(len, bytes_out, EC_PUBLIC_KEY_LEN)
289
298
*/
@@ -297,10 +306,11 @@ WALLY_CORE_API int wally_confidential_addr_to_ec_public_key(
297
306
* Create a confidential address from an address and blinding public key.
298
307
*
299
308
* :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`.
301
310
* :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`.
303
312
* :param output: Destination for the resulting address string.
313
+ *| The string returned should be freed using `wally_free_string`.
304
314
*/
305
315
WALLY_CORE_API int wally_confidential_addr_from_addr (
306
316
const char * address ,
@@ -345,7 +355,7 @@ WALLY_CORE_API int wally_confidential_addr_segwit_to_ec_public_key(
345
355
* :param addr_family: The address family to generate.
346
356
* :param confidential_addr_family: The confidential address family to generate.
347
357
* :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`.
349
359
* :param output: Destination for the resulting address string.
350
360
*| The string returned should be freed using `wally_free_string`.
351
361
*/
0 commit comments