Skip to content

Commit bc3e657

Browse files
dpad85robbiehanson
andauthored
Support taproot channels (#758)
This commit upgrades lightning-kmp to v1.11.0, which brings taproot channels to Phoenix. It also updates kotlin and cleans up legacy code. Notably, the tools for the legacy channel data backup have been removed, and the import-channel-data helper can be removed. The spend-from-channel-address screen has been disabled. The import-channel-data screen is obsolete and has been removed. * Use abstract payerKey and payerNote in offer metadata See ACINQ/lightning-kmp#821 Also limit the description input to 64 chars for Bolt12 offers as the description + payer note cannot exceed 64 chars. --------- Co-authored-by: Robbie Hanson <[email protected]>
1 parent 56fbe17 commit bc3e657

File tree

62 files changed

+164
-998
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+164
-998
lines changed

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ allprojects {
1919
google()
2020
mavenCentral()
2121
maven("https://oss.sonatype.org/content/repositories/snapshots")
22+
maven("https://central.sonatype.com/repository/maven-snapshots")
2223
}
2324
}
2425

gradle/libs.versions.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
[versions]
2-
lightningkmp = "1.10.8"
3-
secp256k1 = "0.19.0" # keep in check with lightning-kmp secp version
2+
lightningkmp = "1.11.0"
3+
secp256k1 = "0.21.0" # keep in check with lightning-kmp secp version
44

55
kotlin = "2.2.10"
66
ktor = "3.1.0"
77
sqldelight = "2.1.0"
88
okio = "3.15.0"
9+
serialization = "1.9.0" # keep in check with lightning-kmp serialization version
910

1011
# iOS
1112
skie = "0.10.6"

phoenix-android/src/main/kotlin/fr/acinq/phoenix/android/components/CalendarView.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@ import fr.acinq.phoenix.android.components.dialogs.Dialog
3535
import fr.acinq.phoenix.android.utils.converters.DateFormatter.toAbsoluteDateString
3636
import fr.acinq.phoenix.android.utils.mutedBgColor
3737
import kotlinx.datetime.*
38+
import kotlin.time.ExperimentalTime
3839

