Skip to content
Merged
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: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ allprojects {
google()
mavenCentral()
maven("https://oss.sonatype.org/content/repositories/snapshots")
maven("https://central.sonatype.com/repository/maven-snapshots")
}
}

Expand Down
5 changes: 3 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[versions]
lightningkmp = "1.10.8"
secp256k1 = "0.19.0" # keep in check with lightning-kmp secp version
lightningkmp = "1.11.0"
secp256k1 = "0.21.0" # keep in check with lightning-kmp secp version

kotlin = "2.2.10"
ktor = "3.1.0"
sqldelight = "2.1.0"
okio = "3.15.0"
serialization = "1.9.0" # keep in check with lightning-kmp serialization version

# iOS
skie = "0.10.6"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ import fr.acinq.phoenix.android.components.dialogs.Dialog
import fr.acinq.phoenix.android.utils.converters.DateFormatter.toAbsoluteDateString
import fr.acinq.phoenix.android.utils.mutedBgColor
import kotlinx.datetime.*
import kotlin.time.ExperimentalTime

/**
* Calendar component to pick a day. [onDateSelected] returns the timestamp in millis at the
* **start** of day.
*/
@OptIn(ExperimentalTime::class)
@Composable
fun CalendarView(
label: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import fr.acinq.phoenix.android.AppViewModel
import fr.acinq.phoenix.android.settings.MutualCloseView
import fr.acinq.phoenix.android.settings.channels.ChannelDetailsView
import fr.acinq.phoenix.android.settings.channels.ChannelsView
import fr.acinq.phoenix.android.settings.channels.ImportChannelsData
import fr.acinq.phoenix.android.settings.channels.SpendFromChannelAddress

fun NavGraphBuilder.channelsNavGraph(navController: NavController, appViewModel: AppViewModel) {
Expand Down Expand Up @@ -56,12 +55,8 @@ fun NavGraphBuilder.channelsNavGraph(navController: NavController, appViewModel:
ChannelDetailsView(business = business, onBackClick = { navController.popBackStack() }, channelId = channelId)
}

businessComposable(Screen.BusinessNavGraph.ImportChannelsData.route, appViewModel) { _, _, business ->
ImportChannelsData(business = business, onBackClick = { navController.popBackStack() })
}

businessComposable(Screen.BusinessNavGraph.SpendChannelAddress.route, appViewModel) { _, _, business ->
SpendFromChannelAddress(business = business, onBackClick = { navController.popBackStack() })
// SpendFromChannelAddress(business = business, onBackClick = { navController.popBackStack() })
}

businessComposable(Screen.BusinessNavGraph.MutualClose.route, appViewModel) { _, walletId, business ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.MaterialTheme
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.draw.clip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ fun Bolt11InvoiceSection(
TechnicalRowAmount(label = stringResource(id = R.string.paymentdetails_invoice_requested_label), amount = it, rateThen = originalFiatRate)
}
(invoice.description ?: invoice.descriptionHash?.toHex())?.takeIf { it.isNotBlank() }?.let {
TechnicalRowSelectable(label = stringResource(id = R.string.paymentdetails_bolt11_description_label), value = it)
TechnicalRowWithCopy(label = stringResource(id = R.string.paymentdetails_bolt11_description_label), value = it)
}
TechnicalRowWithCopy(label = stringResource(id = R.string.paymentdetails_payment_hash_label), value = invoice.paymentHash.toHex())
preimage?.let { TechnicalRowWithCopy(label = stringResource(id = R.string.paymentdetails_preimage_label), value = preimage.toHex(), helpMessage = stringResource(id = R.string.paymentdetails_preimage_help)) }
Expand All @@ -178,13 +178,13 @@ fun Bolt12InvoiceSection(
TechnicalRowAmount(label = stringResource(id = R.string.paymentdetails_invoice_requested_label), amount = it, rateThen = originalFiatRate)
}
invoice.description?.takeIf { it.isNotBlank() }?.let {
TechnicalRowSelectable(label = stringResource(id = R.string.paymentdetails_bolt11_description_label), value = it)
TechnicalRowWithCopy(label = stringResource(id = R.string.paymentdetails_bolt11_description_label), value = it)
}
TechnicalRow(label = stringResource(id = R.string.paymentdetails_payerkey_label)) {
Text(text = payerKey.toHex())
val nodeParamsManager = LocalBusiness.current?.nodeParamsManager
val offerPayerKey by produceState<PrivateKey?>(initialValue = null, key1 = nodeParamsManager) {
value = nodeParamsManager?.defaultOffer()?.payerKey
value = nodeParamsManager?.defaultOffer()?.privateKey
}
if (offerPayerKey != null && payerKey == offerPayerKey) {
Spacer(modifier = Modifier.heightIn(4.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import fr.acinq.bitcoin.PublicKey
import fr.acinq.lightning.db.Bolt12IncomingPayment
import fr.acinq.lightning.utils.UUID
import fr.acinq.phoenix.PhoenixBusiness
import fr.acinq.phoenix.android.LocalBusiness
import fr.acinq.phoenix.android.R
import fr.acinq.phoenix.android.components.layouts.SplashLabelRow
import fr.acinq.phoenix.android.components.contact.ContactCompactView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import fr.acinq.phoenix.android.payments.details.TechnicalRowWithCopy
import fr.acinq.phoenix.android.payments.details.TimestampSection
import fr.acinq.phoenix.android.utils.converters.MSatDisplayPolicy
import fr.acinq.phoenix.data.ExchangeRate
import fr.acinq.phoenix.utils.extensions.description

@Composable
fun TechnicalIncomingBolt12(
Expand Down Expand Up @@ -75,10 +76,13 @@ fun IncomingBolt12Details(
amount = metadata.amount,
rateThen = originalFiatRate
)
metadata.description?.let { description ->
TechnicalRowWithCopy(label = stringResource(id = R.string.paymentdetails_bolt12_description_label), value = description)
}
TechnicalRowWithCopy(label = stringResource(id = R.string.paymentdetails_payment_hash_label), value = metadata.paymentHash.toHex())
TechnicalRowWithCopy(label = stringResource(id = R.string.paymentdetails_preimage_label), value = metadata.preimage.toHex())
TechnicalRowWithCopy(label = stringResource(id = R.string.paymentdetails_offer_metadata_label), value = metadata.encode().toHex())
if (metadata is OfferPaymentMetadata.V1) {
TechnicalRowSelectable(label = stringResource(id = R.string.paymentdetails_payerkey_label), value = metadata.payerKey.toHex())
metadata.payerKey?.let { payerKey ->
TechnicalRowSelectable(label = stringResource(id = R.string.paymentdetails_payerkey_label), value = payerKey.toHex())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,18 @@ import fr.acinq.phoenix.android.utils.logger
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.map
import kotlinx.datetime.Instant
import kotlin.time.Instant
import kotlinx.datetime.Month
import kotlinx.datetime.TimeZone
import kotlinx.datetime.daysUntil
import kotlinx.datetime.toInstant
import kotlinx.datetime.toJavaDayOfWeek
import kotlinx.datetime.toJavaMonth
import kotlinx.datetime.toKotlinLocalDateTime
import kotlinx.datetime.toLocalDateTime
import java.time.format.TextStyle
import java.util.Locale
import kotlin.time.ExperimentalTime


private sealed class PaymentsGroup {
Expand Down Expand Up @@ -94,6 +97,7 @@ private sealed class PaymentsGroup {
}
}

@OptIn(ExperimentalTime::class)
@Composable
fun PaymentsHistoryView(
onBackClick: () -> Unit,
Expand All @@ -111,7 +115,7 @@ fun PaymentsHistoryView(

val groupedPayments = remember(payments) {
val timezone = TimeZone.currentSystemDefault()
val (todaysDayOfWeek, today) = java.time.LocalDate.now().atTime(23, 59, 59).toKotlinLocalDateTime().let { it.dayOfWeek to it.toInstant(timezone) }
val (todaysDayOfWeek, today) = java.time.LocalDate.now().atTime(23, 59, 59).toKotlinLocalDateTime().let { it.dayOfWeek.toJavaDayOfWeek() to it.toInstant(timezone) }
payments.values.groupBy {
val paymentInstant = Instant.fromEpochMilliseconds(it.payment.createdAt)
val daysElapsed = paymentInstant.daysUntil(today, timezone)
Expand Down Expand Up @@ -189,7 +193,7 @@ fun PaymentsHistoryView(
PaymentsGroup.Yesterday -> stringResource(id = R.string.payments_history_yesterday)
PaymentsGroup.ThisWeek -> stringResource(id = R.string.payments_history_thisweek)
PaymentsGroup.LastWeek -> stringResource(id = R.string.payments_history_lastweek)
is PaymentsGroup.Other -> "${header.month.getDisplayName(TextStyle.FULL, Locale.getDefault()).uppercase()} ${header.year}"
is PaymentsGroup.Other -> "${header.month.toJavaMonth().getDisplayName(TextStyle.FULL, Locale.getDefault()).uppercase()} ${header.year}"
},
)
Spacer(modifier = Modifier.height(8.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ private fun EditInvoiceView(
onTextChange = onDescriptionChange,
staticLabel = stringResource(id = R.string.receive_lightning_edit_desc_label),
placeholder = { Text(text = stringResource(id = R.string.receive_lightning_edit_desc_placeholder), maxLines = 2, overflow = TextOverflow.Ellipsis) },
maxChars = 140,
maxChars = if (isReusable) 64 else 140,
minLines = 2,
maxLines = Int.MAX_VALUE,
modifier = Modifier.fillMaxWidth(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class ReceiveViewModel(

if (isReusable) {
val nodeParams = nodeParamsManager.nodeParams.filterNotNull().first()
val bolt12Offer = nodeParams.randomOffer(trampolineNodeId = NodeParamsManager.trampolineNodeId, amount = amount, description = description).first
val bolt12Offer = nodeParams.randomOffer(trampolineNodeId = NodeParamsManager.trampolineNodeId, amount = amount, description = description).offer
lightningQRBitmap = QRCodeHelper.generateBitmap(bolt12Offer.encode()).asImageBitmap()
log.debug("generated new bolt12 offer=${bolt12Offer.encode()}")
lightningInvoiceState = LightningInvoiceState.Done.Bolt12(bolt12Offer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import fr.acinq.phoenix.android.components.layouts.SplashLabelRow
import fr.acinq.phoenix.android.components.layouts.SplashLayout
import fr.acinq.phoenix.android.utils.converters.AmountFormatter.toPrettyString
import fr.acinq.phoenix.android.utils.extensions.safeLet
import fr.acinq.phoenix.utils.extensions.isAmountlessTrampoline
import kotlinx.coroutines.launch

@Composable
Expand Down Expand Up @@ -149,12 +148,6 @@ fun SendToBolt11View(
Text(text = invoice.nodeId.toHex(), maxLines = 2, overflow = TextOverflow.MiddleEllipsis)
}
}
if (invoice.isAmountlessTrampoline()) {
Spacer(modifier = Modifier.height(16.dp))
SplashLabelRow(label = "", helpMessage = stringResource(id = R.string.send_trampoline_amountless_warning_details)) {
Text(text = stringResource(id = R.string.send_trampoline_amountless_warning_label))
}
}
Spacer(modifier = Modifier.height(16.dp))
SplashLabelRow(label = stringResource(id = R.string.send_trampoline_fee_label)) {
val amt = amount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class SendOfferViewModel(
val useRandomKey = contact == null || !contact.useOfferKey
val payerKey = when (useRandomKey) {
true -> Lightning.randomKey()
false -> nodeParamsManager.defaultOffer().payerKey
false -> nodeParamsManager.defaultOffer().privateKey
}
val peer = peerManager.getPeer()
val payerNote = message.takeIf { it.isNotBlank() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ object SeedManager {
val encryptedSeed = try {
loadEncryptedSeedFromDisk(context)
} catch (e: Exception) {
log.error("could read seed file: ", e)
log.error("could not read seed file: ", e)
return DecryptSeedResult.Failure.SeedFileUnreadable
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,19 @@ fun ChannelsView(
var showAdvancedMenuPopIn by remember { mutableStateOf(false) }
Text(text = stringResource(id = R.string.channelsview_title))
Spacer(modifier = Modifier.weight(1f))
Box(contentAlignment = Alignment.TopEnd) {
DropdownMenu(expanded = showAdvancedMenuPopIn, onDismissRequest = { showAdvancedMenuPopIn = false }) {
DropdownMenuItem(onClick = onImportChannelsDataClick, contentPadding = PaddingValues(horizontal = 12.dp)) {
Text(text = stringResource(R.string.channelsview_menu_import_channels), style = MaterialTheme.typography.body1)
}
DropdownMenuItem(onClick = onSpendFromChannelBalance, contentPadding = PaddingValues(horizontal = 12.dp)) {
Text(text = stringResource(R.string.channelsview_menu_spend_channel_balance), style = MaterialTheme.typography.body1)
}
}
Button(
icon = R.drawable.ic_menu_dots,
iconTint = MaterialTheme.colors.onSurface,
padding = PaddingValues(12.dp),
onClick = { showAdvancedMenuPopIn = true }
)
}
// Box(contentAlignment = Alignment.TopEnd) {
// DropdownMenu(expanded = showAdvancedMenuPopIn, onDismissRequest = { showAdvancedMenuPopIn = false }) {
// DropdownMenuItem(onClick = onSpendFromChannelBalance, contentPadding = PaddingValues(horizontal = 12.dp)) {
// Text(text = stringResource(R.string.channelsview_menu_spend_channel_balance), style = MaterialTheme.typography.body1)
// }
// }
// Button(
// icon = R.drawable.ic_menu_dots,
// iconTint = MaterialTheme.colors.onSurface,
// padding = PaddingValues(12.dp),
// onClick = { showAdvancedMenuPopIn = true }
// )
// }
}
)
if (!channelsState?.values?.filter { it.isUsable }.isNullOrEmpty()) {
Expand Down
Loading