Skip to content

Commit cb641ae

Browse files
committed
fix: display only address on details
1 parent 74aba74 commit cb641ae

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

app/src/main/java/to/bitkit/ui/screens/wallets/receive/ReceiveInvoiceUtils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fun getInvoiceForTab(
4545
* @param fallbackAddress Fallback address if BIP21 is empty or invalid
4646
* @return BIP21 URI without the lightning parameter (e.g., bitcoin:address?amount=0.001)
4747
*/
48-
private fun removeLightningFromBip21(bip21: String, fallbackAddress: String): String {
48+
fun removeLightningFromBip21(bip21: String, fallbackAddress: String): String {
4949
if (bip21.isBlank()) return fallbackAddress
5050

5151
// Remove lightning parameter using regex

app/src/main/java/to/bitkit/ui/screens/wallets/receive/ReceiveQrScreen.kt

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ fun ReceiveQrScreen(
193193
showDetails -> {
194194
ReceiveDetailsView(
195195
tab = selectedTab,
196-
onchainAddress = walletState.onchainAddress,
197-
bolt11 = walletState.bolt11,
196+
walletState = walletState,
198197
cjitInvoice = cjitInvoice,
199198
modifier = Modifier.weight(1f)
200199
)
@@ -414,8 +413,7 @@ fun CjitOnBoardingView(modifier: Modifier = Modifier) {
414413
@Composable
415414
private fun ReceiveDetailsView(
416415
tab: ReceiveTab,
417-
onchainAddress: String,
418-
bolt11: String,
416+
walletState: MainUiState,
419417
cjitInvoice: String?,
420418
modifier: Modifier = Modifier,
421419
) {
@@ -427,10 +425,14 @@ private fun ReceiveDetailsView(
427425
Column {
428426
when (tab) {
429427
ReceiveTab.SAVINGS -> {
430-
if (onchainAddress.isNotEmpty()) {
428+
if (walletState.onchainAddress.isNotEmpty()) {
431429
CopyAddressCard(
432430
title = stringResource(R.string.wallet__receive_bitcoin_invoice),
433-
address = onchainAddress,
431+
address = removeLightningFromBip21(
432+
bip21 = walletState.bip21,
433+
fallbackAddress = walletState.onchainAddress
434+
),
435+
body = walletState.onchainAddress,
434436
type = CopyAddressType.ONCHAIN,
435437
testTag = "ReceiveOnchainAddress",
436438
)
@@ -439,29 +441,33 @@ private fun ReceiveDetailsView(
439441

440442
ReceiveTab.AUTO -> {
441443
// Show both onchain AND lightning if available
442-
if (onchainAddress.isNotEmpty()) {
444+
if (walletState.onchainAddress.isNotEmpty()) {
443445
CopyAddressCard(
444446
title = stringResource(R.string.wallet__receive_bitcoin_invoice),
445-
address = onchainAddress,
447+
address = removeLightningFromBip21(
448+
bip21 = walletState.bip21,
449+
fallbackAddress = walletState.onchainAddress
450+
),
451+
body = walletState.onchainAddress,
446452
type = CopyAddressType.ONCHAIN,
447453
testTag = "ReceiveOnchainAddress",
448454
)
449455
}
450-
if (cjitInvoice != null || bolt11.isNotEmpty()) {
456+
if (cjitInvoice != null || walletState.bolt11.isNotEmpty()) {
451457
CopyAddressCard(
452458
title = stringResource(R.string.wallet__receive_lightning_invoice),
453-
address = cjitInvoice ?: bolt11,
459+
address = cjitInvoice ?: walletState.bolt11,
454460
type = CopyAddressType.LIGHTNING,
455461
testTag = "ReceiveLightningAddress",
456462
)
457463
}
458464
}
459465

460466
ReceiveTab.SPENDING -> {
461-
if (cjitInvoice != null || bolt11.isNotEmpty()) {
467+
if (cjitInvoice != null || walletState.bolt11.isNotEmpty()) {
462468
CopyAddressCard(
463469
title = stringResource(R.string.wallet__receive_lightning_invoice),
464-
address = cjitInvoice ?: bolt11,
470+
address = cjitInvoice ?: walletState.bolt11,
465471
type = CopyAddressType.LIGHTNING,
466472
testTag = "ReceiveLightningAddress",
467473
)
@@ -478,6 +484,7 @@ enum class CopyAddressType { ONCHAIN, LIGHTNING }
478484
@Composable
479485
private fun CopyAddressCard(
480486
title: String,
487+
body: String? = null,
481488
address: String,
482489
type: CopyAddressType,
483490
testTag: String? = null,
@@ -502,7 +509,7 @@ private fun CopyAddressCard(
502509
}
503510
Spacer(modifier = Modifier.height(16.dp))
504511
BodyS(
505-
text = address.truncate(32).uppercase(),
512+
text = (body ?: address).truncate(32).uppercase(),
506513
modifier = testTag?.let { Modifier.testTag(it) } ?: Modifier
507514
)
508515
Spacer(modifier = Modifier.height(16.dp))
@@ -751,8 +758,10 @@ private fun PreviewDetailsMode() {
751758
) {
752759
ReceiveDetailsView(
753760
tab = ReceiveTab.AUTO,
754-
onchainAddress = "bcrt1qfserxgtuesul4m9zva56wzk849yf9l8rk4qy0l",
755-
bolt11 = "lnbcrt500u1pn7umn7pp5x0s9lt9fwrff6rp70pz3guwnjgw97sjuv79...",
761+
walletState = MainUiState(
762+
onchainAddress = "bcrt1qfserxgtuesul4m9zva56wzk849yf9l8rk4qy0l",
763+
bolt11 = "lnbcrt500u1pn7umn7pp5x0s9lt9fwrff6rp70pz3guwnjgw97sjuv79...",
764+
),
756765
cjitInvoice = null,
757766
modifier = Modifier.weight(1f)
758767
)

0 commit comments

Comments
 (0)