Skip to content

Commit

Permalink
format the XRPL fields instead of the message
Browse files Browse the repository at this point in the history
  • Loading branch information
themicp committed Feb 21, 2025
1 parent 13162b9 commit cc095af
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ampd/src/xrpl/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ pub fn verify_amount(amount: Amount, message: &XRPLUserMessage) -> bool {
}

pub fn verify_memos(memos: HashMap<String, String>, message: &XRPLUserMessage) -> bool {
let expected_destination_address = message.destination_address.to_string().to_uppercase();
let expected_destination_chain = hex::encode_upper(message.destination_chain.to_string());
let expected_destination_address = message.destination_address.to_string();
let expected_destination_chain = hex::encode(message.destination_chain.to_string());

let is_valid_payload_hash = match &message.payload_hash {
Some(expected_hash) => memos
Expand All @@ -133,8 +133,9 @@ pub fn verify_memos(memos: HashMap<String, String>, message: &XRPLUserMessage) -
None => !memos.contains_key("payload"),
};

memos.get("destination_address") == Some(&expected_destination_address)
&& memos.get("destination_chain") == Some(&expected_destination_chain)
memos.get("destination_address").map(|s| s.to_lowercase()) == Some(expected_destination_address)
&& memos.get("destination_chain").map(|s| s.to_lowercase())
== Some(expected_destination_chain)
&& is_valid_payload_hash
}

Expand Down

0 comments on commit cc095af

Please sign in to comment.