MCPcopy Create free account
hub / github.com/BitVM/BitVM / new

Method new

bridge/src/client/client.rs:138–215  ·  view source on GitHub ↗
(
        esplora_url: Option<&str>,
        source_network: Network,
        destination_network: DestinationNetwork,
        chain_adaptor: Option<Box<dyn ChainAdaptor>>,
        n_of_n_public_keys:

Source from the content-addressed store, hash-verified

136impl BitVMClient {
137 #[allow(clippy::too_many_arguments)]
138 pub async fn new(
139 esplora_url: Option<&str>,
140 source_network: Network,
141 destination_network: DestinationNetwork,
142 chain_adaptor: Option<Box<dyn ChainAdaptor>>,
143 n_of_n_public_keys: &[PublicKey],
144 depositor_secret: Option<&str>,
145 operator_secret: Option<&str>,
146 verifier_secret: Option<&str>,
147 withdrawer_secret: Option<&str>,
148 file_path_prefix: Option<&str>,
149 zkproof_verifying_key: Option<ZkProofVerifyingKey>,
150 ) -> Self {
151 let depositor_context = depositor_secret
152 .map(|secret| DepositorContext::new(source_network, secret, n_of_n_public_keys));
153
154 let operator_context = operator_secret
155 .map(|secret| OperatorContext::new(source_network, secret, n_of_n_public_keys));
156
157 let verifier_context = verifier_secret
158 .map(|secret| VerifierContext::new(source_network, secret, n_of_n_public_keys));
159
160 let withdrawer_context = withdrawer_secret
161 .map(|secret| WithdrawerContext::new(source_network, secret, n_of_n_public_keys));
162
163 let (n_of_n_public_key, _) = generate_n_of_n_public_key(n_of_n_public_keys);
164
165 // NOTE: This path is used to save files in the remote data store (currently AWS S3).
166 // Although S3 implements a flat object storage model without true directories, it uses '/'
167 // as a delimiter to simulate a hierarchical directory structure. For this reason we use it
168 // explicitly in the format string below.
169 let remote_file_path = format! {"{BRIDGE_DATA_DIRECTORY_NAME}/{source_network}/{destination_network}/{n_of_n_public_key}"};
170 // The local file path, on the other hand, must use the platform specific path separator.
171 // Additionally, it includes the provided file path prefix to create a user namespace.
172 let local_file_path = Path::new(BRIDGE_DATA_DIRECTORY_NAME)
173 .join(file_path_prefix.unwrap_or(DEFAULT_PATH_PREFIX)) // TODO: Refactor to require a prefix and remove the const, as the client already has a default and will always pass it. Also rename to 'user_profile' to match the client implementation.
174 .join(source_network.to_string())
175 .join(destination_network.to_string())
176 .join(n_of_n_public_key.to_string());
177 println!("Using data file path: {}", local_file_path.display());
178
179 let data = BitVMClientPublicData {
180 version: 1,
181 peg_in_graphs: vec![],
182 peg_out_graphs: vec![],
183 };
184
185 let data_store = DataStore::new().await;
186
187 let private_data =
188 get_private_data_from_file(&get_private_data_file_path(&local_file_path));
189
190 Self {
191 esplora: Builder::new(esplora_url.unwrap_or(get_esplora_url(source_network)))
192 .build_async()
193 .expect("Could not build esplora client"),
194 source_network,
195

Callers

nothing calls this directly

Calls 4

get_esplora_urlFunction · 0.85

Tested by

no test coverage detected