7b86c9a08f
* Add progress on new deposits * Add deposited command to account manager * Remove old lcli::helpers mod * Clean clap_utils * Refactor lcli deposit contract commands to use IPC * Make testnet optional for environment * Use dbg formatting for deploy address * Add command to generate bootnode enr * Ensure lcli returns with 1 on error * Ensure account manager returns 1 on error * Disallow deposits to the zero address * Update web3 in eth1 crate * Ensure correct lighthouse dir is created * Reduce deposit gas requirement * Update cargo.lock * Add progress on new deposits * Add deposited command to account manager * Remove old lcli::helpers mod * Clean clap_utils * Refactor lcli deposit contract commands to use IPC * Add command to generate bootnode enr * Ensure lcli returns with 1 on error * Ensure account manager returns 1 on error * Update web3 in eth1 crate * Update Cargo.lock * Move lcli out of main install script * Change --limit to --at-least * Change --datadir to --validator-dir * Remove duplication in docs
32 lines
1.0 KiB
Rust
32 lines
1.0 KiB
Rust
use clap::ArgMatches;
|
|
use clap_utils::{parse_required, parse_ssz_required};
|
|
use deposit_contract::{decode_eth1_tx_data, DEPOSIT_DATA_LEN};
|
|
use tree_hash::TreeHash;
|
|
use types::EthSpec;
|
|
|
|
pub fn run<T: EthSpec>(matches: &ArgMatches) -> Result<(), String> {
|
|
let rlp_bytes = parse_ssz_required::<Vec<u8>>(matches, "deposit-data")?;
|
|
let amount = parse_required(matches, "deposit-amount")?;
|
|
|
|
if rlp_bytes.len() != DEPOSIT_DATA_LEN {
|
|
return Err(format!(
|
|
"The given deposit-data is {} bytes, expected {}",
|
|
rlp_bytes.len(),
|
|
DEPOSIT_DATA_LEN
|
|
));
|
|
}
|
|
|
|
let (deposit_data, root) = decode_eth1_tx_data(&rlp_bytes, amount)
|
|
.map_err(|e| format!("Invalid deposit data bytes: {:?}", e))?;
|
|
|
|
let expected_root = deposit_data.tree_hash_root();
|
|
if root != expected_root {
|
|
return Err(format!(
|
|
"Deposit data root is invalid. Expected {:?}, but got {:?}. Perhaps the amount is incorrect?",
|
|
expected_root, root
|
|
));
|
|
}
|
|
|
|
Ok(())
|
|
}
|