Skip to content

Commit 7e0df6a

Browse files
committed
[plan] Make placeholders satisfiable
Each satisfiable placeholder now has an `Option<_>` where the data needed to satisfy it can be inserted. This allows you satisfy the witness without using a `Satisfier` impl. I think it also makes for a simpler simpler API and internals. It probably needs some more work to take advantage of it.
1 parent c3ba4d3 commit 7e0df6a

File tree

6 files changed

+182
-217
lines changed

6 files changed

+182
-217
lines changed

src/descriptor/bare.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ impl Pkh<DefiniteDescriptorKey> {
311311
{
312312
if provider.lookup_ecdsa_sig(&self.pk) {
313313
let stack = vec![
314-
Placeholder::EcdsaSigPk(self.pk.clone()),
314+
Placeholder::EcdsaSigPk(self.pk.clone(), None),
315315
Placeholder::Pubkey(self.pk.clone(), BareCtx::pk_len(&self.pk)),
316316
];
317317
Some(Plan {

src/descriptor/segwitv0.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ impl Wpkh<DefiniteDescriptorKey> {
430430
{
431431
if provider.lookup_ecdsa_sig(&self.pk) {
432432
let stack = vec![
433-
Placeholder::EcdsaSigPk(self.pk.clone()),
433+
Placeholder::EcdsaSigPk(self.pk.clone(), None),
434434
Placeholder::Pubkey(self.pk.clone(), Segwitv0::pk_len(&self.pk)),
435435
];
436436
Some(Plan {

src/descriptor/tr.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,9 @@ impl<Pk: MiniscriptKey + ToPublicKey> Tr<Pk> {
319319
{
320320
let satisfaction =
321321
best_tap_spend(self, satisfier, false /* allow_mall */).map_stack(|stack| {
322-
WitnessTemplate::from_placeholder_stack(stack)
323-
.try_completing(satisfier)
322+
let mut wt = WitnessTemplate::from_placeholder_stack(stack);
323+
wt.satisfy(satisfier);
324+
wt.try_completing()
324325
.expect("the same satisfier should manage to complete the template")
325326
});
326327
if let Witness::Stack(stack) = satisfaction.stack {
@@ -339,8 +340,9 @@ impl<Pk: MiniscriptKey + ToPublicKey> Tr<Pk> {
339340
{
340341
let satisfaction =
341342
best_tap_spend(self, satisfier, true /* allow_mall */).map_stack(|stack| {
342-
WitnessTemplate::from_placeholder_stack(stack)
343-
.try_completing(satisfier)
343+
let mut wt = WitnessTemplate::from_placeholder_stack(stack);
344+
wt.satisfy(satisfier);
345+
wt.try_completing()
344346
.expect("the same satisfier should manage to complete the template")
345347
});
346348
if let Witness::Stack(stack) = satisfaction.stack {
@@ -661,6 +663,7 @@ where
661663
stack: Witness::Stack(vec![Placeholder::SchnorrSig(
662664
desc.internal_key.clone(),
663665
None,
666+
None,
664667
)]),
665668
has_sig: true,
666669
absolute_timelock: None,

0 commit comments

Comments
 (0)