Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Citrea Client should be required #536

Open
mmtftr opened this issue Feb 14, 2025 · 0 comments
Open

Citrea Client should be required #536

mmtftr opened this issue Feb 14, 2025 · 0 comments

Comments

@mmtftr
Copy link

mmtftr commented Feb 14, 2025

Currently, we store an Option which is only used to verify things if it's present. Instead, we should verify its existence and fail unless we're in a test_mode state. The test_mode should likely be a config and should be validated so that it's impossible to run test_mode with network being mainnet

if let Some(citrea_client) = &self.citrea_client {
// See: https://gist.github.com/okkothejawa/a9379b02a16dada07a2b85cbbd3c1e80
let params = rpc_params![
json!({
"to": "0x3100000000000000000000000000000000000002",
"data": format!("0x471ba1e300000000000000000000000000000000000000000000000000000000{}",
hex::encode(withdrawal_index.to_be_bytes())),
}),
"latest"
];
let response: String = citrea_client.request("eth_call", params).await?;
let txid_response = &response[2..66];
let txid = hex::decode(txid_response).map_err(|e| BridgeError::Error(e.to_string()))?;
// txid.reverse(); // TODO: we should need to reverse this, test this with declareWithdrawalFiller
let txid = Txid::from_slice(&txid)?;
if txid != input_utxo.outpoint.txid || 0 != input_utxo.outpoint.vout {
// TODO: Fix this, vout can be different from 0 as well
return Err(BridgeError::InvalidInputUTXO(
txid,
input_utxo.outpoint.txid,
));
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant