Skip to content
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9eab88d
Use lightning-kmp with taproot swaps and rotation
dpad85 Feb 15, 2024
ab0bb12
(android) Use taproot-rotated addresses by default (wip)
dpad85 Feb 6, 2024
523bd9d
(android) Terminate the channels-watcher business properly
dpad85 Feb 6, 2024
8b8d622
Rename bitcoin uri errors and fix tests
dpad85 Feb 7, 2024
ed430eb
(android) Move swap addresses to wallet-info view
dpad85 Feb 8, 2024
c56b6d9
Fix method parsing address to script
dpad85 Feb 12, 2024
e3d8bef
(android) Use modern descriptor in wallet info
dpad85 Feb 15, 2024
0890840
(android) Update wording for address format setting
dpad85 Feb 15, 2024
4c3682d
(ios) Updating code to use taproot address
robbiehanson Feb 15, 2024
a55bc15
(ios) Adding sheet to allow selection of legacy address
robbiehanson Feb 16, 2024
d51c743
(ios) Add "swap-in addresses" view
robbiehanson Feb 19, 2024
050519c
Update for latest lightning-kmp master
dpad85 Feb 20, 2024
304be64
(android) Update android app for latest api changes
dpad85 Feb 20, 2024
cb821aa
(ios) Update iOS app following API changes (WIP)
dpad85 Feb 20, 2024
55e4e4c
Update to use chain as a non-inner class
dpad85 Feb 20, 2024
1328643
(android) Update to user Chain as a non-inner class
dpad85 Feb 20, 2024
fe2b5ff
(ios) Update to use Chain and Bolt11Invoice
dpad85 Feb 20, 2024
1ab1fa0
(ios) Fixing remaining compiler issue
robbiehanson Feb 20, 2024
25b035b
Remove redundant extension for PaymentRequest
dpad85 Feb 21, 2024
4a85828
(ios) Fixing crash due to missing logger setup
robbiehanson Feb 21, 2024
cbc9424
Update to latest bolt11/bolt12 changes (wip)
dpad85 Feb 21, 2024
c1ce479
(android) Remove navigation animation introduced with kotlin update
dpad85 Feb 21, 2024
3ca411b
Use lightning-kmp 1.6.0 tag
dpad85 Feb 21, 2024
391f2b0
(ios) Fixing remaining compiler issues
robbiehanson Feb 21, 2024
4eb52a2
Fix tests
dpad85 Feb 21, 2024
a332038
Cancel channels-watcher before starting node
dpad85 Feb 21, 2024
0483b37
Update gradle build to kotlin mpp hierarchy
dpad85 Feb 21, 2024
827068d
(android) Rollback navigation version to 2.6.0
dpad85 Feb 22, 2024
a43cc43
Use lightning-kmp 1.6.1
dpad85 Feb 22, 2024
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
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
object Versions {
const val lightningKmp = "1.6-SNAPSHOT"
const val secp256k1 = "0.13.0"
const val lightningKmp = "1.6.0"
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 @@ -21,6 +21,8 @@ import android.content.Intent
import android.net.Uri
import android.os.Build
import android.text.format.DateUtils
import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -81,8 +83,9 @@ import fr.acinq.phoenix.android.settings.fees.AdvancedIncomingFeePolicy
import fr.acinq.phoenix.android.settings.fees.LiquidityPolicyView
import fr.acinq.phoenix.android.payments.liquidity.RequestLiquidityView
import fr.acinq.phoenix.android.settings.walletinfo.FinalWalletInfo
import fr.acinq.phoenix.android.settings.walletinfo.SwapInAddresses
import fr.acinq.phoenix.android.settings.walletinfo.SwapInSignerView
import fr.acinq.phoenix.android.settings.walletinfo.SwapInWalletInfo
import fr.acinq.phoenix.android.settings.walletinfo.SwapInWallet
import fr.acinq.phoenix.android.settings.walletinfo.WalletInfoView
import fr.acinq.phoenix.android.startup.LegacySwitcherView
import fr.acinq.phoenix.android.startup.StartupView
Expand Down Expand Up @@ -165,7 +168,14 @@ fun AppView(
.fillMaxHeight()
) {

NavHost(navController = navController, startDestination = "${Screen.Startup.route}?next={next}") {
NavHost(
navController = navController,
startDestination = "${Screen.Startup.route}?next={next}",
enterTransition = { EnterTransition.None },
exitTransition = { ExitTransition.None },
popEnterTransition = { EnterTransition.None },
popExitTransition = { ExitTransition.None },
) {
composable(
route = "${Screen.Startup.route}?next={next}",
arguments = listOf(
Expand Down Expand Up @@ -390,6 +400,7 @@ fun AppView(
onBackClick = { navController.popBackStack() },
onLightningWalletClick = { navController.navigate(Screen.Channels.route) },
onSwapInWalletClick = { navController.navigate(Screen.WalletInfo.SwapInWallet.route) },
onSwapInWalletInfoClick = { navController.navigate(Screen.WalletInfo.SwapInAddresses.route) },
onFinalWalletClick = { navController.navigate(Screen.WalletInfo.FinalWallet.route) },
)
}
Expand All @@ -399,12 +410,15 @@ fun AppView(
navDeepLink { uriPattern = "phoenix:swapinwallet" }
)
) {
SwapInWalletInfo(
SwapInWallet(
onBackClick = { navController.popBackStack() },
onViewChannelPolicyClick = { navController.navigate(Screen.LiquidityPolicy.route) },
onAdvancedClick = { navController.navigate(Screen.WalletInfo.SwapInSigner.route) },
)
}
composable(Screen.WalletInfo.SwapInAddresses.route) {
SwapInAddresses(onBackClick = { navController.popBackStack() })
}
composable(Screen.WalletInfo.SwapInSigner.route) {
SwapInSignerView(onBackClick = { navController.popBackStack() })
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ sealed class Screen(val route: String) {
object Logs : Screen("settings/logs")
object WalletInfo : Screen("settings/walletinfo") {
object SwapInWallet: Screen("settings/walletinfo/swapin")
object SwapInAddresses: Screen("settings/walletinfo/swapinaddresses")
object SwapInSigner: Screen("settings/walletinfo/swapinsigner")
object FinalWallet: Screen("settings/walletinfo/final")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,23 @@ fun WebLink(
)
}

@Composable
fun AddressLinkButton(
modifier: Modifier = Modifier,
address: String,
) {
WebLink(
text = address,
url = addressUrl(address = address),
space = 4.dp,
maxLines = 1,
fontSize = 15.sp,
iconSize = 14.dp,
onClickLabel = stringResource(id = R.string.accessibility_address_explorer_link),
modifier = modifier,
)
}

@Composable
fun TransactionLinkButton(
modifier: Modifier = Modifier,
Expand All @@ -422,6 +439,11 @@ fun txUrl(txId: TxId): String {
return business.blockchainExplorer.txUrl(txId = txId, website = BlockchainExplorer.Website.MempoolSpace)
}

@Composable
fun addressUrl(address: String): String {
return business.blockchainExplorer.addressUrl(addr = address, website = BlockchainExplorer.Website.MempoolSpace)
}

fun openLink(context: Context, link: String) {
context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(link)))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* Copyright 2024 ACINQ SAS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package fr.acinq.phoenix.android.components

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import fr.acinq.phoenix.android.R


@Composable
fun MenuButton(
text: String,
onClick: () -> Unit,
modifier: Modifier = Modifier,
textStyle: TextStyle = MaterialTheme.typography.body1,
icon: Int? = null,
iconTint: Color = MaterialTheme.colors.onSurface,
iconSpace: Dp = 12.dp,
padding: PaddingValues = PaddingValues(horizontal = 16.dp, vertical = 16.dp),
enabled: Boolean = true,
) {
MenuButton(
content = {
Text(
text = text,
style = textStyle,
textAlign = TextAlign.Start
)
},
onClick = onClick,
modifier = modifier,
icon = icon,
iconTint = iconTint,
iconSpace = iconSpace,
padding = padding,
enabled = enabled,
)
}

@Composable
fun MenuButton(
content: @Composable () -> Unit,
onClick: () -> Unit,
modifier: Modifier = Modifier,
onClickLabel: String? = null,
icon: Int? = null,
iconTint: Color = MaterialTheme.colors.onSurface,
iconSpace: Dp = 12.dp,
padding: PaddingValues = PaddingValues(horizontal = 16.dp, vertical = 16.dp),
enabled: Boolean = true,
) {
Row(
modifier = modifier
.clickable(
onClick = onClick,
enabled = enabled,
role = Role.Button,
onClickLabel = onClickLabel,
)
.padding(padding),
horizontalArrangement = Arrangement.Start,
verticalAlignment = Alignment.CenterVertically,
) {
if (icon != null) {
PhoenixIcon(resourceId = icon, tint = iconTint)
Spacer(modifier = Modifier.width(iconSpace))
}
Box(modifier = Modifier.weight(1f)) {
content()
}
PhoenixIcon(resourceId = R.drawable.ic_chevron_right, tint = MaterialTheme.typography.caption.color.copy(alpha = 0.6f))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,13 @@ private fun <T> PreferenceDialogItem(
Row(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 8.dp, vertical = 3.dp),
verticalAlignment = Alignment.CenterVertically
.padding(horizontal = 8.dp),
) {
RadioButton(selected = selected, onClick = { onClick(item) })
Spacer(modifier = Modifier.width(2.dp))
Column {
Column(modifier = Modifier.padding(vertical = 12.dp)) {
Text(text = item.title)
item.description?.let {
Spacer(modifier = Modifier.height(4.dp))
Text(text = it, style = MaterialTheme.typography.subtitle2)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -99,6 +100,7 @@ fun SettingWithCopy(
}
}

/** Static setting with composable description, and decoration to the left of the title. */
@Composable
fun SettingWithDecoration(
modifier: Modifier = Modifier,
Expand Down Expand Up @@ -162,7 +164,7 @@ fun SettingInteractive(
Column(
modifier
.fillMaxWidth()
.clickable(onClick = { if (enabled) onClick() })
.clickable(onClickLabel = title, role = Role.Button, onClick = { if (enabled) onClick() })
.enableOrFade(enabled)
.padding(horizontal = 16.dp, vertical = 12.dp),
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ fun ScanDataView(
onScannedText = { postIntent(Scan.Intent.Parse(request = it)) }
)
}
is Scan.Model.InvoiceFlow.InvoiceRequest -> {
SendLightningPaymentView(
paymentRequest = model.paymentRequest,
is Scan.Model.Bolt11InvoiceFlow.Bolt11InvoiceRequest -> {
SendBolt11PaymentView(
invoice = model.invoice,
trampolineFees = trampolineFees,
onBackClick = onBackClick,
onPayClick = { postIntent(it) }
)
}
Scan.Model.InvoiceFlow.Sending -> {
Scan.Model.Bolt11InvoiceFlow.Sending -> {
LaunchedEffect(key1 = Unit) { onBackClick() }
}
is Scan.Model.OnchainFlow -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import fr.acinq.lightning.TrampolineFees
import fr.acinq.lightning.payment.PaymentRequest
import fr.acinq.lightning.payment.Bolt11Invoice
import fr.acinq.phoenix.android.LocalBitcoinUnit
import fr.acinq.phoenix.android.R
import fr.acinq.phoenix.android.business
Expand All @@ -42,17 +42,17 @@ import fr.acinq.phoenix.controllers.payments.Scan
import fr.acinq.phoenix.utils.extensions.isAmountlessTrampoline

@Composable
fun SendLightningPaymentView(
paymentRequest: PaymentRequest,
fun SendBolt11PaymentView(
invoice: Bolt11Invoice,
trampolineFees: TrampolineFees?,
onBackClick: () -> Unit,
onPayClick: (Scan.Intent.InvoiceFlow.SendInvoicePayment) -> Unit
onPayClick: (Scan.Intent.Bolt11InvoiceFlow.SendBolt11Invoice) -> Unit
) {
val context = LocalContext.current
val balance = business.balanceManager.balance.collectAsState(null).value
val prefBitcoinUnit = LocalBitcoinUnit.current

val requestedAmount = paymentRequest.amount
val requestedAmount = invoice.amount
var amount by remember { mutableStateOf(requestedAmount) }
var amountErrorMessage by remember { mutableStateOf("") }

Expand Down Expand Up @@ -88,17 +88,17 @@ fun SendLightningPaymentView(
)
}
) {
paymentRequest.description?.takeIf { it.isNotBlank() }?.let {
invoice.description?.takeIf { it.isNotBlank() }?.let {
SplashLabelRow(label = stringResource(R.string.send_description_label)) {
Text(text = it)
}
}
SplashLabelRow(label = stringResource(R.string.send_destination_label), icon = R.drawable.ic_zap) {
SelectionContainer {
Text(text = paymentRequest.nodeId.toHex(), maxLines = 2, overflow = TextOverflow.Ellipsis)
Text(text = invoice.nodeId.toHex(), maxLines = 2, overflow = TextOverflow.Ellipsis)
}
}
if (paymentRequest.isAmountlessTrampoline()) {
if (invoice.isAmountlessTrampoline()) {
SplashLabelRow(label = "", helpMessage = stringResource(id = R.string.send_trampoline_amountless_warning_details)) {
Text(text = stringResource(id = R.string.send_trampoline_amountless_warning_label))
}
Expand All @@ -123,7 +123,7 @@ fun SendLightningPaymentView(
enabled = mayDoPayments && amount != null && amountErrorMessage.isBlank() && trampolineFees != null,
) {
safeLet(amount, trampolineFees) { amt, fees ->
onPayClick(Scan.Intent.InvoiceFlow.SendInvoicePayment(paymentRequest = paymentRequest, amount = amt, trampolineFees = fees))
onPayClick(Scan.Intent.Bolt11InvoiceFlow.SendBolt11Invoice(invoice = invoice, amount = amt, trampolineFees = fees))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ import fr.acinq.phoenix.data.WalletPaymentId
import fr.acinq.phoenix.data.WalletPaymentInfo
import fr.acinq.phoenix.data.lnurl.LnurlPay
import fr.acinq.phoenix.utils.extensions.WalletPaymentState
import fr.acinq.phoenix.utils.extensions.errorMessage
import fr.acinq.phoenix.utils.extensions.minDepthForFunding
import fr.acinq.phoenix.utils.extensions.state
import io.ktor.http.Url
Expand Down
Loading