(common_args: CommonArgs)
| 36 | |
| 37 | impl ClientCommand { |
| 38 | pub async fn new(common_args: CommonArgs) -> Self { |
| 39 | let (source_network, destination_network) = match common_args.environment.as_deref() { |
| 40 | Some("mainnet") => (Network::Bitcoin, DestinationNetwork::Ethereum), |
| 41 | Some("testnet") => (Network::Testnet, DestinationNetwork::EthereumSepolia), |
| 42 | Some("regtest") => (Network::Regtest, DestinationNetwork::Local), |
| 43 | _ => { |
| 44 | eprintln!("Invalid environment. Use mainnet, testnet or regtest."); |
| 45 | std::process::exit(1); |
| 46 | } |
| 47 | }; |
| 48 | |
| 49 | let keys_command = KeysCommand::new(common_args.key_dir); |
| 50 | let config = keys_command |
| 51 | .read_config() |
| 52 | .expect("Failed to read config file"); |
| 53 | |
| 54 | let n_of_n_public_keys = common_args.verifiers.expect("Error: Verifier public keys must be specified either in command line or environment variable."); |
| 55 | |
| 56 | let mut verifying_key = None; |
| 57 | if let Some(vk) = config.keys.verifying_key.clone() { |
| 58 | let bytes = Vec::<u8>::from_hex(&vk).unwrap(); |
| 59 | verifying_key = Some(ZkProofVerifyingKey::deserialize_compressed(&*bytes).unwrap()); |
| 60 | } |
| 61 | |
| 62 | let bitvm_client = BitVMClient::new( |
| 63 | Some(get_esplora_url(source_network)), |
| 64 | source_network, |
| 65 | destination_network, |
| 66 | Some(get_chain_adaptor(DestinationNetwork::Local, None, None)), // TODO: Will be replaced with a destination network specific adaptor once Ethereum support is added. |
| 67 | &n_of_n_public_keys, |
| 68 | config.keys.depositor.as_deref(), |
| 69 | config.keys.operator.as_deref(), |
| 70 | config.keys.verifier.as_deref(), |
| 71 | config.keys.withdrawer.as_deref(), |
| 72 | common_args.path_prefix.as_deref(), |
| 73 | verifying_key, |
| 74 | ) |
| 75 | .await; |
| 76 | |
| 77 | Self { |
| 78 | client: bitvm_client, |
| 79 | config, |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | async fn get_funding_utxo_input(&self, utxo_arg: Option<&String>) -> io::Result<Input> { |
| 84 | let utxo = utxo_arg.expect("Missing UTXO argument, please see help."); |
nothing calls this directly
no test coverage detected