Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Tor embedded library and use onion addresses #662

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
object Versions {
const val lightningKmp = "1.8.4"
const val secp256k1 = "0.14.0"
const val torMobile = "0.2.0"

const val kotlin = "1.9.22"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ import fr.acinq.phoenix.android.services.NodeServiceState
import fr.acinq.phoenix.android.settings.AboutView
import fr.acinq.phoenix.android.settings.AppAccessSettings
import fr.acinq.phoenix.android.settings.DisplayPrefsView
import fr.acinq.phoenix.android.settings.ElectrumView
import fr.acinq.phoenix.android.settings.electrum.ElectrumView
import fr.acinq.phoenix.android.settings.ExperimentalView
import fr.acinq.phoenix.android.settings.ForceCloseView
import fr.acinq.phoenix.android.settings.LogsView
Expand Down Expand Up @@ -366,7 +366,7 @@ fun AppView(
ElectrumView()
}
composable(Screen.TorConfig.route) {
TorConfigView()
TorConfigView(appViewModel = appVM, onBackClick = { navController.popBackStack() }, onBusinessTeardown = { navController.popToHome() })
}
composable(Screen.Channels.route) {
ChannelsView(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ fun Dialog(
title: String? = null,
properties: DialogProperties = DialogProperties(usePlatformDefaultWidth = false),
isScrollable: Boolean = true,
buttonsTopMargin: Dp = 24.dp,
buttons: (@Composable RowScope.() -> Unit)? = { Button(onClick = onDismiss, text = stringResource(id = R.string.btn_ok), padding = PaddingValues(16.dp)) },
buttonsTopMargin: Dp = 20.dp,
buttons: (@Composable RowScope.() -> Unit)? = { Button(onClick = onDismiss, text = stringResource(id = R.string.btn_ok), padding = PaddingValues(16.dp), shape = RoundedCornerShape(16.dp)) },
content: @Composable ColumnScope.() -> Unit,
) {
androidx.compose.ui.window.Dialog(onDismissRequest = onDismiss, properties = properties) {
Expand All @@ -79,10 +79,7 @@ fun Dialog(
// buttons
if (buttons != null) {
Spacer(Modifier.height(buttonsTopMargin))
Row(
modifier = Modifier
.align(Alignment.End)
) {
Row(modifier = Modifier.align(Alignment.End).padding(8.dp)) {
buttons()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ fun ProgressView(
progressCircleSize: Dp = 20.dp,
progressCircleWidth: Dp = 2.dp,
space: Dp = 8.dp,
horizontalArrangement: Arrangement.Horizontal = Arrangement.Start,
) {
Row(
modifier.padding(padding),
horizontalArrangement = horizontalArrangement,
) {
CircularProgressIndicator(Modifier.size(progressCircleSize), strokeWidth = progressCircleWidth)
Spacer(Modifier.width(space))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ package fr.acinq.phoenix.android.home

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
Expand All @@ -30,24 +32,27 @@ import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import fr.acinq.lightning.utils.Connection
import fr.acinq.phoenix.android.R
import fr.acinq.phoenix.android.components.Card
import fr.acinq.phoenix.android.components.Dialog
import fr.acinq.phoenix.android.components.HSeparator
import fr.acinq.phoenix.android.components.TextWithIcon
import fr.acinq.phoenix.android.userPrefs
import fr.acinq.phoenix.android.utils.extensions.isBadCertificate
import fr.acinq.phoenix.android.utils.monoTypo
import fr.acinq.phoenix.android.utils.mutedBgColor
import fr.acinq.phoenix.android.utils.negativeColor
import fr.acinq.phoenix.android.utils.orange
import fr.acinq.phoenix.android.utils.positiveColor
import fr.acinq.phoenix.managers.Connections
import fr.acinq.phoenix.utils.extensions.isOnion


@Composable
Expand All @@ -66,52 +71,45 @@ fun ConnectionDialog(
modifier = Modifier.padding(top = 16.dp, start = 24.dp, end = 24.dp)
)
} else {
if (connections.electrum != Connection.ESTABLISHED || connections.peer != Connection.ESTABLISHED) {
val hasConnectionIssues = connections.electrum != Connection.ESTABLISHED || connections.peer != Connection.ESTABLISHED
if (hasConnectionIssues) {
Text(text = stringResource(id = R.string.conndialog_summary_not_ok), Modifier.padding(horizontal = 24.dp))
}
Spacer(modifier = Modifier.height(24.dp))
Spacer(modifier = Modifier.height(16.dp))
HSeparator()

val isTorEnabled = userPrefs.getIsTorEnabled.collectAsState(initial = null).value
if (isTorEnabled != null && isTorEnabled) {
ConnectionDialogLine(label = stringResource(id = R.string.conndialog_tor), connection = connections.tor, onClick = onTorClick)
HSeparator()
}

ConnectionDialogLine(label = stringResource(id = R.string.conndialog_electrum), connection = connections.electrum, onClick = onElectrumClick) {
when (val connection = connections.electrum) {
Connection.ESTABLISHING -> {
Text(text = stringResource(R.string.conndialog_connecting), style = monoTypo)
}
Connection.ESTABLISHED -> {
Column {
Text(text = stringResource(R.string.conndialog_connected), style = monoTypo)
if (electrumBlockheight < 795_000) { // FIXME use a dynamic blockheight
TextWithIcon(
text = stringResource(id = R.string.conndialog_connected_electrum_behind, electrumBlockheight),
textStyle = MaterialTheme.typography.body1.copy(fontSize = 14.sp),
icon = R.drawable.ic_alert_triangle,
iconTint = negativeColor
)
}
}
Text(text = stringResource(R.string.conndialog_connected), style = monoTypo)
}
else -> {
Text(
text = if (connection is Connection.CLOSED && connection.isBadCertificate()) {
stringResource(R.string.conndialog_closed_bad_cert)
} else {
stringResource(R.string.conndialog_closed)
},
style = monoTypo
)
val customElectrumServer by userPrefs.getElectrumServer.collectAsState(initial = null)
if (customElectrumServer?.isOnion == false) {
TextWithIcon(text = stringResource(R.string.conndialog_electrum_not_onion), textStyle = monoTypo, icon = R.drawable.ic_alert_triangle, iconTint = negativeColor)
} else if (connection is Connection.CLOSED && connection.isBadCertificate()) {
TextWithIcon(text = stringResource(R.string.conndialog_closed_bad_cert), textStyle = monoTypo, icon = R.drawable.ic_alert_triangle, iconTint = negativeColor)
} else {
Text(text = stringResource(R.string.conndialog_closed), style = monoTypo)
}
}
}
}
HSeparator()
ConnectionDialogLine(label = stringResource(id = R.string.conndialog_lightning), connection = connections.peer)
HSeparator()
Spacer(Modifier.height(16.dp))

val isTorEnabled = userPrefs.getIsTorEnabled.collectAsState(initial = null).value
if (hasConnectionIssues && isTorEnabled == true) {
Card(backgroundColor = mutedBgColor, modifier = Modifier.fillMaxWidth(), internalPadding = PaddingValues(horizontal = 16.dp, vertical = 12.dp), onClick = onTorClick) {
TextWithIcon(text = stringResource(id = R.string.conndialog_tor_disclaimer_title), icon = R.drawable.ic_tor_shield, textStyle = MaterialTheme.typography.body2)
Spacer(modifier = Modifier.height(4.dp))
Text(text = stringResource(id = R.string.conndialog_tor_disclaimer_body))
}
}
}
}
}
Expand Down Expand Up @@ -147,7 +145,7 @@ private fun ConnectionDialogLine(
.then(
if (onClick != null) Modifier.clickable(role = Role.Button, onClickLabel = stringResource(id = R.string.conndialog_accessibility_desc, label), onClick = onClick) else Modifier
)
.padding(vertical = 12.dp, horizontal = 24.dp),
.padding(vertical = 16.dp, horizontal = 24.dp),
verticalAlignment = Alignment.CenterVertically
) {
Surface(
Expand All @@ -161,6 +159,7 @@ private fun ConnectionDialogLine(
) {}
Spacer(modifier = Modifier.width(16.dp))
Text(text = label, modifier = Modifier.weight(1.0f))
Spacer(modifier = Modifier.width(24.dp))
content()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fun HomeBalance(
balanceDisplayMode: HomeAmountDisplayMode,
) {
if (balance == null) {
ProgressView(modifier = modifier, text = stringResource(id = R.string.home__balance_loading))
ProgressView(modifier = modifier, text = stringResource(id = R.string.home_balance_loading))
} else {
val isAmountRedacted = balanceDisplayMode == HomeAmountDisplayMode.REDACTED
Column(
Expand Down Expand Up @@ -136,7 +136,7 @@ private fun OnChainBalance(
) {
TextWithIcon(
text = if (balanceDisplayMode == HomeAmountDisplayMode.REDACTED) "****" else {
stringResource(id = R.string.home__onchain_incoming, availableOnchainBalance.toPrettyString(preferredAmountUnit, fiatRate, withUnit = true))
stringResource(id = R.string.home_onchain_incoming, availableOnchainBalance.toPrettyString(preferredAmountUnit, fiatRate, withUnit = true))
},
textStyle = MaterialTheme.typography.caption,
icon = R.drawable.ic_chain,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import fr.acinq.lightning.utils.sat
import fr.acinq.phoenix.android.PaymentRowState
import fr.acinq.phoenix.android.PaymentsViewModel
import fr.acinq.phoenix.android.R
Expand All @@ -57,7 +56,7 @@ fun ColumnScope.PaymentsList(
Column(modifier = modifier.weight(1f, fill = true), horizontalAlignment = Alignment.CenterHorizontally) {
if (payments.isEmpty()) {
Text(
text = stringResource(id = R.string.home__payments_none),
text = stringResource(id = R.string.home_payments_none),
style = MaterialTheme.typography.caption.copy(textAlign = TextAlign.Center, fontSize = 14.sp),
modifier = Modifier
.padding(horizontal = 32.dp)
Expand Down Expand Up @@ -87,7 +86,7 @@ private fun ColumnScope.LatestPaymentsList(
) {
val morePaymentsButton: @Composable () -> Unit = {
FilledButton(
text = stringResource(id = R.string.home__payments_more_button),
text = stringResource(id = R.string.home_payments_more_button),
icon = R.drawable.ic_chevron_down,
iconTint = MaterialTheme.typography.caption.color,
onClick = onPaymentsHistoryClick,
Expand Down
Loading