psbt: Copy the PSET genesis blockhash
What changed, and why it matters
This commit fixes a bug where cloning or combining a special Bitcoin transaction format (PSET) dropped the 'genesis blockhash' field. Without that field, valid signatures could not be created for certain transactions using Elements taproot features. It is a correctness/data-loss bug rather than a direct theft-of-funds vulnerability, but it could cause signing failures or interoperability problems.
Treat as a bug fix with moderate operational-security relevance. Users relying on PSET cloning/combining for Elements taproot transactions should upgrade to ensure produced PSETs remain signable. Review whether any downstream workflows produced invalid PSETs that were rejected or could not be signed.
Security signals we found
Missing field copy in PSET clone/combine path
Affects Elements taproot signature hash computation
Could produce an unsignable or invalidly-signed PSET
No explicit bounds issue; memcpy uses fixed-size array
Conditional copy prevents overwriting an already-set value
Evidence from the diff
wally_psbt_clone_alloc() and wally_psbt_combine() failed to copy psbt->genesis_blockhash when handling PSETs under BUILD_ELEMENTS. The patch adds a conditional memcpy in psbt_combine() that copies src->genesis_blockhash into psbt only when the destination’s genesis_blockhash is all-zeroes. Because Elements taproot signature hashing includes the genesis blockhash, a cloned/combined PSET missing it becomes unsignable. The fix preserves an existing value during combine and always takes the source value during a clone (which starts with a zeroed blockhash).
Changed components
src/psbt.cwally_psbt_clone_alloc()wally_psbt_combine()PSET genesis blockhash handlingElements taproot signing pathInspect captured patch +3 / −0
### src/psbt.c
@@ -3962,6 +3962,9 @@ static int psbt_combine(struct wally_psbt *psbt, const struct wally_psbt *src,
#ifdef BUILD_ELEMENTS
if (ret == WALLY_OK && is_pset) {
psbt->pset_modifiable_flags |= src->pset_modifiable_flags;
+ if (mem_is_zero(psbt->genesis_blockhash, sizeof(psbt->genesis_blockhash)))
+ memcpy(psbt->genesis_blockhash, src->genesis_blockhash,
+ sizeof(psbt->genesis_blockhash));
ret = wally_map_combine(&psbt->global_scalars, &src->global_scalars);
}
#endif /* BUILD_ELEMENTS */Why this scored 44/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.