File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -125,11 +125,19 @@ impl<Pk: MiniscriptKey> Tr<Pk> {
125
125
/// This data is needed to compute the Taproot output, so this method is implicitly
126
126
/// called through [`Self::script_pubkey`], [`Self::address`], etc. It is also needed
127
127
/// to compute the hash needed to sign the output.
128
- pub fn spend_info(&self) -> TrSpendInfo<Pk>
128
+ pub fn spend_info(&self) -> Arc< TrSpendInfo<Pk> >
129
129
where
130
130
Pk: ToPublicKey,
131
131
{
132
- TrSpendInfo::from_tr(self)
132
+ let mut lock = self.spend_info.lock().unwrap();
133
+ match *lock {
134
+ Some(ref res) => Arc::clone(res),
135
+ None => {
136
+ let arc = Arc::new(TrSpendInfo::from_tr(self));
137
+ *lock = Some(Arc::clone(&arc));
138
+ arc
139
+ }
140
+ }
133
141
}
134
142
135
143
/// Checks whether the descriptor is safe.
You can’t perform that action at this time.
0 commit comments