From 83c4154fd03f309b29a54b222bbbce83ab265b4a Mon Sep 17 00:00:00 2001 From: Leonardo Lima Date: Sat, 15 Jun 2024 01:51:08 -0300 Subject: [PATCH] feat: use tor connector when bulding client --- Cargo.lock | 36 ++++++++++++++++++------------------ Cargo.toml | 16 ++++++++-------- justfile | 2 +- src/core.rs | 3 ++- src/fedimint_client.rs | 5 ++++- 5 files changed, 33 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4ba2447..e63394e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2182,7 +2182,7 @@ dependencies = [ [[package]] name = "fedimint-aead" version = "0.4.0-alpha" -source = "git+https://github.com/oleonardolima/fedimint/?branch=feat/add-mvp-tor-support-connection-to-hostnames#dfc19a42769f95c283400c1fd6f3b6657e74734c" +source = "git+https://github.com/oleonardolima/fedimint/?rev=2b54c1cbbec42499c805862724496f45006393db#2b54c1cbbec42499c805862724496f45006393db" dependencies = [ "anyhow", "argon2", @@ -2194,7 +2194,7 @@ dependencies = [ [[package]] name = "fedimint-api-client" version = "0.4.0-alpha" -source = "git+https://github.com/oleonardolima/fedimint/?branch=feat/add-mvp-tor-support-connection-to-hostnames#dfc19a42769f95c283400c1fd6f3b6657e74734c" +source = "git+https://github.com/oleonardolima/fedimint/?rev=2b54c1cbbec42499c805862724496f45006393db#2b54c1cbbec42499c805862724496f45006393db" dependencies = [ "anyhow", "arti-client", @@ -2227,7 +2227,7 @@ dependencies = [ [[package]] name = "fedimint-bip39" version = "0.4.0-alpha" -source = "git+https://github.com/oleonardolima/fedimint/?branch=feat/add-mvp-tor-support-connection-to-hostnames#dfc19a42769f95c283400c1fd6f3b6657e74734c" +source = "git+https://github.com/oleonardolima/fedimint/?rev=2b54c1cbbec42499c805862724496f45006393db#2b54c1cbbec42499c805862724496f45006393db" dependencies = [ "bip39", "fedimint-client", @@ -2238,7 +2238,7 @@ dependencies = [ [[package]] name = "fedimint-bitcoind" version = "0.4.0-alpha" -source = "git+https://github.com/oleonardolima/fedimint/?branch=feat/add-mvp-tor-support-connection-to-hostnames#dfc19a42769f95c283400c1fd6f3b6657e74734c" +source = "git+https://github.com/oleonardolima/fedimint/?rev=2b54c1cbbec42499c805862724496f45006393db#2b54c1cbbec42499c805862724496f45006393db" dependencies = [ "anyhow", "async-trait", @@ -2259,7 +2259,7 @@ dependencies = [ [[package]] name = "fedimint-build" version = "0.4.0-alpha" -source = "git+https://github.com/oleonardolima/fedimint/?branch=feat/add-mvp-tor-support-connection-to-hostnames#dfc19a42769f95c283400c1fd6f3b6657e74734c" +source = "git+https://github.com/oleonardolima/fedimint/?rev=2b54c1cbbec42499c805862724496f45006393db#2b54c1cbbec42499c805862724496f45006393db" dependencies = [ "serde_json", ] @@ -2267,7 +2267,7 @@ dependencies = [ [[package]] name = "fedimint-client" version = "0.4.0-alpha" -source = "git+https://github.com/oleonardolima/fedimint/?branch=feat/add-mvp-tor-support-connection-to-hostnames#dfc19a42769f95c283400c1fd6f3b6657e74734c" +source = "git+https://github.com/oleonardolima/fedimint/?rev=2b54c1cbbec42499c805862724496f45006393db#2b54c1cbbec42499c805862724496f45006393db" dependencies = [ "anyhow", "aquamarine", @@ -2299,7 +2299,7 @@ dependencies = [ [[package]] name = "fedimint-core" version = "0.4.0-alpha" -source = "git+https://github.com/oleonardolima/fedimint/?branch=feat/add-mvp-tor-support-connection-to-hostnames#dfc19a42769f95c283400c1fd6f3b6657e74734c" +source = "git+https://github.com/oleonardolima/fedimint/?rev=2b54c1cbbec42499c805862724496f45006393db#2b54c1cbbec42499c805862724496f45006393db" dependencies = [ "anyhow", "async-lock", @@ -2352,7 +2352,7 @@ dependencies = [ [[package]] name = "fedimint-derive" version = "0.4.0-alpha" -source = "git+https://github.com/oleonardolima/fedimint/?branch=feat/add-mvp-tor-support-connection-to-hostnames#dfc19a42769f95c283400c1fd6f3b6657e74734c" +source = "git+https://github.com/oleonardolima/fedimint/?rev=2b54c1cbbec42499c805862724496f45006393db#2b54c1cbbec42499c805862724496f45006393db" dependencies = [ "itertools 0.12.1", "proc-macro2", @@ -2363,7 +2363,7 @@ dependencies = [ [[package]] name = "fedimint-derive-secret" version = "0.4.0-alpha" -source = "git+https://github.com/oleonardolima/fedimint/?branch=feat/add-mvp-tor-support-connection-to-hostnames#dfc19a42769f95c283400c1fd6f3b6657e74734c" +source = "git+https://github.com/oleonardolima/fedimint/?rev=2b54c1cbbec42499c805862724496f45006393db#2b54c1cbbec42499c805862724496f45006393db" dependencies = [ "anyhow", "bitcoin_hashes 0.11.0", @@ -2377,7 +2377,7 @@ dependencies = [ [[package]] name = "fedimint-hkdf" version = "0.4.0-alpha" -source = "git+https://github.com/oleonardolima/fedimint/?branch=feat/add-mvp-tor-support-connection-to-hostnames#dfc19a42769f95c283400c1fd6f3b6657e74734c" +source = "git+https://github.com/oleonardolima/fedimint/?rev=2b54c1cbbec42499c805862724496f45006393db#2b54c1cbbec42499c805862724496f45006393db" dependencies = [ "bitcoin_hashes 0.12.0", ] @@ -2385,7 +2385,7 @@ dependencies = [ [[package]] name = "fedimint-ln-client" version = "0.4.0-alpha" -source = "git+https://github.com/oleonardolima/fedimint/?branch=feat/add-mvp-tor-support-connection-to-hostnames#dfc19a42769f95c283400c1fd6f3b6657e74734c" +source = "git+https://github.com/oleonardolima/fedimint/?rev=2b54c1cbbec42499c805862724496f45006393db#2b54c1cbbec42499c805862724496f45006393db" dependencies = [ "anyhow", "aquamarine", @@ -2417,7 +2417,7 @@ dependencies = [ [[package]] name = "fedimint-ln-common" version = "0.4.0-alpha" -source = "git+https://github.com/oleonardolima/fedimint/?branch=feat/add-mvp-tor-support-connection-to-hostnames#dfc19a42769f95c283400c1fd6f3b6657e74734c" +source = "git+https://github.com/oleonardolima/fedimint/?rev=2b54c1cbbec42499c805862724496f45006393db#2b54c1cbbec42499c805862724496f45006393db" dependencies = [ "anyhow", "bitcoin 0.30.2", @@ -2438,7 +2438,7 @@ dependencies = [ [[package]] name = "fedimint-logging" version = "0.4.0-alpha" -source = "git+https://github.com/oleonardolima/fedimint/?branch=feat/add-mvp-tor-support-connection-to-hostnames#dfc19a42769f95c283400c1fd6f3b6657e74734c" +source = "git+https://github.com/oleonardolima/fedimint/?rev=2b54c1cbbec42499c805862724496f45006393db#2b54c1cbbec42499c805862724496f45006393db" dependencies = [ "anyhow", "tracing-subscriber", @@ -2447,7 +2447,7 @@ dependencies = [ [[package]] name = "fedimint-mint-client" version = "0.4.0-alpha" -source = "git+https://github.com/oleonardolima/fedimint/?branch=feat/add-mvp-tor-support-connection-to-hostnames#dfc19a42769f95c283400c1fd6f3b6657e74734c" +source = "git+https://github.com/oleonardolima/fedimint/?rev=2b54c1cbbec42499c805862724496f45006393db#2b54c1cbbec42499c805862724496f45006393db" dependencies = [ "anyhow", "aquamarine", @@ -2483,7 +2483,7 @@ dependencies = [ [[package]] name = "fedimint-mint-common" version = "0.4.0-alpha" -source = "git+https://github.com/oleonardolima/fedimint/?branch=feat/add-mvp-tor-support-connection-to-hostnames#dfc19a42769f95c283400c1fd6f3b6657e74734c" +source = "git+https://github.com/oleonardolima/fedimint/?rev=2b54c1cbbec42499c805862724496f45006393db#2b54c1cbbec42499c805862724496f45006393db" dependencies = [ "anyhow", "bincode", @@ -2499,7 +2499,7 @@ dependencies = [ [[package]] name = "fedimint-tbs" version = "0.4.0-alpha" -source = "git+https://github.com/oleonardolima/fedimint/?branch=feat/add-mvp-tor-support-connection-to-hostnames#dfc19a42769f95c283400c1fd6f3b6657e74734c" +source = "git+https://github.com/oleonardolima/fedimint/?rev=2b54c1cbbec42499c805862724496f45006393db#2b54c1cbbec42499c805862724496f45006393db" dependencies = [ "bls12_381", "fedimint-core", @@ -2536,7 +2536,7 @@ dependencies = [ [[package]] name = "fedimint-wallet-client" version = "0.4.0-alpha" -source = "git+https://github.com/oleonardolima/fedimint/?branch=feat/add-mvp-tor-support-connection-to-hostnames#dfc19a42769f95c283400c1fd6f3b6657e74734c" +source = "git+https://github.com/oleonardolima/fedimint/?rev=2b54c1cbbec42499c805862724496f45006393db#2b54c1cbbec42499c805862724496f45006393db" dependencies = [ "anyhow", "aquamarine", @@ -2563,7 +2563,7 @@ dependencies = [ [[package]] name = "fedimint-wallet-common" version = "0.4.0-alpha" -source = "git+https://github.com/oleonardolima/fedimint/?branch=feat/add-mvp-tor-support-connection-to-hostnames#dfc19a42769f95c283400c1fd6f3b6657e74734c" +source = "git+https://github.com/oleonardolima/fedimint/?rev=2b54c1cbbec42499c805862724496f45006393db#2b54c1cbbec42499c805862724496f45006393db" dependencies = [ "anyhow", "bitcoin 0.30.2", diff --git a/Cargo.toml b/Cargo.toml index d3c0ad1..ba1601a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,14 +30,14 @@ hex = "0.4.3" bitcoin = { version = "0.30.2", features = ["base64"] } bip39 = "2.0.0" -fedimint-api-client = { git = "https://github.com/oleonardolima/fedimint/", branch = "feat/add-mvp-tor-support-connection-to-hostnames" } -fedimint-client = { git = "https://github.com/oleonardolima/fedimint/", branch = "feat/add-mvp-tor-support-connection-to-hostnames" } -fedimint-core = { git = "https://github.com/oleonardolima/fedimint/", branch = "feat/add-mvp-tor-support-connection-to-hostnames" } -fedimint-wallet-client = { git = "https://github.com/oleonardolima/fedimint/", branch = "feat/add-mvp-tor-support-connection-to-hostnames" } -fedimint-mint-client = { git = "https://github.com/oleonardolima/fedimint/", branch = "feat/add-mvp-tor-support-connection-to-hostnames" } -fedimint-ln-client = { git = "https://github.com/oleonardolima/fedimint/", branch = "feat/add-mvp-tor-support-connection-to-hostnames" } -fedimint-bip39 = { git = "https://github.com/oleonardolima/fedimint/", branch = "feat/add-mvp-tor-support-connection-to-hostnames" } -fedimint-ln-common = { git = "https://github.com/oleonardolima/fedimint/", branch = "feat/add-mvp-tor-support-connection-to-hostnames" } +fedimint-api-client = { git = "https://github.com/oleonardolima/fedimint/", rev = "2b54c1cbbec42499c805862724496f45006393db" } +fedimint-client = { git = "https://github.com/oleonardolima/fedimint/", rev = "2b54c1cbbec42499c805862724496f45006393db" } +fedimint-core = { git = "https://github.com/oleonardolima/fedimint/", rev = "2b54c1cbbec42499c805862724496f45006393db" } +fedimint-wallet-client = { git = "https://github.com/oleonardolima/fedimint/", rev = "2b54c1cbbec42499c805862724496f45006393db" } +fedimint-mint-client = { git = "https://github.com/oleonardolima/fedimint/", rev = "2b54c1cbbec42499c805862724496f45006393db" } +fedimint-ln-client = { git = "https://github.com/oleonardolima/fedimint/", rev = "2b54c1cbbec42499c805862724496f45006393db" } +fedimint-bip39 = { git = "https://github.com/oleonardolima/fedimint/", rev = "2b54c1cbbec42499c805862724496f45006393db" } +fedimint-ln-common = { git = "https://github.com/oleonardolima/fedimint/", rev = "2b54c1cbbec42499c805862724496f45006393db" } [dev-dependencies] tempdir = "0.3.7" diff --git a/justfile b/justfile index de244f9..704686a 100644 --- a/justfile +++ b/justfile @@ -5,7 +5,7 @@ set dotenv-load := true FEATURE_FLAG := if env('USE_VENDOR_FEATURE', '0') == "1" { "--features vendored" } else { "" } run: - RUST_LOG=harbor=debug,iced_wgpu=error,wgpu_core=error,info cargo run {{FEATURE_FLAG}} + RUST_LOG=harbor=debug,fedimint=trace,jsonrpsee=trace,arti=trace,iced_wgpu=error,wgpu_core=error,info cargo run {{FEATURE_FLAG}} watch: RUST_LOG=harbor=debug,iced_wgpu=error,wgpu_core=error,info cargo watch -x "run {{FEATURE_FLAG}}" diff --git a/src/core.rs b/src/core.rs index b527682..90f68cb 100644 --- a/src/core.rs +++ b/src/core.rs @@ -2,6 +2,7 @@ use anyhow::anyhow; use bip39::Mnemonic; use bitcoin::address::NetworkUnchecked; use bitcoin::{Address, Network}; +use fedimint_api_client::api::Connector; use fedimint_core::config::{ClientConfig, FederationId}; use fedimint_core::invite_code::InviteCode; use fedimint_core::Amount; @@ -302,7 +303,7 @@ impl HarborCore { async fn get_federation_info(&self, invite_code: InviteCode) -> anyhow::Result { let download = Instant::now(); - let config = fedimint_api_client::download_from_invite_code(&invite_code) + let config = fedimint_api_client::download_from_invite_code(Connector::Tor, &invite_code) .await .map_err(|e| { error!("Could not download federation info: {e}"); diff --git a/src/fedimint_client.rs b/src/fedimint_client.rs index 427c3d7..b96dd0b 100644 --- a/src/fedimint_client.rs +++ b/src/fedimint_client.rs @@ -6,6 +6,7 @@ use async_trait::async_trait; use bip39::Mnemonic; use bitcoin::hashes::hex::FromHex; use bitcoin::Network; +use fedimint_api_client::api::Connector; use fedimint_bip39::Bip39RootSecretStrategy; use fedimint_client::oplog::UpdateStreamOrOutcome; use fedimint_client::secret::{get_default_client_secret, RootSecretStrategy}; @@ -85,6 +86,8 @@ impl FedimintClient { client_builder.with_primary_module(1); + client_builder.with_tor_connector(); + trace!("Building fedimint client db"); let secret = Bip39RootSecretStrategy::<12>::to_root_secret(mnemonic); @@ -100,7 +103,7 @@ impl FedimintClient { ) } else if let FederationInviteOrId::Invite(i) = invite_or_id { let download = Instant::now(); - let config = fedimint_api_client::download_from_invite_code(&i) + let config = fedimint_api_client::download_from_invite_code(Connector::Tor, &i) .await .map_err(|e| { error!("Could not download federation info: {e}");