Skip to content

Commit

Permalink
Merge branch 'main' into mock-deps
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-21 committed Jul 9, 2024
2 parents e11c27b + 1993a78 commit f88d51a
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 53 deletions.
34 changes: 17 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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"
Expand All @@ -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"]
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions mock/wild/chameleon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 2 additions & 2 deletions mock/wild/crow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
4 changes: 2 additions & 2 deletions mock/wild/honeybadger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions mock/wild/parrot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
2 changes: 1 addition & 1 deletion mock/wild/pigeon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
7 changes: 4 additions & 3 deletions mock/wild/pigeon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

Expand Down
4 changes: 2 additions & 2 deletions mock/wild/squirrel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
43 changes: 31 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -286,6 +286,7 @@ pub struct LightningNode {
environment: Environment,
allowed_countries_country_iso_3166_1_alpha_2: Vec<String>,
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.
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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,
})
}

Expand Down Expand Up @@ -2558,7 +2557,8 @@ impl LightningNode {
///
/// Requires network: **yes**
pub fn query_verified_phone_number(&self) -> Result<Option<String>> {
self.rt
let encrypted_number = self
.rt
.handle()
.block_on(pigeon::query_verified_phone_number(
&self.environment.backend_url,
Expand All @@ -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
Expand All @@ -2580,15 +2590,23 @@ 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()
.block_on(pigeon::request_phone_number_verification(
&self.environment.backend_url,
&self.async_auth,
phone_number.e164,
encrypted_number,
))
.map_to_runtime_error(
RuntimeErrorCode::AuthServiceUnavailable,
Expand All @@ -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()
Expand Down

0 comments on commit f88d51a

Please sign in to comment.