Skip to content

Commit

Permalink
check transaction before broadcasting / accepting
Browse files Browse the repository at this point in the history
  • Loading branch information
HarukaMa committed Jan 30, 2024
1 parent 1d942fd commit e9922f9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions node/rest/src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,10 @@ impl<N: Network, C: ConsensusStorage<N>, R: Routing<N>> Rest<N, C, R> {
State(rest): State<Self>,
Json(tx): Json<Transaction<N>>,
) -> Result<ErasedJson, RestError> {
// Check if the transaction is well-formed.
rest.ledger.check_transaction_basic(&tx, None, &mut rand::thread_rng())
.map_err(|e| RestError(format!("Invalid transaction: {e}")))?;

// If the consensus module is enabled, add the unconfirmed transaction to the memory pool.
if let Some(consensus) = rest.consensus {
// Add the unconfirmed transaction to the memory pool.
Expand Down

0 comments on commit e9922f9

Please sign in to comment.