Skip to content

Commit 169e489

Browse files
committed
Fix compilation of pk()-only policies into tr() descriptors
1 parent 286fa88 commit 169e489

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/policy/concrete.rs

+15-4
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,13 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
247247
.expect("compiler produces sane output");
248248
leaf_compilations.push((OrdF64(prob), compilation));
249249
}
250-
let tap_tree = with_huffman_tree::<Pk>(leaf_compilations).unwrap();
251-
Some(tap_tree)
250+
if !leaf_compilations.is_empty() {
251+
let tap_tree = with_huffman_tree::<Pk>(leaf_compilations).unwrap();
252+
Some(tap_tree)
253+
} else {
254+
// no policies remaining once the extracted key is skipped
255+
None
256+
}
252257
}
253258
},
254259
)
@@ -303,8 +308,14 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
303308
)
304309
})
305310
.collect();
306-
let tap_tree = with_huffman_tree::<Pk>(leaf_compilations).unwrap();
307-
Some(tap_tree)
311+
312+
if !leaf_compilations.is_empty() {
313+
let tap_tree = with_huffman_tree::<Pk>(leaf_compilations).unwrap();
314+
Some(tap_tree)
315+
} else {
316+
// no policies remaining once the extracted key is skipped
317+
None
318+
}
308319
}
309320
},
310321
)?;

0 commit comments

Comments
 (0)