Skip to content

Commit 45fc1c1

Browse files
committed
wollet: include dummy spent in spent() computation
1 parent 855bcb7 commit 45fc1c1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lwk_wollet/src/cache.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,23 @@ impl Cache {
166166
}
167167

168168
pub fn spent(&self) -> Result<HashSet<OutPoint>, Error> {
169+
// Dummy spent outputs are outputs that are not in height map, but we have to consider them
170+
// for the utxo mode.
171+
let dummy_spent: Vec<OutPoint> = self
172+
.all_txs
173+
.iter()
174+
.filter(|(_, tx)| tx.output.is_empty()) // Only dummy tx have no outputs
175+
.map(|(_, tx)| tx.input.iter().map(|i| i.previous_output))
176+
.flatten()
177+
.collect();
178+
169179
Ok(self
170180
.heights
171181
.keys()
172182
.filter_map(|txid| self.all_txs.get(txid))
173183
.flat_map(|tx| tx.input.iter())
174184
.map(|i| i.previous_output)
185+
.chain(dummy_spent)
175186
.collect())
176187
}
177188
}

0 commit comments

Comments
 (0)