From 7227257b903ae1324fd094e7382ef76f7f406f15 Mon Sep 17 00:00:00 2001 From: bitcoisas Date: Mon, 23 Nov 2026 14:30:09 -0300 Subject: [PATCH] psbt: require output taproot trees to be complete taproot_tree_value_verify() checked each leaf but not the tree as a whole, so leaves that don't form a complete binary tree were accepted, while Bitcoin Core rejects them. Track the depths waiting for a sibling and reject trees with a missing sibling, leaves after the tree is complete, or a leaf above an unfinished branch. Fixes #565. --- src/psbt.c | 20 ++++++++++++++++++-- src/test/test_psbt.py | 22 ++++++++++++++++++++-- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/psbt.c b/src/psbt.c index 1626b008d..dd09342d4 100644 --- a/src/psbt.c +++ b/src/psbt.c @@ -561,6 +561,10 @@ static int map_leaf_hashes_verify(const unsigned char *key, size_t key_len, * <8-bit depth> <8-bit leaf version>