Skip to content

Commit 8ae5a0f

Browse files
committed
Return BIP21 URI also when only non-bitcoin asset_id is defined
1 parent 2e7501a commit 8ae5a0f

File tree

4 files changed

+25
-23
lines changed

4 files changed

+25
-23
lines changed

cli/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ lwk_wollet = { git = "https://github.com/dangeross/lwk", branch = "savage-full-s
3131
#lwk_wollet = "0.8.0"
3232
rusqlite = { version = "0.31", features = ["backup", "bundled"] }
3333
rusqlite_migration = "1.0"
34-
sdk-common = { git = "https://github.com/breez/breez-sdk", rev = "2d1b3193e838fd245c78806ec5b68826b0d7b156", features = ["liquid"] }
34+
sdk-common = { git = "https://github.com/breez/breez-sdk", rev = "5a20b38b4c3b574282e8d6e5a61750bb7f4bebed", features = ["liquid"] }
3535
serde = { version = "1.0.197", features = ["derive"] }
3636
serde_json = "1.0.116"
3737
strum = "0.25"

lib/core/src/sdk.rs

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,35 +2033,37 @@ impl LiquidSdk {
20332033
self.receive_onchain(amount_sat, *fees_sat).await
20342034
}
20352035
PaymentMethod::LiquidAddress => {
2036+
let lbtc_asset_id = self.config.lbtc_asset_id();
20362037
let (asset_id, amount, amount_sat) = match amount.clone() {
20372038
Some(ReceiveAmount::Asset {
20382039
asset_id,
20392040
payer_amount,
20402041
}) => (asset_id, payer_amount, None),
20412042
Some(ReceiveAmount::Bitcoin { payer_amount_sat }) => {
2042-
(self.config.lbtc_asset_id(), None, Some(payer_amount_sat))
2043+
(lbtc_asset_id.clone(), None, Some(payer_amount_sat))
20432044
}
2044-
None => (self.config.lbtc_asset_id(), None, None),
2045+
None => (lbtc_asset_id.clone(), None, None),
20452046
};
20462047

20472048
let address = self.onchain_wallet.next_unused_address().await?.to_string();
2048-
let receive_destination = if amount.is_some() || amount_sat.is_some() {
2049-
LiquidAddressData {
2050-
address: address.to_string(),
2051-
network: self.config.network.into(),
2052-
amount,
2053-
amount_sat,
2054-
asset_id: Some(asset_id.clone()),
2055-
label: None,
2056-
message: req.description.clone(),
2057-
}
2058-
.to_uri()
2059-
.map_err(|e| PaymentError::Generic {
2060-
err: format!("Could not build BIP21 URI: {e:?}"),
2061-
})?
2062-
} else {
2063-
address
2064-
};
2049+
let receive_destination =
2050+
if asset_id.ne(&lbtc_asset_id) || amount.is_some() || amount_sat.is_some() {
2051+
LiquidAddressData {
2052+
address: address.to_string(),
2053+
network: self.config.network.into(),
2054+
amount,
2055+
amount_sat,
2056+
asset_id: Some(asset_id),
2057+
label: None,
2058+
message: req.description.clone(),
2059+
}
2060+
.to_uri()
2061+
.map_err(|e| PaymentError::Generic {
2062+
err: format!("Could not build BIP21 URI: {e:?}"),
2063+
})?
2064+
} else {
2065+
address
2066+
};
20652067

20662068
Ok(ReceivePaymentResponse {
20672069
destination: receive_destination,
@@ -3287,7 +3289,7 @@ impl LiquidSdk {
32873289

32883290
let res = match input_type {
32893291
InputType::LiquidAddress { ref address } => match &address.asset_id {
3290-
Some(asset_id) if asset_id.eq(&self.config.lbtc_asset_id()).not() => {
3292+
Some(asset_id) if asset_id.ne(&self.config.lbtc_asset_id()) => {
32913293
let asset_metadata = self.persister.get_asset_metadata(asset_id)?.ok_or(
32923294
PaymentError::AssetError {
32933295
err: format!("Asset {asset_id} is not supported"),

0 commit comments

Comments
 (0)