Skip to content

Commit 05c3903

Browse files
committed
elements: fix enable-elements-abi=no build
1 parent a445157 commit 05c3903

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

src/psbt.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4552,10 +4552,13 @@ static int get_signing_data(const struct wally_psbt *psbt,
45524552
if (utxo) {
45534553
/* Add items to maps without allocating/copying */
45544554
append_signing_data(scripts, i, utxo->script, utxo->script_len);
4555+
#ifdef BUILD_ELEMENTS
45554556
if (assets) {
45564557
append_signing_data(assets, i, utxo->asset, utxo->asset_len);
45574558
append_signing_data(values, i, utxo->value, utxo->value_len);
4558-
} else {
4559+
} else
4560+
#endif
4561+
{
45594562
append_signing_data(values, i, (unsigned char*)&utxo->satoshi,
45604563
sizeof(utxo->satoshi));
45614564
}
@@ -4612,7 +4615,11 @@ int wally_psbt_get_input_signature_hash(struct wally_psbt *psbt, size_t index,
46124615
&scripts, assets_p, &values,
46134616
script, script_len,
46144617
0, WALLY_NO_CODESEPARATOR, NULL, 0,
4618+
#ifdef BUILD_ELEMENTS
46154619
psbt->genesis_blockhash, sizeof(psbt->genesis_blockhash),
4620+
#else
4621+
NULL, 0,
4622+
#endif
46164623
sighash, sighash_type,
46174624
psbt->signing_cache, bytes_out, len);
46184625

src/tx_io.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,9 @@ static void txio_hash_tapleaf_hash(cursor_io *io,
564564
bool is_elements)
565565
{
566566
const struct wally_map_item *item;
567+
#ifndef BUILD_ELEMENTS
568+
(void)is_elements;
569+
#endif
567570
item = io->cache ? wally_map_get(io->cache, tapleaf_script, tapleaf_script_len) : NULL;
568571
if (item) {
569572
hash_bytes(&io->ctx, item->value, item->value_len);
@@ -594,6 +597,9 @@ static int legacy_signature_hash(
594597
const bool sh_none = (sighash & WALLY_SIGHASH_MASK) == WALLY_SIGHASH_NONE;
595598
const bool sh_single = (sighash & WALLY_SIGHASH_MASK) == WALLY_SIGHASH_SINGLE;
596599
cursor_io io;
600+
#ifndef BUILD_ELEMENTS
601+
(void)is_elements;
602+
#endif
597603

598604
/* Note that script can be empty, so we don't check it here */
599605
if (!tx || !values || BYTES_INVALID(script, script_len) ||
@@ -964,7 +970,6 @@ int wally_tx_get_input_signature_hash(
964970
{
965971
size_t is_elements = 0;
966972
uint32_t sighash_type = flags & WALLY_SIGTYPE_MASK;
967-
int ret = WALLY_EINVAL;
968973

969974
if (!tx || !tx->num_inputs || !tx->num_outputs || !values ||
970975
BYTES_INVALID(script, script_len) || key_version > 1 ||
@@ -974,11 +979,11 @@ int wally_tx_get_input_signature_hash(
974979
!flags || (flags & ~SIGTYPE_ALL) || !bytes_out || len != SHA256_LEN)
975980
return WALLY_EINVAL;
976981

977-
if ((ret = wally_tx_is_elements(tx, &is_elements)) != WALLY_OK)
978-
return ret;
979-
#ifndef BUILD_ELEMENTS
980-
if (is_elements)
982+
#ifdef BUILD_ELEMENTS
983+
if (wally_tx_is_elements(tx, &is_elements) != WALLY_OK)
981984
return WALLY_EINVAL;
985+
#else
986+
(void)is_elements;
982987
#endif
983988

984989
switch (sighash) {

0 commit comments

Comments
 (0)