Skip to content

Commit

Permalink
[plan] Make placeholders satisfiable
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
LLFourn committed Nov 19, 2022
1 parent c3ba4d3 commit 7e0df6a
Show file tree
Hide file tree
Showing 6 changed files with 182 additions and 217 deletions.
2 changes: 1 addition & 1 deletion src/descriptor/bare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ impl Pkh<DefiniteDescriptorKey> {
{
if provider.lookup_ecdsa_sig(&self.pk) {
let stack = vec![
Placeholder::EcdsaSigPk(self.pk.clone()),
Placeholder::EcdsaSigPk(self.pk.clone(), None),
Placeholder::Pubkey(self.pk.clone(), BareCtx::pk_len(&self.pk)),
];
Some(Plan {
Expand Down
2 changes: 1 addition & 1 deletion src/descriptor/segwitv0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ impl Wpkh<DefiniteDescriptorKey> {
{
if provider.lookup_ecdsa_sig(&self.pk) {
let stack = vec![
Placeholder::EcdsaSigPk(self.pk.clone()),
Placeholder::EcdsaSigPk(self.pk.clone(), None),
Placeholder::Pubkey(self.pk.clone(), Segwitv0::pk_len(&self.pk)),
];
Some(Plan {
Expand Down
11 changes: 7 additions & 4 deletions src/descriptor/tr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,9 @@ impl<Pk: MiniscriptKey + ToPublicKey> Tr<Pk> {
{
let satisfaction =
best_tap_spend(self, satisfier, false /* allow_mall */).map_stack(|stack| {
WitnessTemplate::from_placeholder_stack(stack)
.try_completing(satisfier)
let mut wt = WitnessTemplate::from_placeholder_stack(stack);
wt.satisfy(satisfier);
wt.try_completing()
.expect("the same satisfier should manage to complete the template")
});
if let Witness::Stack(stack) = satisfaction.stack {
Expand All @@ -339,8 +340,9 @@ impl<Pk: MiniscriptKey + ToPublicKey> Tr<Pk> {
{
let satisfaction =
best_tap_spend(self, satisfier, true /* allow_mall */).map_stack(|stack| {
WitnessTemplate::from_placeholder_stack(stack)
.try_completing(satisfier)
let mut wt = WitnessTemplate::from_placeholder_stack(stack);
wt.satisfy(satisfier);
wt.try_completing()
.expect("the same satisfier should manage to complete the template")
});
if let Witness::Stack(stack) = satisfaction.stack {
Expand Down Expand Up @@ -661,6 +663,7 @@ where
stack: Witness::Stack(vec![Placeholder::SchnorrSig(
desc.internal_key.clone(),
None,
None,
)]),
has_sig: true,
absolute_timelock: None,
Expand Down
Loading

0 comments on commit 7e0df6a

Please sign in to comment.