Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSBT/PSET updates #336

Merged
merged 14 commits into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,31 @@

## Version 0.8.6
- Support for PSET v0 (Elements) has been removed.
- PSBT: PSBT v2 support has been added and the ABI has changed slightly as a result.
- PSBT: PSBT/PSET v2 support has been added. The ABI has changed slightly as a result.
Users will need to recompile their applications and change function names and
arguments in the cases listed below:
- PSBT_PROPRIETARY_TYPE has been renamed to WALLY_PSBT_PROPRIETARY_TYPE to respect
wallys namespace.
- psbt_init_alloc has changed its definition and now has a new flags argument.
Passing `WALLY_PSBT_INIT_PSET` to this function will create an Elements
PSET instead of a PSBT (version must be passed as 2 in this case).
- psbt_from_base64 and psbt_from_bytes now take an extra flags parameter. The
Java and Python wrappers default this to zero for backwards compatibility.
- psbt_add_input_at has been renamed to psbt_add_tx_input_at.
- psbt_add_output_at has been renamed to psbt_add_tx_output_at.
- wally_map initialization functions now take a verification function
as an extra parameter.
- New functions wally_map_keypath_bip32_init_alloc and
wally_map_keypath_public_key_init_alloc for initializing BIP32 and public key
keypath maps have been added.
- wally_map_add_keypath_item has been renamed to wally_map_keypath_add.
This call must only be made on a keypath initialized map.
- The input and output variants wally_psbt_input_add_keypath_item and
wally_psbt_output_add_keypath_item have also been renamed to
wally_psbt_input_keypath_add and wally_psbt_output_keypath_add.
- New functions wally_map_keypath_bip32_init_alloc and
wally_map_keypath_public_key_init_alloc for initializing BIP32 and public key
keypath maps have been added.
- Note that PSET support for issuance and peg-in is incomplete at this time and
may contain bugs. Users are strongly advised to test their code thoroughly
if using these features.

## Version 0.8.2

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ installed.
For non-development use, you can install wally with `pip` as follows:

```
pip install wallycore==0.8.5
pip install wallycore==0.8.6
```

