diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/handlers.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/handlers.rs b/src/handlers.rs index ead6828..a5070a4 100644 --- a/src/handlers.rs +++ b/src/handlers.rs | |||
@@ -656,14 +656,17 @@ pub async fn propose_transaction( | |||
656 | // this transaction was already checked for correctness at custom_filters, we can panic here if | 656 | // this transaction was already checked for correctness at custom_filters, we can panic here if |
657 | // it has been changed since | 657 | // it has been changed since |
658 | 658 | ||
659 | let hashed_transaction = | 659 | let serd_tx = serde_json::to_string(&new_transaction).unwrap(); |
660 | Md5::digest((&serde_json::to_string(&new_transaction).unwrap()).as_ref()); | 660 | |
661 | debug!("Taking the hash of {}", serd_tx); | ||
662 | |||
663 | let hashed_transaction = Md5::digest(&serd_tx.as_bytes()); | ||
661 | if token_payload.claims.tha != format!("{:x}", hashed_transaction) { | 664 | if token_payload.claims.tha != format!("{:x}", hashed_transaction) { |
662 | debug!("The hash of the transaction did not match with the hash given in JWT"); | ||
663 | return Ok(warp::reply::with_status( | 665 | return Ok(warp::reply::with_status( |
664 | warp::reply::json(&GradeCoinResponse { | 666 | warp::reply::json(&GradeCoinResponse { |
665 | res: ResponseType::Error, | 667 | res: ResponseType::Error, |
666 | message: "The hash of the transaction did not match the hash given in JWT".to_owned(), | 668 | message: "The hash of the transaction did not match the hash given in JWT" |
669 | .to_owned(), | ||
667 | }), | 670 | }), |
668 | StatusCode::BAD_REQUEST, | 671 | StatusCode::BAD_REQUEST, |
669 | )); | 672 | )); |