diff --git a/cli/Cargo.lock b/cli/Cargo.lock index f27bc6475..a3aafc904 100644 --- a/cli/Cargo.lock +++ b/cli/Cargo.lock @@ -707,7 +707,6 @@ dependencies = [ "glob", "hex", "lazy_static", - "lightning 0.0.125", "log", "lwk_common", "lwk_signer", @@ -3436,7 +3435,7 @@ dependencies = [ [[package]] name = "sdk-common" version = "0.6.2" -source = "git+https://github.com/breez/breez-sdk?rev=f77208acd34d74b571388889e856444908c59a85#f77208acd34d74b571388889e856444908c59a85" +source = "git+https://github.com/breez/breez-sdk?rev=da61ce31e937fb7bad452aaf89ff53471b19bc3a#da61ce31e937fb7bad452aaf89ff53471b19bc3a" dependencies = [ "aes 0.8.4", "anyhow", @@ -3447,6 +3446,7 @@ dependencies = [ "elements", "hex", "lightning 0.0.118", + "lightning 0.0.125", "lightning-invoice 0.26.0", "log", "percent-encoding", diff --git a/lib/Cargo.lock b/lib/Cargo.lock index 557adfdbb..b2e23d51c 100644 --- a/lib/Cargo.lock +++ b/lib/Cargo.lock @@ -811,7 +811,6 @@ dependencies = [ "glob", "hex", "lazy_static", - "lightning 0.0.125", "log", "lwk_common", "lwk_signer", @@ -3530,7 +3529,7 @@ dependencies = [ [[package]] name = "sdk-common" version = "0.6.2" -source = "git+https://github.com/breez/breez-sdk?rev=f77208acd34d74b571388889e856444908c59a85#f77208acd34d74b571388889e856444908c59a85" +source = "git+https://github.com/breez/breez-sdk?rev=da61ce31e937fb7bad452aaf89ff53471b19bc3a#da61ce31e937fb7bad452aaf89ff53471b19bc3a" dependencies = [ "aes 0.8.4", "anyhow", @@ -3541,6 +3540,7 @@ dependencies = [ "elements", "hex", "lightning 0.0.118", + "lightning 0.0.125", "lightning-invoice 0.26.0", "log", "percent-encoding", diff --git a/lib/core/Cargo.toml b/lib/core/Cargo.toml index 26af69232..6af84e018 100644 --- a/lib/core/Cargo.toml +++ b/lib/core/Cargo.toml @@ -23,8 +23,6 @@ env_logger = "0.11" flutter_rust_bridge = { version = "=2.4.0", features = [ "chrono", ], optional = true } -# We need at least lightning v0.0.125 for the Bolt12 structs. The lightning version from sdk-common is too old (v0.0.118, matching vls-core). -lightning = "0.0.125" log = { workspace = true } lwk_common = "0.7.0" lwk_signer = "0.7.0" @@ -32,7 +30,7 @@ lwk_wollet = { git = "https://github.com/dangeross/lwk", branch = "savage-full-s #lwk_wollet = "0.7.0" rusqlite = { version = "0.31", features = ["backup", "bundled"] } rusqlite_migration = "1.0" -sdk-common = { git = "https://github.com/breez/breez-sdk", rev = "f77208acd34d74b571388889e856444908c59a85", features = ["liquid"] } +sdk-common = { git = "https://github.com/breez/breez-sdk", rev = "da61ce31e937fb7bad452aaf89ff53471b19bc3a", features = ["liquid"] } serde = { version = "1.0.197", features = ["derive"] } serde_json = "1.0.116" strum = "0.25" diff --git a/lib/core/src/sdk.rs b/lib/core/src/sdk.rs index 5399301c4..1a5cc1385 100644 --- a/lib/core/src/sdk.rs +++ b/lib/core/src/sdk.rs @@ -49,8 +49,7 @@ use crate::{ persist::Persister, utils, *, }; -use ::lightning::offers::invoice::Bolt12Invoice; -use ::lightning::offers::offer::Offer; +use sdk_common::lightning_125::offers::invoice::Bolt12Invoice; use self::sync::client::BreezSyncerClient; use self::sync::SyncService; @@ -2614,7 +2613,7 @@ impl LiquidSdk { /// Prepares to pay to an LNURL encoded pay request or lightning address. /// - /// This is the second step of LNURL-pay flow. The first step is [parse], which also validates the LNURL + /// This is the second step of LNURL-pay flow. The first step is [LiquidSdk::parse], which also validates the LNURL /// destination and generates the [LnUrlPayRequest] payload needed here. /// /// This call will validate the `amount_msat` and `comment` parameters of `req` against the parameters @@ -2625,7 +2624,7 @@ impl LiquidSdk { /// # Arguments /// /// * `req` - the [PrepareLnUrlPayRequest] containing: - /// * `data` - the [LnUrlPayRequestData] returned by [parse] + /// * `data` - the [LnUrlPayRequestData] returned by [LiquidSdk::parse] /// * `amount_msat` - the amount in millisatoshis for this payment /// * `comment` - an optional comment for this payment /// * `validate_success_action_url` - validates that, if there is a URL success action, the URL domain matches @@ -2784,7 +2783,7 @@ impl LiquidSdk { }) } - /// Second step of LNURL-withdraw. The first step is [parse], which also validates the LNURL destination + /// Second step of LNURL-withdraw. The first step is [LiquidSdk::parse], which also validates the LNURL destination /// and generates the [LnUrlWithdrawRequest] payload needed here. /// /// This call will validate the given `amount_msat` against the parameters @@ -2840,7 +2839,7 @@ impl LiquidSdk { Ok(res) } - /// Third and last step of LNURL-auth. The first step is [parse], which also validates the LNURL destination + /// Third and last step of LNURL-auth. The first step is [LiquidSdk::parse], which also validates the LNURL destination /// and generates the [LnUrlAuthRequestData] payload needed here. The second step is user approval of auth action. /// /// This call will sign `k1` of the LNURL endpoint (`req_data`) on `secp256k1` using `linkingPrivKey` and DER-encodes the signature. @@ -2924,60 +2923,6 @@ impl LiquidSdk { /// /// Can optionally be configured to use external input parsers by providing `external_input_parsers` in [Config]. pub async fn parse(&self, input: &str) -> Result { - if let Ok(offer) = input.parse::() { - // TODO This conversion (between lightning-v0.0.125 to -v0.0.118 Amount types) - // won't be needed when Liquid SDK uses the same lightning crate version as sdk-common - let min_amount = offer - .amount() - .map(|amount| match amount { - ::lightning::offers::offer::Amount::Bitcoin { amount_msats } => { - Ok(Amount::Bitcoin { - amount_msat: amount_msats, - }) - } - ::lightning::offers::offer::Amount::Currency { - iso4217_code, - amount, - } => Ok(Amount::Currency { - iso4217_code: String::from_utf8(iso4217_code.to_vec()).map_err(|_| { - anyhow!("Expecting a valid ISO 4217 character sequence") - })?, - fractional_amount: amount, - }), - }) - .transpose() - .map_err(|e: anyhow::Error| { - PaymentError::generic(&format!("Failed to reconstruct amount: {e:?}")) - })?; - - return Ok(InputType::Bolt12Offer { - offer: LNOffer { - offer: input.to_string(), - chains: offer - .chains() - .iter() - .map(|chain| chain.to_string()) - .collect(), - min_amount, - description: offer.description().map(|d| d.to_string()), - absolute_expiry: offer.absolute_expiry().map(|expiry| expiry.as_secs()), - issuer: offer.issuer().map(|s| s.to_string()), - signing_pubkey: offer.signing_pubkey().map(|pk| pk.to_string()), - paths: offer - .paths() - .iter() - .map(|path| LnOfferBlindedPath { - blinded_hops: path - .blinded_hops() - .iter() - .map(|hop| hop.blinded_node_id.to_hex()) - .collect(), - }) - .collect::>(), - }, - }); - } - let external_parsers = &self.external_input_parsers; parse(input, Some(external_parsers)) .await diff --git a/lib/core/src/utils.rs b/lib/core/src/utils.rs index c10af5e74..53d93b83b 100644 --- a/lib/core/src/utils.rs +++ b/lib/core/src/utils.rs @@ -3,7 +3,6 @@ use std::time::{SystemTime, UNIX_EPOCH}; use crate::error::{PaymentError, SdkResult}; use anyhow::{anyhow, ensure, Result}; -use lightning::offers::invoice::Bolt12Invoice; use lwk_wollet::elements::encode::deserialize; use lwk_wollet::elements::hex::FromHex; use lwk_wollet::elements::{ @@ -12,6 +11,7 @@ use lwk_wollet::elements::{ }; use sdk_common::bitcoin::bech32; use sdk_common::bitcoin::bech32::FromBase32; +use sdk_common::lightning_125::offers::invoice::Bolt12Invoice; pub(crate) fn now() -> u32 { SystemTime::now() @@ -62,6 +62,6 @@ pub(crate) fn parse_bolt12_invoice(invoice: &str) -> Result { let data = Vec::::from_base32(&data)?; - lightning::offers::invoice::Bolt12Invoice::try_from(data) + sdk_common::lightning_125::offers::invoice::Bolt12Invoice::try_from(data) .map_err(|e| anyhow!("Failed to parse BOLT12: {e:?}")) }