For python development, you can build and install wally using:
Expand All @@ -130,7 +130,7 @@ You can also install the binary [wally releases](https://github.com/ElementsProj
using the released wheel files without having to compile the library, e.g.:

```
pip install wallycore-0.8.5-cp39-cp39m-linux_x86_64.whl
pip install wallycore-0.8.6-cp39-cp39m-linux_x86_64.whl
```

The script `tools/build_python_manylinux_wheels.sh` builds the Linux release files
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AC_PREREQ([2.60])
AC_INIT([libwallycore],[0.8.5])
AC_INIT([libwallycore],[0.8.6])
AC_CONFIG_AUX_DIR([tools/build-aux])
AC_CONFIG_MACRO_DIR([tools/build-aux/m4])
AC_CONFIG_SRCDIR([src/mnemonic.h])
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def extract_docs(infile, outfile):
# built documents.
#
# The short X.Y version.
version = u'0.8.5'
version = u'0.8.6'
# The full version, including alpha/beta/rc tags.
release = version

Expand Down
92 changes: 88 additions & 4 deletions include/wally.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -857,14 +857,14 @@ inline int psbt_free(struct wally_psbt* psbt) {
}

template <class BASE64>
inline int psbt_from_base64(const BASE64& base64, struct wally_psbt** output) {
int ret = ::wally_psbt_from_base64(detail::get_p(base64), output);
inline int psbt_from_base64(const BASE64& base64, uint32_t flags, struct wally_psbt** output) {
int ret = ::wally_psbt_from_base64(detail::get_p(base64), flags, output);
return ret;
}

template <class BYTES>
inline int psbt_from_bytes(const BYTES& bytes, struct wally_psbt** output) {
int ret = ::wally_psbt_from_bytes(bytes.data(), bytes.size(), output);
inline int psbt_from_bytes(const BYTES& bytes, uint32_t flags, struct wally_psbt** output) {
int ret = ::wally_psbt_from_bytes(bytes.data(), bytes.size(), flags, output);
return ret;
}

Expand Down Expand Up @@ -1881,6 +1881,21 @@ inline int psbt_find_global_scalar(const PSBT& psbt, const SCALAR& scalar, size_
return written || ret != WALLY_OK ? ret : n == static_cast<size_t>(scalar.size()) ? WALLY_OK : WALLY_EINVAL;
}

inline int psbt_input_clear_amount_rangeproof(struct wally_psbt_input* input) {
int ret = ::wally_psbt_input_clear_amount_rangeproof(input);
return ret;
}

inline int psbt_input_clear_asset(struct wally_psbt_input* input) {
int ret = ::wally_psbt_input_clear_asset(input);
return ret;
}

inline int psbt_input_clear_asset_surjectionproof(struct wally_psbt_input* input) {
int ret = ::wally_psbt_input_clear_asset_surjectionproof(input);
return ret;
}

inline int psbt_input_clear_inflation_keys_blinding_rangeproof(struct wally_psbt_input* input) {
int ret = ::wally_psbt_input_clear_inflation_keys_blinding_rangeproof(input);
return ret;
Expand Down Expand Up @@ -1941,6 +1956,51 @@ inline int psbt_input_clear_utxo_rangeproof(struct wally_psbt_input* input) {
return ret;
}

template <class INPUT, class ASSET, class ABF, class VBF, class ENTROPY>
inline int psbt_input_generate_explicit_proofs(const INPUT& input, uint64_t satoshi, const ASSET& asset, const ABF& abf, const VBF& vbf, const ENTROPY& entropy) {
int ret = ::wally_psbt_input_generate_explicit_proofs(detail::get_p(input), satoshi, asset.data(), asset.size(), abf.data(), abf.size(), vbf.data(), vbf.size(), entropy.data(), entropy.size());
return ret;
}

template <class INPUT, class BYTES_OUT>
inline int psbt_input_get_amount_rangeproof(const INPUT& input, BYTES_OUT& bytes_out, size_t* written = 0) {
size_t n;
int ret = ::wally_psbt_input_get_amount_rangeproof(detail::get_p(input), bytes_out.data(), bytes_out.size(), written ? written : &n);
return written || ret != WALLY_OK ? ret : n == static_cast<size_t>(bytes_out.size()) ? WALLY_OK : WALLY_EINVAL;
}

template <class INPUT>
inline int psbt_input_get_amount_rangeproof_len(const INPUT& input, size_t* written) {
int ret = ::wally_psbt_input_get_amount_rangeproof_len(detail::get_p(input), written);
return ret;
}

template <class INPUT, class BYTES_OUT>
inline int psbt_input_get_asset(const INPUT& input, BYTES_OUT& bytes_out, size_t* written = 0) {
size_t n;
int ret = ::wally_psbt_input_get_asset(detail::get_p(input), bytes_out.data(), bytes_out.size(), written ? written : &n);
return written || ret != WALLY_OK ? ret : n == static_cast<size_t>(bytes_out.size()) ? WALLY_OK : WALLY_EINVAL;
}

template <class INPUT>
inline int psbt_input_get_asset_len(const INPUT& input, size_t* written) {
int ret = ::wally_psbt_input_get_asset_len(detail::get_p(input), written);
return ret;
}

template <class INPUT, class BYTES_OUT>
inline int psbt_input_get_asset_surjectionproof(const INPUT& input, BYTES_OUT& bytes_out, size_t* written = 0) {
size_t n;
int ret = ::wally_psbt_input_get_asset_surjectionproof(detail::get_p(input), bytes_out.data(), bytes_out.size(), written ? written : &n);
return written || ret != WALLY_OK ? ret : n == static_cast<size_t>(bytes_out.size()) ? WALLY_OK : WALLY_EINVAL;
}

template <class INPUT>
inline int psbt_input_get_asset_surjectionproof_len(const INPUT& input, size_t* written) {
int ret = ::wally_psbt_input_get_asset_surjectionproof_len(detail::get_p(input), written);
return ret;
}

template <class INPUT, class BYTES_OUT>
inline int psbt_input_get_inflation_keys_blinding_rangeproof(const INPUT& input, BYTES_OUT& bytes_out, size_t* written = 0) {
size_t n;
Expand Down Expand Up @@ -2097,6 +2157,30 @@ inline int psbt_input_get_utxo_rangeproof_len(const INPUT& input, size_t* writte
return ret;
}

template <class INPUT>
inline int psbt_input_set_amount(const INPUT& input, uint64_t amount) {
int ret = ::wally_psbt_input_set_amount(detail::get_p(input), amount);
return ret;
}

template <class INPUT, class RANGEPROOF>
inline int psbt_input_set_amount_rangeproof(const INPUT& input, const RANGEPROOF& rangeproof) {
int ret = ::wally_psbt_input_set_amount_rangeproof(detail::get_p(input), rangeproof.data(), rangeproof.size());
return ret;
}

template <class INPUT, class ASSET>
inline int psbt_input_set_asset(const INPUT& input, const ASSET& asset) {
int ret = ::wally_psbt_input_set_asset(detail::get_p(input), asset.data(), asset.size());
return ret;
}

template <class INPUT, class SURJECTIONPROOF>
inline int psbt_input_set_asset_surjectionproof(const INPUT& input, const SURJECTIONPROOF& surjectionproof) {
int ret = ::wally_psbt_input_set_asset_surjectionproof(detail::get_p(input), surjectionproof.data(), surjectionproof.size());
return ret;
}

template <class INPUT>
inline int psbt_input_set_inflation_keys(const INPUT& input, uint64_t value) {
int ret = ::wally_psbt_input_set_inflation_keys(detail::get_p(input), value);
Expand Down
4 changes: 2 additions & 2 deletions include/wally_bip32.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ WALLY_CORE_API int bip32_key_init_alloc(
*| ``BIP32_ENTROPY_LEN_256`` or ``BIP32_ENTROPY_LEN_512``.
* :param version: Either ``BIP32_VER_MAIN_PRIVATE`` or ``BIP32_VER_TEST_PRIVATE``,
*| indicating mainnet or testnet/regtest respectively.
* :param hmac_key: Custom data to HMAC-SHA512 with `bytes` before creating the key. Pass
* :param hmac_key: Custom data to HMAC-SHA512 with ``bytes`` before creating the key. Pass
*| NULL to use the default BIP32 key of "Bitcoin seed".
* :param hmac_key_len: Size of ``hmac_key`` in bytes, or 0 if ``hmac_key`` is NULL.
* :param flags: Either ``BIP32_FLAG_SKIP_HASH`` to skip hash160 calculation, or 0.
Expand Down Expand Up @@ -433,7 +433,7 @@ WALLY_CORE_API int bip32_key_from_base58_n_alloc(
* keys can be derived, and only the public serialization can be created.
* If the provided key is already public, nothing will be done.
*
* :param hdkey: The extended key to covert.
* :param hdkey: The extended key to convert.
*/
WALLY_CORE_API int bip32_key_strip_private_key(
struct ext_key *hdkey);
Expand Down
2 changes: 1 addition & 1 deletion include/wally_crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ WALLY_CORE_API int wally_format_bitcoin_message(
* :param bytes_out: Destination for the shared secret.
* :param len: The length of ``bytes_out`` in bytes. Must be ``SHA256_LEN``.
*
* .. note:: If `priv_key` is invalid, this call returns ``WALLY_ERROR``.
* .. note:: If ``priv_key`` is invalid, this call returns ``WALLY_ERROR``.
*/
WALLY_CORE_API int wally_ecdh(
const unsigned char *pub_key,
Expand Down
2 changes: 1 addition & 1 deletion include/wally_elements.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ WALLY_CORE_API int wally_asset_unblind(
* Generate a master blinding key from a seed as specified in SLIP-0077.
*
* :param bytes: Seed value. See :c:func:`bip39_mnemonic_to_seed`.
* :param bytes_len: Length of ``seed``. Must be one of ``BIP32_ENTROPY_LEN_128``, ``BIP32_ENTROPY_LEN_256`` or
* :param bytes_len: Length of ``bytes``. Must be one of ``BIP32_ENTROPY_LEN_128``, ``BIP32_ENTROPY_LEN_256`` or
*| ``BIP32_ENTROPY_LEN_512``.
* :param bytes_out: Buffer to receive master blinding key. The master blinding key can be used to generate blinding
*| keys for specific outputs by passing it to `wally_asset_blinding_key_to_ec_private_key`.
Expand Down
Loading