Skip to content

Commit d7dafc9

Browse files
committed
f Verify we retrieve expected transaction
1 parent 68c75dd commit d7dafc9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lightning-transaction-sync/src/esplora.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,15 +342,19 @@ where
342342
// unwrap() safety: len() > 0 is checked above
343343
let pos = *indexes.first().unwrap() as usize;
344344
if let Some(tx) = maybe_await!(self.client.get_tx(&txid))? {
345-
let txid = tx.txid();
345+
if tx.txid() != *txid {
346+
log_error!(self.logger, "Retrieved transaction for txid {} doesn't match expectations. This should not happen. Please verify server integrity.", txid);
347+
return Err(InternalError::Failed);
348+
}
349+
346350
if let Some(block_height) = known_block_height {
347351
// We can take a shortcut here if a previous call already gave us the height.
348-
return Ok(Some(ConfirmedTx { tx, txid, block_header, pos, block_height }));
352+
return Ok(Some(ConfirmedTx { tx, txid: *txid, block_header, pos, block_height }));
349353
}
350354

351355
let block_status = maybe_await!(self.client.get_block_status(&block_hash))?;
352356
if let Some(block_height) = block_status.height {
353-
return Ok(Some(ConfirmedTx { tx, txid, block_header, pos, block_height }));
357+
return Ok(Some(ConfirmedTx { tx, txid: *txid, block_header, pos, block_height }));
354358
} else {
355359
// If any previously-confirmed block suddenly is no longer confirmed, we found
356360
// an inconsistency and should start over.

0 commit comments

Comments
 (0)