3940
/**
4041
* Calendar component to pick a day. [onDateSelected] returns the timestamp in millis at the
4142
* **start** of day.
4243
*/
44+
@OptIn(ExperimentalTime::class)
4345
@Composable
4446
fun CalendarView(
4547
label: String,

phoenix-android/src/main/kotlin/fr/acinq/phoenix/android/navigation/NavGraphSettingsChannels.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import fr.acinq.phoenix.android.AppViewModel
2424
import fr.acinq.phoenix.android.settings.MutualCloseView
2525
import fr.acinq.phoenix.android.settings.channels.ChannelDetailsView
2626
import fr.acinq.phoenix.android.settings.channels.ChannelsView
27-
import fr.acinq.phoenix.android.settings.channels.ImportChannelsData
2827
import fr.acinq.phoenix.android.settings.channels.SpendFromChannelAddress
2928

3029
fun NavGraphBuilder.channelsNavGraph(navController: NavController, appViewModel: AppViewModel) {
@@ -56,12 +55,8 @@ fun NavGraphBuilder.channelsNavGraph(navController: NavController, appViewModel:
5655
ChannelDetailsView(business = business, onBackClick = { navController.popBackStack() }, channelId = channelId)
5756
}
5857

59-
businessComposable(Screen.BusinessNavGraph.ImportChannelsData.route, appViewModel) { _, _, business ->
60-
ImportChannelsData(business = business, onBackClick = { navController.popBackStack() })
61-
}
62-
6358
businessComposable(Screen.BusinessNavGraph.SpendChannelAddress.route, appViewModel) { _, _, business ->
64-
SpendFromChannelAddress(business = business, onBackClick = { navController.popBackStack() })
59+
// SpendFromChannelAddress(business = business, onBackClick = { navController.popBackStack() })
6560
}
6661

6762
businessComposable(Screen.BusinessNavGraph.MutualClose.route, appViewModel) { _, walletId, business ->

phoenix-android/src/main/kotlin/fr/acinq/phoenix/android/payments/details/PaymentLine.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ import androidx.compose.foundation.shape.CircleShape
3131
import androidx.compose.material.MaterialTheme
3232
import androidx.compose.material.Text
3333
import androidx.compose.runtime.Composable
34-
import androidx.compose.runtime.collectAsState
35-
import androidx.compose.runtime.getValue
3634
import androidx.compose.ui.Alignment
3735
import androidx.compose.ui.Modifier
3836
import androidx.compose.ui.draw.clip

phoenix-android/src/main/kotlin/fr/acinq/phoenix/android/payments/details/PaymentTechnicalView.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ fun Bolt11InvoiceSection(
160160
TechnicalRowAmount(label = stringResource(id = R.string.paymentdetails_invoice_requested_label), amount = it, rateThen = originalFiatRate)
161161
}
162162
(invoice.description ?: invoice.descriptionHash?.toHex())?.takeIf { it.isNotBlank() }?.let {
163-
TechnicalRowSelectable(label = stringResource(id = R.string.paymentdetails_bolt11_description_label), value = it)
163+
TechnicalRowWithCopy(label = stringResource(id = R.string.paymentdetails_bolt11_description_label), value = it)
164164
}
165165
TechnicalRowWithCopy(label = stringResource(id = R.string.paymentdetails_payment_hash_label), value = invoice.paymentHash.toHex())
166166
preimage?.let { TechnicalRowWithCopy(label = stringResource(id = R.string.paymentdetails_preimage_label), value = preimage.toHex(), helpMessage = stringResource(id = R.string.paymentdetails_preimage_help)) }
@@ -178,13 +178,13 @@ fun Bolt12InvoiceSection(
178178
TechnicalRowAmount(label = stringResource(id = R.string.paymentdetails_invoice_requested_label), amount = it, rateThen = originalFiatRate)
179179
}
180180
invoice.description?.takeIf { it.isNotBlank() }?.let {
181-
TechnicalRowSelectable(label = stringResource(id = R.string.paymentdetails_bolt11_description_label), value = it)
181+
TechnicalRowWithCopy(label = stringResource(id = R.string.paymentdetails_bolt11_description_label), value = it)
182182
}
183183
TechnicalRow(label = stringResource(id = R.string.paymentdetails_payerkey_label)) {
184184
Text(text = payerKey.toHex())
185185
val nodeParamsManager = LocalBusiness.current?.nodeParamsManager
186186
val offerPayerKey by produceState<PrivateKey?>(initialValue = null, key1 = nodeParamsManager) {
187-
value = nodeParamsManager?.defaultOffer()?.payerKey
187+
value = nodeParamsManager?.defaultOffer()?.privateKey
188188
}
189189
if (offerPayerKey != null && payerKey == offerPayerKey) {
190190
Spacer(modifier = Modifier.heightIn(4.dp))

phoenix-android/src/main/kotlin/fr/acinq/phoenix/android/payments/details/splash/SplashIncomingBolt12.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import fr.acinq.bitcoin.PublicKey
3333
import fr.acinq.lightning.db.Bolt12IncomingPayment
3434
import fr.acinq.lightning.utils.UUID
3535
import fr.acinq.phoenix.PhoenixBusiness
36-
import fr.acinq.phoenix.android.LocalBusiness
3736
import fr.acinq.phoenix.android.R
3837
import fr.acinq.phoenix.android.components.layouts.SplashLabelRow
3938
import fr.acinq.phoenix.android.components.contact.ContactCompactView

phoenix-android/src/main/kotlin/fr/acinq/phoenix/android/payments/details/technical/TechnicalIncomingBolt12.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import fr.acinq.phoenix.android.payments.details.TechnicalRowWithCopy
3030
import fr.acinq.phoenix.android.payments.details.TimestampSection
3131
import fr.acinq.phoenix.android.utils.converters.MSatDisplayPolicy
3232
import fr.acinq.phoenix.data.ExchangeRate
33+
import fr.acinq.phoenix.utils.extensions.description
3334

3435
@Composable
3536
fun TechnicalIncomingBolt12(
@@ -75,10 +76,13 @@ fun IncomingBolt12Details(
7576
amount = metadata.amount,
7677
rateThen = originalFiatRate
7778
)
79+
metadata.description?.let { description ->
80+
TechnicalRowWithCopy(label = stringResource(id = R.string.paymentdetails_bolt12_description_label), value = description)
81+
}
7882
TechnicalRowWithCopy(label = stringResource(id = R.string.paymentdetails_payment_hash_label), value = metadata.paymentHash.toHex())
7983
TechnicalRowWithCopy(label = stringResource(id = R.string.paymentdetails_preimage_label), value = metadata.preimage.toHex())
8084
TechnicalRowWithCopy(label = stringResource(id = R.string.paymentdetails_offer_metadata_label), value = metadata.encode().toHex())
81-
if (metadata is OfferPaymentMetadata.V1) {
82-
TechnicalRowSelectable(label = stringResource(id = R.string.paymentdetails_payerkey_label), value = metadata.payerKey.toHex())
85+
metadata.payerKey?.let { payerKey ->
86+
TechnicalRowSelectable(label = stringResource(id = R.string.paymentdetails_payerkey_label), value = payerKey.toHex())
8387
}
8488
}

phoenix-android/src/main/kotlin/fr/acinq/phoenix/android/payments/history/PaymentsHistoryView.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,18 @@ import fr.acinq.phoenix.android.utils.logger
5252
import kotlinx.coroutines.flow.distinctUntilChanged
5353
import kotlinx.coroutines.flow.filterNotNull
5454
import kotlinx.coroutines.flow.map
55-
import kotlinx.datetime.Instant
55+
import kotlin.time.Instant
5656
import kotlinx.datetime.Month
5757
import kotlinx.datetime.TimeZone
5858
import kotlinx.datetime.daysUntil
5959
import kotlinx.datetime.toInstant
60+
import kotlinx.datetime.toJavaDayOfWeek
61+
import kotlinx.datetime.toJavaMonth
6062
import kotlinx.datetime.toKotlinLocalDateTime
6163
import kotlinx.datetime.toLocalDateTime
6264
import java.time.format.TextStyle
6365
import java.util.Locale
66+
import kotlin.time.ExperimentalTime
6467

6568

6669
private sealed class PaymentsGroup {
@@ -94,6 +97,7 @@ private sealed class PaymentsGroup {
9497
}
9598
}
9699

100+
@OptIn(ExperimentalTime::class)
97101
@Composable
98102
fun PaymentsHistoryView(
99103
onBackClick: () -> Unit,
@@ -111,7 +115,7 @@ fun PaymentsHistoryView(
111115

112116
val groupedPayments = remember(payments) {
113117
val timezone = TimeZone.currentSystemDefault()
114-
val (todaysDayOfWeek, today) = java.time.LocalDate.now().atTime(23, 59, 59).toKotlinLocalDateTime().let { it.dayOfWeek to it.toInstant(timezone) }
118+
val (todaysDayOfWeek, today) = java.time.LocalDate.now().atTime(23, 59, 59).toKotlinLocalDateTime().let { it.dayOfWeek.toJavaDayOfWeek() to it.toInstant(timezone) }
115119
payments.values.groupBy {
116120
val paymentInstant = Instant.fromEpochMilliseconds(it.payment.createdAt)
117121
val daysElapsed = paymentInstant.daysUntil(today, timezone)
@@ -189,7 +193,7 @@ fun PaymentsHistoryView(
189193
PaymentsGroup.Yesterday -> stringResource(id = R.string.payments_history_yesterday)
190194
PaymentsGroup.ThisWeek -> stringResource(id = R.string.payments_history_thisweek)
191195
PaymentsGroup.LastWeek -> stringResource(id = R.string.payments_history_lastweek)
192-
is PaymentsGroup.Other -> "${header.month.getDisplayName(TextStyle.FULL, Locale.getDefault()).uppercase()} ${header.year}"
196+
is PaymentsGroup.Other -> "${header.month.toJavaMonth().getDisplayName(TextStyle.FULL, Locale.getDefault()).uppercase()} ${header.year}"
193197
},
194198
)
195199
Spacer(modifier = Modifier.height(8.dp))

phoenix-android/src/main/kotlin/fr/acinq/phoenix/android/payments/receive/ReceiveLightningView.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ private fun EditInvoiceView(
383383
onTextChange = onDescriptionChange,
384384
staticLabel = stringResource(id = R.string.receive_lightning_edit_desc_label),
385385
placeholder = { Text(text = stringResource(id = R.string.receive_lightning_edit_desc_placeholder), maxLines = 2, overflow = TextOverflow.Ellipsis) },
386-
maxChars = 140,
386+
maxChars = if (isReusable) 64 else 140,
387387
minLines = 2,
388388
maxLines = Int.MAX_VALUE,
389389
modifier = Modifier.fillMaxWidth(),

0 commit comments

Comments
 (0)