From 05c3903d83ac7ed8bf03f54ca74b31f4187fe6d2 Mon Sep 17 00:00:00 2001 From: Jon Griffiths Date: Mon, 29 Sep 2025 12:23:17 +1300 Subject: [PATCH 1/2] elements: fix enable-elements-abi=no build --- src/psbt.c | 9 ++++++++- src/tx_io.c | 15 ++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/psbt.c b/src/psbt.c index 8e0ab3f82..d09800010 100644 --- a/src/psbt.c +++ b/src/psbt.c @@ -4552,10 +4552,13 @@ static int get_signing_data(const struct wally_psbt *psbt, if (utxo) { /* Add items to maps without allocating/copying */ append_signing_data(scripts, i, utxo->script, utxo->script_len); +#ifdef BUILD_ELEMENTS if (assets) { append_signing_data(assets, i, utxo->asset, utxo->asset_len); append_signing_data(values, i, utxo->value, utxo->value_len); - } else { + } else +#endif + { append_signing_data(values, i, (unsigned char*)&utxo->satoshi, sizeof(utxo->satoshi)); } @@ -4612,7 +4615,11 @@ int wally_psbt_get_input_signature_hash(struct wally_psbt *psbt, size_t index, &scripts, assets_p, &values, script, script_len, 0, WALLY_NO_CODESEPARATOR, NULL, 0, +#ifdef BUILD_ELEMENTS psbt->genesis_blockhash, sizeof(psbt->genesis_blockhash), +#else + NULL, 0, +#endif sighash, sighash_type, psbt->signing_cache, bytes_out, len); diff --git a/src/tx_io.c b/src/tx_io.c index edf19e158..77b49594c 100644 --- a/src/tx_io.c +++ b/src/tx_io.c @@ -564,6 +564,9 @@ static void txio_hash_tapleaf_hash(cursor_io *io, bool is_elements) { const struct wally_map_item *item; +#ifndef BUILD_ELEMENTS + (void)is_elements; +#endif item = io->cache ? wally_map_get(io->cache, tapleaf_script, tapleaf_script_len) : NULL; if (item) { hash_bytes(&io->ctx, item->value, item->value_len); @@ -594,6 +597,9 @@ static int legacy_signature_hash( const bool sh_none = (sighash & WALLY_SIGHASH_MASK) == WALLY_SIGHASH_NONE; const bool sh_single = (sighash & WALLY_SIGHASH_MASK) == WALLY_SIGHASH_SINGLE; cursor_io io; +#ifndef BUILD_ELEMENTS + (void)is_elements; +#endif /* Note that script can be empty, so we don't check it here */ if (!tx || !values || BYTES_INVALID(script, script_len) || @@ -964,7 +970,6 @@ int wally_tx_get_input_signature_hash( { size_t is_elements = 0; uint32_t sighash_type = flags & WALLY_SIGTYPE_MASK; - int ret = WALLY_EINVAL; if (!tx || !tx->num_inputs || !tx->num_outputs || !values || BYTES_INVALID(script, script_len) || key_version > 1 || @@ -974,11 +979,11 @@ int wally_tx_get_input_signature_hash( !flags || (flags & ~SIGTYPE_ALL) || !bytes_out || len != SHA256_LEN) return WALLY_EINVAL; - if ((ret = wally_tx_is_elements(tx, &is_elements)) != WALLY_OK) - return ret; -#ifndef BUILD_ELEMENTS - if (is_elements) +#ifdef BUILD_ELEMENTS + if (wally_tx_is_elements(tx, &is_elements) != WALLY_OK) return WALLY_EINVAL; +#else + (void)is_elements; #endif switch (sighash) { From ed29507aea6439264672edfcea684bad5e770504 Mon Sep 17 00:00:00 2001 From: Jon Griffiths Date: Mon, 29 Sep 2025 13:30:20 +1300 Subject: [PATCH 2/2] ci: add an enable-elements-abi=no build to prevent future breakage --- .gitlab-ci.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 497096a7b..19ed7b705 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -115,6 +115,17 @@ test_mingw_static_build: - CC=x86_64-w64-mingw32-gcc ./configure --host=x86_64-w64-mingw32 --disable-swig-python --disable-swig-java --disable-shared --enable-static - make -j $(($(grep ^processor /proc/cpuinfo | wc -l) / 2)) +test_no_elements_abi: + stage: test + image: greenaddress/wallycore@sha256:956b107d688f549c6e3884424991b7d3d34d84173990d43046fd760d7918db7c + tags: + - ga + artifacts: + script: + - ./tools/cleanup.sh && ./tools/autogen.sh + - CFLAGS='-Wall -W -Wextra -Werror' ./configure --disable-swig-python --disable-swig-java --disable-clear-tests --enable-elements=no --enable-elements-abi=no + - make -j $(($(grep ^processor /proc/cpuinfo | wc -l) / 2)) + build_wally_release_files: stage: release needs: [test_mingw_static_build,test_with_valgrind,test_asan_ubsan_gcc,test_scan_build_clang,test_cmake,test_amalgamation]