diff --git a/Cargo.lock b/Cargo.lock index acc73171..b1a890f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -760,7 +760,7 @@ dependencies = [ [[package]] name = "chameleon" version = "0.1.0" -source = "git+https://github.com/getlipa/wild?tag=v1.24.0#7fce8e6bb9cb4d672392ed6a2193b64a0d203777" +source = "git+https://github.com/getlipa/wild?tag=v1.25.0#06b231cd578addc00e1c49b4c02f3338b67e6c98" dependencies = [ "graphql", "honeybadger", @@ -976,7 +976,7 @@ dependencies = [ [[package]] name = "crow" version = "0.1.0" -source = "git+https://github.com/getlipa/wild?tag=v1.24.0#7fce8e6bb9cb4d672392ed6a2193b64a0d203777" +source = "git+https://github.com/getlipa/wild?tag=v1.25.0#06b231cd578addc00e1c49b4c02f3338b67e6c98" dependencies = [ "graphql", "honeybadger", @@ -1213,9 +1213,9 @@ dependencies = [ [[package]] name = "email_address" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2153bd83ebc09db15bcbdc3e2194d901804952e3dc96967e1cd3b0c5c32d112" +checksum = "c1019fa28f600f5b581b7a603d515c3f1635da041ca211b5055804788673abfe" dependencies = [ "serde", ] @@ -1649,7 +1649,7 @@ dependencies = [ [[package]] name = "graphql" version = "0.1.0" -source = "git+https://github.com/getlipa/wild?tag=v1.24.0#7fce8e6bb9cb4d672392ed6a2193b64a0d203777" +source = "git+https://github.com/getlipa/wild?tag=v1.25.0#06b231cd578addc00e1c49b4c02f3338b67e6c98" dependencies = [ "chrono", "graphql_client", @@ -1847,7 +1847,7 @@ dependencies = [ [[package]] name = "honeybadger" version = "1.0.1" -source = "git+https://github.com/getlipa/wild?tag=v1.24.0#7fce8e6bb9cb4d672392ed6a2193b64a0d203777" +source = "git+https://github.com/getlipa/wild?tag=v1.25.0#06b231cd578addc00e1c49b4c02f3338b67e6c98" dependencies = [ "base64 0.22.1", "bdk", @@ -2716,7 +2716,7 @@ dependencies = [ [[package]] name = "parrot" version = "0.1.0" -source = "git+https://github.com/getlipa/wild?tag=v1.24.0#7fce8e6bb9cb4d672392ed6a2193b64a0d203777" +source = "git+https://github.com/getlipa/wild?tag=v1.25.0#06b231cd578addc00e1c49b4c02f3338b67e6c98" dependencies = [ "graphql", "honeybadger", @@ -2828,7 +2828,7 @@ dependencies = [ [[package]] name = "pigeon" version = "0.1.0" -source = "git+https://github.com/getlipa/wild?tag=v1.24.0#7fce8e6bb9cb4d672392ed6a2193b64a0d203777" +source = "git+https://github.com/getlipa/wild?tag=v1.25.0#06b231cd578addc00e1c49b4c02f3338b67e6c98" dependencies = [ "graphql", "honeybadger", @@ -3061,9 +3061,9 @@ dependencies = [ [[package]] name = "qrcode" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e719ca51966ff9f5a8436edb00d6115b3c606a0bb27c8f8ca74a38ff2b036d" +checksum = "d68782463e408eb1e668cf6152704bd856c78c5b6417adaee3203d8f4c1fc9ec" [[package]] name = "querystring" @@ -3638,9 +3638,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] @@ -3659,9 +3659,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", @@ -3905,7 +3905,7 @@ dependencies = [ [[package]] name = "squirrel" version = "0.1.0" -source = "git+https://github.com/getlipa/wild?tag=v1.24.0#7fce8e6bb9cb4d672392ed6a2193b64a0d203777" +source = "git+https://github.com/getlipa/wild?tag=v1.25.0#06b231cd578addc00e1c49b4c02f3338b67e6c98" dependencies = [ "bdk", "graphql", @@ -4650,9 +4650,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.9.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de17fd2f7da591098415cff336e12965a28061ddace43b59cb3c430179c9439" +checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" dependencies = [ "serde", "sha1_smol", diff --git a/Cargo.toml b/Cargo.toml index de5e8212..4202d426 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,19 +19,19 @@ parser = { path = "parser" } pocketclient = { path = "pocketclient", optional = true } pocketclient-mock = { path = "mock/pocketclient", optional = true } -chameleon = { git = "https://github.com/getlipa/wild", tag = "v1.24.0", optional = true } +chameleon = { git = "https://github.com/getlipa/wild", tag = "v1.25.0", optional = true } chameleon-mock = { path = "mock/wild/chameleon", optional = true } -crow = { git = "https://github.com/getlipa/wild", tag = "v1.24.0", optional = true } +crow = { git = "https://github.com/getlipa/wild", tag = "v1.25.0", optional = true } crow-mock = { path = "mock/wild/crow", optional = true } -graphql = { git = "https://github.com/getlipa/wild", tag = "v1.24.0" } -honeybadger = { git = "https://github.com/getlipa/wild", tag = "v1.24.0", optional = true } +graphql = { git = "https://github.com/getlipa/wild", tag = "v1.25.0" } +honeybadger = { git = "https://github.com/getlipa/wild", tag = "v1.25.0", optional = true } honeybadger-mock = { path = "mock/wild/honeybadger", optional = true } -parrot = { git = "https://github.com/getlipa/wild", tag = "v1.24.0", optional = true } +parrot = { git = "https://github.com/getlipa/wild", tag = "v1.25.0", optional = true } parrot-mock = { path = "mock/wild/parrot", optional = true } perro = { git = "https://github.com/getlipa/perro", tag = "v1.2.0" } -pigeon = { git = "https://github.com/getlipa/wild", tag = "v1.24.0", optional = true } +pigeon = { git = "https://github.com/getlipa/wild", tag = "v1.25.0", optional = true } pigeon-mock = { path = "mock/wild/pigeon", optional = true } -squirrel = { git = "https://github.com/getlipa/wild", tag = "v1.24.0", optional = true } +squirrel = { git = "https://github.com/getlipa/wild", tag = "v1.25.0", optional = true } squirrel-mock = { path = "mock/wild/squirrel", optional = true } breez-sdk-core = { git = "https://github.com/breez/breez-sdk", tag = "0.5.0", optional = true } @@ -42,7 +42,7 @@ bip39 = "2.0.0" bitcoin = "0.30.1" chrono = { version = "0.4.38", default-features = false, features = ["serde"] } cipher = "0.4.4" -email_address = "0.2.4" +email_address = "0.2.5" file-rotate = "0.7.6" hex = "0.4.3" iban_validate = "4.0.1" @@ -60,7 +60,7 @@ simplelog = { version = "0.12.2" } thiserror = "1.0.61" tokio = { version = "1.38.0", features = ["rt-multi-thread", "time", "sync"] } uniffi = "0.28.0" -uuid = { version = "1.9.1", features = ["v5"] } +uuid = { version = "1.10.0", features = ["v5"] } [features] default = ["dep:breez-sdk-core", "dep:chameleon", "dep:crow", "dep:honeybadger", "dep:parrot", "dep:pigeon", "dep:squirrel", "dep:pocketclient"] @@ -90,7 +90,7 @@ rusqlite = { version = "0.29.0", features = [ anyhow = "1" colored = "2.1.0" ctor = "0.2.8" -qrcode = { version = "0.14.0", default-features = false } +qrcode = { version = "0.14.1", default-features = false } rustyline = { version = "14.0.0", features = ["derive"] } serial_test = { version = "3.1.1", features = ["file_locks"] } strip-ansi-escapes = "0.2.0" diff --git a/mock/wild/chameleon/Cargo.toml b/mock/wild/chameleon/Cargo.toml index f769ea7a..b120beff 100644 --- a/mock/wild/chameleon/Cargo.toml +++ b/mock/wild/chameleon/Cargo.toml @@ -7,8 +7,8 @@ edition = "2021" name = "chameleon" [dependencies] -chameleon = { git = "https://github.com/getlipa/wild", tag = "v1.24.0" } -graphql = { git = "https://github.com/getlipa/wild", tag = "v1.24.0" } +chameleon = { git = "https://github.com/getlipa/wild", tag = "v1.25.0" } +graphql = { git = "https://github.com/getlipa/wild", tag = "v1.25.0" } honeybadger-mock = { path = "../honeybadger" } lazy_static = "1.4.0" rand = "0.8.5" diff --git a/mock/wild/crow/Cargo.toml b/mock/wild/crow/Cargo.toml index 6cf0c6c6..f8ec3222 100644 --- a/mock/wild/crow/Cargo.toml +++ b/mock/wild/crow/Cargo.toml @@ -7,8 +7,8 @@ edition = "2021" name = "crow" [dependencies] -crow = { git = "https://github.com/getlipa/wild", tag = "v1.24.0" } -graphql = { git = "https://github.com/getlipa/wild", tag = "v1.24.0" } +crow = { git = "https://github.com/getlipa/wild", tag = "v1.25.0" } +graphql = { git = "https://github.com/getlipa/wild", tag = "v1.25.0" } honeybadger-mock = { path = "../honeybadger" } isocountry = { version = "0.3.2" } isolanguage-1 = { version = "0.2.2" } diff --git a/mock/wild/honeybadger/Cargo.toml b/mock/wild/honeybadger/Cargo.toml index 0881a1a1..bacd5991 100644 --- a/mock/wild/honeybadger/Cargo.toml +++ b/mock/wild/honeybadger/Cargo.toml @@ -7,8 +7,8 @@ edition = "2021" name = "honeybadger" [dependencies] -graphql = { git = "https://github.com/getlipa/wild", tag = "v1.24.0" } -honeybadger = { git = "https://github.com/getlipa/wild", tag = "v1.24.0" } +graphql = { git = "https://github.com/getlipa/wild", tag = "v1.25.0" } +honeybadger = { git = "https://github.com/getlipa/wild", tag = "v1.25.0" } rand = "0.8.5" secp256k1 = { version = "0.27.0", features = ["global-context"] } tokio = "1.37.0" diff --git a/mock/wild/parrot/Cargo.toml b/mock/wild/parrot/Cargo.toml index 5c1596fa..2bef9c15 100644 --- a/mock/wild/parrot/Cargo.toml +++ b/mock/wild/parrot/Cargo.toml @@ -7,6 +7,6 @@ edition = "2021" name = "parrot" [dependencies] -graphql = { git = "https://github.com/getlipa/wild", tag = "v1.24.0" } +graphql = { git = "https://github.com/getlipa/wild", tag = "v1.25.0" } honeybadger-mock = { path = "../honeybadger" } -parrot = { git = "https://github.com/getlipa/wild", tag = "v1.24.0" } +parrot = { git = "https://github.com/getlipa/wild", tag = "v1.25.0" } diff --git a/mock/wild/pigeon/Cargo.toml b/mock/wild/pigeon/Cargo.toml index 64d18e56..c5ccaafb 100644 --- a/mock/wild/pigeon/Cargo.toml +++ b/mock/wild/pigeon/Cargo.toml @@ -7,6 +7,6 @@ edition = "2021" name = "pigeon" [dependencies] -graphql = { git = "https://github.com/getlipa/wild", tag = "v1.24.0" } +graphql = { git = "https://github.com/getlipa/wild", tag = "v1.25.0" } honeybadger-mock = { path = "../honeybadger" } lazy_static = "1.4.0" diff --git a/mock/wild/pigeon/src/lib.rs b/mock/wild/pigeon/src/lib.rs index 9c75f691..e1ea5bfb 100644 --- a/mock/wild/pigeon/src/lib.rs +++ b/mock/wild/pigeon/src/lib.rs @@ -21,18 +21,19 @@ pub async fn request_phone_number_verification( _backend_url: &str, _auth: &Auth, _number: String, + encrypted_number: String, ) -> graphql::Result<()> { + let mut phone_number = PHONE_NUMBER.lock().unwrap(); + *phone_number = Some(encrypted_number); Ok(()) } pub async fn verify_phone_number( _backend_url: &str, _auth: &Auth, - number: String, + _number: String, _otp: String, ) -> graphql::Result<()> { - let mut phone_number = PHONE_NUMBER.lock().unwrap(); - *phone_number = Some(number); Ok(()) } diff --git a/mock/wild/squirrel/Cargo.toml b/mock/wild/squirrel/Cargo.toml index d0037157..6b9abd89 100644 --- a/mock/wild/squirrel/Cargo.toml +++ b/mock/wild/squirrel/Cargo.toml @@ -7,6 +7,6 @@ edition = "2021" name = "squirrel" [dependencies] -graphql = { git = "https://github.com/getlipa/wild", tag = "v1.24.0" } +graphql = { git = "https://github.com/getlipa/wild", tag = "v1.25.0" } honeybadger-mock = { path = "../honeybadger" } -squirrel = { git = "https://github.com/getlipa/wild", tag = "v1.24.0" } +squirrel = { git = "https://github.com/getlipa/wild", tag = "v1.25.0" } diff --git a/src/lib.rs b/src/lib.rs index 0218335f..7484b584 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -88,7 +88,7 @@ pub use crate::secret::{generate_secret, mnemonic_to_secret, words_by_prefix, Se pub use crate::swap::{ FailedSwapInfo, ResolveFailedSwapInfo, SwapAddressInfo, SwapInfo, SwapToLightningFees, }; -use crate::symmetric_encryption::deterministic_encrypt; +use crate::symmetric_encryption::{decrypt, deterministic_encrypt, encrypt}; use crate::task_manager::TaskManager; use crate::util::{ replace_byte_arrays_by_hex_string, unix_timestamp_to_system_time, LogIgnoreError, @@ -286,6 +286,7 @@ pub struct LightningNode { environment: Environment, allowed_countries_country_iso_3166_1_alpha_2: Vec, phone_number_prefix_parser: PhoneNumberPrefixParser, + persistence_encryption_key: [u8; 32], } /// Contains the fee information for the options to resolve on-chain funds from channel closes. @@ -429,13 +430,10 @@ impl LightningNode { "Couldn't create a fiat topup client", )?; + let persistence_encryption_key = derive_persistence_encryption_key(&strong_typed_seed)?; let backup_client = RemoteBackupClient::new(environment.backend_url.clone(), Arc::clone(&async_auth)); - let backup_manager = BackupManager::new( - backup_client, - db_path, - derive_persistence_encryption_key(&strong_typed_seed)?, - ); + let backup_manager = BackupManager::new(backup_client, db_path, persistence_encryption_key); let task_manager = Arc::new(Mutex::new(TaskManager::new( rt.handle(), @@ -485,6 +483,7 @@ impl LightningNode { allowed_countries_country_iso_3166_1_alpha_2: config .phone_number_allowed_countries_iso_3166_1_alpha_2, phone_number_prefix_parser, + persistence_encryption_key, }) } @@ -2558,7 +2557,8 @@ impl LightningNode { /// /// Requires network: **yes** pub fn query_verified_phone_number(&self) -> Result> { - self.rt + let encrypted_number = self + .rt .handle() .block_on(pigeon::query_verified_phone_number( &self.environment.backend_url, @@ -2567,7 +2567,17 @@ impl LightningNode { .map_to_runtime_error( RuntimeErrorCode::AuthServiceUnavailable, "Failed to query verified phone number", - ) + )?; + if let Some(encrypted_number) = encrypted_number { + let encrypted_number = hex::decode(encrypted_number) + .map_to_permanent_failure("Failed to hex decode verified phone number")?; + let number = decrypt(&encrypted_number, &self.persistence_encryption_key)?; + let number = std::str::from_utf8(&number) + .map_to_permanent_failure("Failed to decrypt verified phone number")? + .to_string(); + return Ok(Some(number)); + } + Ok(None) } /// Start the verification process for a new phone number. This will trigger an SMS containing @@ -2580,8 +2590,15 @@ impl LightningNode { /// /// Requires network: **yes** pub fn request_phone_number_verification(&self, phone_number: String) -> Result<()> { - let phone_number = - PhoneNumber::parse(&phone_number).map_to_invalid_input("Invalid phone number")?; + let phone_number = self + .parse_phone_number(phone_number) + .map_to_invalid_input("Invalid phone number")?; + + let encrypted_number = encrypt( + phone_number.e164.as_bytes(), + &self.persistence_encryption_key, + )?; + let encrypted_number = hex::encode(encrypted_number); self.rt .handle() @@ -2589,6 +2606,7 @@ impl LightningNode { &self.environment.backend_url, &self.async_auth, phone_number.e164, + encrypted_number, )) .map_to_runtime_error( RuntimeErrorCode::AuthServiceUnavailable, @@ -2604,8 +2622,9 @@ impl LightningNode { /// /// Requires network: **yes** pub fn verify_phone_number(&self, phone_number: String, otp: String) -> Result<()> { - let phone_number = - PhoneNumber::parse(&phone_number).map_to_invalid_input("Invalid phone number")?; + let phone_number = self + .parse_phone_number(phone_number) + .map_to_invalid_input("Invalid phone number")?; self.rt .handle()