`update_claims_view_from_requests` assumes that any
`PackageTemplate`s passed to it will not be aggregated (i.e. have
only one input) and uses that assumption when skipping duplicates.
This is currently true, but dropping `PackateTemplate` claims
entirely based on only the first input is somewhat brittle so we
add a debug assertion here and update the logic to not spuriously
drop claims if they happen to come into the `OnChainTxHandler`
pre-aggregated.
// First drop any claims which are duplicate
requests.retain(|req| {
- if self.claimable_outpoints.get(req.outpoints()[0]).is_some() {
+ debug_assert_eq!(
+ req.outpoints().len(),
+ 1,
+ "Claims passed to `update_claims_view_from_requests` should not be aggregated"
+ );
+ let mut all_outpoints_claiming = true;
+ for outpoint in req.outpoints() {
+ if self.claimable_outpoints.get(&outpoint).is_none() {
+ all_outpoints_claiming = false;
+ }
+ }
+ if all_outpoints_claiming {
log_info!(logger, "Ignoring second claim for outpoint {}:{}, already registered its claiming request", req.outpoints()[0].txid, req.outpoints()[0].vout);
false
} else {