3.9/3.10. 3.9: Remove cast which fails on a several GB malicious TX

3.10 has its impossibility documented. A malicious RPC cananot effect this code.
This commit is contained in:
Luke Parker
2023-07-10 14:43:46 -04:00
parent fa1b569b78
commit 677b9b681f
2 changed files with 8 additions and 1 deletions

View File

@@ -137,11 +137,16 @@ impl Scanner {
pub fn scan_transaction(&self, tx: &Transaction) -> Vec<ReceivedOutput> {
let mut res = vec![];
for (vout, output) in tx.output.iter().enumerate() {
// If the vout index exceeds 2**32, stop scanning outputs
let Ok(vout) = u32::try_from(vout) else {
break
};
if let Some(offset) = self.scripts.get(&output.script_pubkey) {
res.push(ReceivedOutput {
offset: *offset,
output: output.clone(),
outpoint: OutPoint::new(tx.txid(), u32::try_from(vout).unwrap()),
outpoint: OutPoint::new(tx.txid(), vout),
});
}
}