Skip to content

Commit 9a57e00

Browse files
committed
Ensure there are no duplicated leaf hashes in tap_key_origins
1 parent 1bbd13b commit 9a57e00

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/psbt/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1234,6 +1234,14 @@ fn update_item_with_descriptor_helper<F: PsbtFields>(
12341234
}
12351235
}
12361236

1237+
// Ensure there are no duplicated leaf hashes. This can happen if some of them were
1238+
// already present in the map when this function is called, since this only appends new
1239+
// data to the psbt without checking what's already present.
1240+
for (tapleaf_hashes, _) in item.tap_key_origins().values_mut() {
1241+
tapleaf_hashes.sort();
1242+
tapleaf_hashes.dedup();
1243+
}
1244+
12371245
match item.tap_tree() {
12381246
// Only set the tap_tree if the item supports it (it's an output) and the descriptor actually
12391247
// contains one, otherwise it'll just be empty

0 commit comments

Comments
 (0)