Skip to content

Commit b5a3372

Browse files
committed
Return BIP21 URI also when only non-bitcoin asset_id is defined
1 parent ed88821 commit b5a3372

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
@@ -2042,35 +2042,37 @@ impl LiquidSdk {
20422042
self.receive_onchain(amount_sat, *fees_sat).await
20432043
}
20442044
PaymentMethod::LiquidAddress => {
2045+
let lbtc_asset_id = self.config.lbtc_asset_id();
20452046
let (asset_id, amount, amount_sat) = match amount.clone() {
20462047
Some(ReceiveAmount::Asset {
20472048
asset_id,
20482049
payer_amount,
20492050
}) => (asset_id, payer_amount, None),
20502051
Some(ReceiveAmount::Bitcoin { payer_amount_sat }) => {
2051-
(self.config.lbtc_asset_id(), None, Some(payer_amount_sat))
2052+
(lbtc_asset_id.clone(), None, Some(payer_amount_sat))
20522053
}
2053-
None => (self.config.lbtc_asset_id(), None, None),
2054+
None => (lbtc_asset_id.clone(), None, None),
20542055
};
20552056

20562057
let address = self.onchain_wallet.next_unused_address().await?.to_string();
2057-
let receive_destination = if amount.is_some() || amount_sat.is_some() {
2058-
LiquidAddressData {
2059-
address: address.to_string(),
2060-
network: self.config.network.into(),
2061-
amount,
2062-
amount_sat,
2063-
asset_id: Some(asset_id.clone()),
2064-
label: None,
2065-
message: req.description.clone(),
2066-
}
2067-
.to_uri()
2068-
.map_err(|e| PaymentError::Generic {
2069-
err: format!("Could not build BIP21 URI: {e:?}"),
2070-
})?
2071-
} else {
2072-
address
2073-
};
2058+
let receive_destination =
2059+
if asset_id.ne(&lbtc_asset_id) || amount.is_some() || amount_sat.is_some() {
2060+
LiquidAddressData {
2061+
address: address.to_string(),
2062+
network: self.config.network.into(),
2063+
amount,
2064+
amount_sat,
2065+
asset_id: Some(asset_id),
2066+
label: None,
2067+
message: req.description.clone(),
2068+
}
2069+
.to_uri()
2070+
.map_err(|e| PaymentError::Generic {
2071+
err: format!("Could not build BIP21 URI: {e:?}"),
2072+
})?
2073+
} else {
2074+
address
2075+
};
20742076

20752077
Ok(ReceivePaymentResponse {
20762078
destination: receive_destination,
@@ -3303,7 +3305,7 @@ impl LiquidSdk {
33033305

33043306
let res = match input_type {
33053307
InputType::LiquidAddress { ref address } => match &address.asset_id {
3306-
Some(asset_id) if asset_id.eq(&self.config.lbtc_asset_id()).not() => {
3308+
Some(asset_id) if asset_id.ne(&self.config.lbtc_asset_id()) => {
33073309
let asset_metadata = self.persister.get_asset_metadata(asset_id)?.ok_or(
33083310
PaymentError::AssetError {
33093311
err: format!("Asset {asset_id} is not supported"),

0 commit comments

Comments
 (0)