Skip to content

Commit c03c8a4

Browse files
committed
Introduce SpendableOutputDescriptor::outpoint accessor
1 parent 86308e1 commit c03c8a4

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

lightning/src/sign/mod.rs

+9
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,15 @@ impl SpendableOutputDescriptor {
538538
};
539539
Ok((psbt, expected_max_weight))
540540
}
541+
542+
/// Returns the outpoint of the spendable output.
543+
pub fn outpoint(&self) -> OutPoint {
544+
match self {
545+
Self::StaticOutput { outpoint, .. } => *outpoint,
546+
Self::StaticPaymentOutput(descriptor) => descriptor.outpoint,
547+
Self::DelayedPaymentOutput(descriptor) => descriptor.outpoint,
548+
}
549+
}
541550
}
542551

543552
/// The parameters required to derive a channel signer via [`SignerProvider`].

lightning/src/util/sweep.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,7 @@ impl TrackedSpendableOutput {
7171

7272
/// Returns whether the output is spent in the given transaction.
7373
pub fn is_spent_in(&self, tx: &Transaction) -> bool {
74-
let prev_outpoint = match &self.descriptor {
75-
SpendableOutputDescriptor::StaticOutput { outpoint, .. } => *outpoint,
76-
SpendableOutputDescriptor::DelayedPaymentOutput(output) => output.outpoint,
77-
SpendableOutputDescriptor::StaticPaymentOutput(output) => output.outpoint,
78-
}
79-
.into_bitcoin_outpoint();
80-
74+
let prev_outpoint = self.descriptor.outpoint().into_bitcoin_outpoint();
8175
tx.input.iter().any(|input| input.previous_output == prev_outpoint)
8276
}
8377
}

0 commit comments

Comments
 (0)