Skip to content

Commit c952163

Browse files
committed
Merge branch 'master' into mainnet
2 parents ce4505c + 918c4b9 commit c952163

File tree

14 files changed

+252
-90
lines changed

14 files changed

+252
-90
lines changed

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
lightningkmp = "1.9.0"
2+
lightningkmp = "1.9.1"
33
secp256k1 = "0.17.1"
44

55
kotlin = "2.1.10"

phoenix-android/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ android {
2626
applicationId = "fr.acinq.phoenix.mainnet"
2727
minSdk = 26
2828
targetSdk = 34
29-
versionCode = 102
30-
versionName = "2.5.2"
29+
versionCode = 103
30+
versionName = gitCommitHash()
3131
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
3232
}
3333

phoenix-android/src/main/kotlin/fr/acinq/phoenix/android/settings/channels/SpendFromChannelAddress.kt

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@ fun SpendFromChannelAddress(
154154
ErrorMessage(
155155
header = stringResource(id = R.string.spendchanneladdress_error_generic),
156156
details = when (state) {
157-
is SpendFromChannelAddressViewState.Error.Generic -> state.cause.localizedMessage
157+
is SpendFromChannelAddressViewState.Error.Generic -> {
158+
state.cause.localizedMessage
159+
}
158160
is SpendFromChannelAddressViewState.Error.AmountMissing -> {
159161
stringResource(id = R.string.spendchanneladdress_error_amount)
160162
}
@@ -179,9 +181,30 @@ fun SpendFromChannelAddress(
179181
is SpendFromChannelAddressViewState.Error.TransactionMalformed -> {
180182
stringResource(id = R.string.spendchanneladdress_error_tx, state.details)
181183
}
184+
is SpendFromChannelAddressViewState.Error.InvalidSig -> {
185+
stringResource(R.string.spendchanneladdress_error_invalid_sig)
186+
}
182187
},
183188
alignment = Alignment.CenterHorizontally
184189
)
190+
if (state is SpendFromChannelAddressViewState.Error.InvalidSig) {
191+
val context = LocalContext.current
192+
FilledButton(
193+
text = "Copy error data",
194+
onClick = {
195+
copyToClipboard(
196+
context = context,
197+
data = """
198+
tx_id=${state.txId}
199+
funding_script=${state.fundingScript.toHex()}
200+
public_key=${state.publicKey.toHex()}
201+
signature=${state.signature.toHex()}
202+
""".trimIndent(),
203+
dataLabel = "signature error data"
204+
)
205+
}
206+
)
207+
}
185208
}
186209

187210
Card {

phoenix-android/src/main/kotlin/fr/acinq/phoenix/android/settings/channels/SpendFromChannelAddressViewModel.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ import androidx.compose.runtime.mutableStateOf
2020
import androidx.lifecycle.ViewModel
2121
import androidx.lifecycle.ViewModelProvider
2222
import androidx.lifecycle.viewModelScope
23+
import fr.acinq.bitcoin.ByteVector
2324
import fr.acinq.bitcoin.ByteVector64
2425
import fr.acinq.bitcoin.PublicKey
2526
import fr.acinq.bitcoin.Satoshi
27+
import fr.acinq.bitcoin.TxId
2628
import fr.acinq.phoenix.PhoenixBusiness
2729
import fr.acinq.phoenix.utils.channels.SpendChannelAddressHelper
2830
import fr.acinq.phoenix.utils.channels.SpendChannelAddressResult
@@ -48,6 +50,7 @@ sealed class SpendFromChannelAddressViewState {
4850
data class ChannelDataUnhandledVersion(val version: Int) : Error()
4951
data class PublicKeyMalformed(val details: String) : Error()
5052
data class TransactionMalformed(val details: String) : Error()
53+
data class InvalidSig(val txId: TxId, val publicKey: PublicKey, val fundingScript: ByteVector, val signature: ByteVector64): Error()
5154
}
5255

5356
val canProcess: Boolean = this !is Processing && this !is SignedTransaction
@@ -120,6 +123,9 @@ class SpendFromChannelAddressViewModel(
120123
is SpendChannelAddressResult.Failure.TransactionMalformed -> {
121124
state.value = SpendFromChannelAddressViewState.Error.TransactionMalformed(result.details)
122125
}
126+
is SpendChannelAddressResult.Failure.InvalidSig -> {
127+
state.value = SpendFromChannelAddressViewState.Error.InvalidSig(result.txId, result.publicKey, result.fundingScript, result.signature)
128+
}
123129
}
124130
}
125131
}

phoenix-android/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@
331331
<string name="spendchanneladdress_error_unsigned_tx">Malformed unsigned tx [%1$s]</string>
332332
<string name="spendchanneladdress_error_remote_funding_pubkey">Malformed remote funding pubkey [%1$s]</string>
333333
<string name="spendchanneladdress_error_tx">Malformed transaction [%1$s]</string>
334+
<string name="spendchanneladdress_error_invalid_sig">Invalid signature</string>
334335

335336
<!-- home: balance section & misc -->
336337

phoenix-ios/phoenix-ios.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2449,7 +2449,7 @@
24492449
ASSETCATALOG_COMPILER_APPICON_NAME = "AppIcon-Green";
24502450
CODE_SIGN_ENTITLEMENTS = "phoenix-ios/Phoenix.entitlements";
24512451
CODE_SIGN_STYLE = Automatic;
2452-
CURRENT_PROJECT_VERSION = 87;
2452+
CURRENT_PROJECT_VERSION = 88;
24532453
DEVELOPMENT_ASSET_PATHS = "\"phoenix-ios/Preview Content\"";
24542454
DEVELOPMENT_TEAM = XD77LN4376;
24552455
ENABLE_PREVIEWS = YES;
@@ -2473,7 +2473,7 @@
24732473
ASSETCATALOG_COMPILER_APPICON_NAME = "AppIcon-Green";
24742474
CODE_SIGN_ENTITLEMENTS = "phoenix-ios/Phoenix.entitlements";
24752475
CODE_SIGN_STYLE = Automatic;
2476-
CURRENT_PROJECT_VERSION = 87;
2476+
CURRENT_PROJECT_VERSION = 88;
24772477
DEVELOPMENT_ASSET_PATHS = "\"phoenix-ios/Preview Content\"";
24782478
DEVELOPMENT_TEAM = XD77LN4376;
24792479
ENABLE_PREVIEWS = YES;
@@ -2571,7 +2571,7 @@
25712571
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
25722572
CODE_SIGN_ENTITLEMENTS = "phoenix-notifySrvExt/phoenix-notifySrvExt.entitlements";
25732573
CODE_SIGN_STYLE = Automatic;
2574-
CURRENT_PROJECT_VERSION = 87;
2574+
CURRENT_PROJECT_VERSION = 88;
25752575
DEVELOPMENT_TEAM = XD77LN4376;
25762576
GENERATE_INFOPLIST_FILE = YES;
25772577
INFOPLIST_FILE = "phoenix-notifySrvExt/Info.plist";
@@ -2598,7 +2598,7 @@
25982598
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
25992599
CODE_SIGN_ENTITLEMENTS = "phoenix-notifySrvExt/phoenix-notifySrvExt.entitlements";
26002600
CODE_SIGN_STYLE = Automatic;
2601-
CURRENT_PROJECT_VERSION = 87;
2601+
CURRENT_PROJECT_VERSION = 88;
26022602
DEVELOPMENT_TEAM = XD77LN4376;
26032603
GENERATE_INFOPLIST_FILE = YES;
26042604
INFOPLIST_FILE = "phoenix-notifySrvExt/Info.plist";

phoenix-ios/phoenix-ios/views/inspect/CpfpView.swift

Lines changed: 52 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ struct CpfpView: View {
6666
)
6767
@State var priorityBoxWidth: CGFloat? = nil
6868

69+
enum PriorityBoxHeight: Preference {}
70+
let priorityBoxHeightReader = GeometryPreferenceReader(
71+
key: AppendValue<PriorityBoxWidth>.self,
72+
value: { [$0.size.height] }
73+
)
74+
@State var priorityBoxHeight: CGFloat? = nil
75+
6976
@Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>
7077

7178
@EnvironmentObject var currencyPrefs: CurrencyPrefs
@@ -99,7 +106,6 @@ struct CpfpView: View {
99106
func main() -> some View {
100107

101108
VStack(alignment: HorizontalAlignment.center, spacing: 0) {
102-
103109
header()
104110
ScrollView {
105111
content()
@@ -187,34 +193,47 @@ struct CpfpView: View {
187193
@ViewBuilder
188194
func priorityBoxes() -> some View {
189195

190-
priorityBoxes_ios16()
196+
ViewThatFits {
197+
priorityBoxes_normal()
198+
priorityBoxes_accessibility()
199+
}
200+
.assignMaxPreference(for: priorityBoxWidthReader.key, to: $priorityBoxWidth)
201+
.assignMaxPreference(for: priorityBoxHeightReader.key, to: $priorityBoxHeight)
191202
}
192203

193204
@ViewBuilder
194-
func priorityBoxes_ios16() -> some View {
205+
func priorityBoxes_normal() -> some View {
195206

196-
ViewThatFits {
197-
Grid(horizontalSpacing: 8, verticalSpacing: 8) {
198-
GridRow(alignment: VerticalAlignment.center) {
199-
priorityBox_economy()
200-
priorityBox_low()
201-
priorityBox_medium()
202-
priorityBox_high()
203-
}
204-
} // </Grid>
205-
Grid(horizontalSpacing: 8, verticalSpacing: 8) {
206-
GridRow(alignment: VerticalAlignment.center) {
207-
priorityBox_economy()
208-
priorityBox_low()
209-
210-
}
211-
GridRow(alignment: VerticalAlignment.center) {
212-
priorityBox_medium()
213-
priorityBox_high()
214-
}
215-
} // </Grid>
216-
}
217-
.assignMaxPreference(for: priorityBoxWidthReader.key, to: $priorityBoxWidth)
207+
Grid(horizontalSpacing: 8, verticalSpacing: 8) {
208+
GridRow(alignment: VerticalAlignment.center) {
209+
priorityBox_economy()
210+
priorityBox_low()
211+
212+
}
213+
GridRow(alignment: VerticalAlignment.center) {
214+
priorityBox_medium()
215+
priorityBox_high()
216+
}
217+
} // </Grid>
218+
}
219+
220+
@ViewBuilder
221+
func priorityBoxes_accessibility() -> some View {
222+
223+
Grid(horizontalSpacing: 8, verticalSpacing: 8) {
224+
GridRow(alignment: VerticalAlignment.center) {
225+
priorityBox_economy()
226+
}
227+
GridRow(alignment: VerticalAlignment.center) {
228+
priorityBox_low()
229+
}
230+
GridRow(alignment: VerticalAlignment.center) {
231+
priorityBox_medium()
232+
}
233+
GridRow(alignment: VerticalAlignment.center) {
234+
priorityBox_high()
235+
}
236+
} // </Grid>
218237
}
219238

220239
@ViewBuilder
@@ -232,11 +251,13 @@ struct CpfpView: View {
232251
}
233252
.groupBoxStyle(PriorityBoxStyle(
234253
width: priorityBoxWidth,
254+
height: priorityBoxHeight,
235255
disabled: isPriorityDisabled(),
236256
selected: isPrioritySelected(.none),
237257
tapped: { priorityTapped(.none) }
238258
))
239259
.read(priorityBoxWidthReader)
260+
.read(priorityBoxHeightReader)
240261
}
241262

242263
@ViewBuilder
@@ -254,11 +275,13 @@ struct CpfpView: View {
254275
}
255276
.groupBoxStyle(PriorityBoxStyle(
256277
width: priorityBoxWidth,
278+
height: priorityBoxHeight,
257279
disabled: isPriorityDisabled(),
258280
selected: isPrioritySelected(.low),
259281
tapped: { priorityTapped(.low) }
260282
))
261283
.read(priorityBoxWidthReader)
284+
.read(priorityBoxHeightReader)
262285
}
263286

264287
@ViewBuilder
@@ -276,11 +299,13 @@ struct CpfpView: View {
276299
}
277300
.groupBoxStyle(PriorityBoxStyle(
278301
width: priorityBoxWidth,
302+
height: priorityBoxHeight,
279303
disabled: isPriorityDisabled(),
280304
selected: isPrioritySelected(.medium),
281305
tapped: { priorityTapped(.medium) }
282306
))
283307
.read(priorityBoxWidthReader)
308+
.read(priorityBoxHeightReader)
284309
}
285310

286311
@ViewBuilder
@@ -298,11 +323,13 @@ struct CpfpView: View {
298323
}
299324
.groupBoxStyle(PriorityBoxStyle(
300325
width: priorityBoxWidth,
326+
height: priorityBoxHeight,
301327
disabled: isPriorityDisabled(),
302328
selected: isPrioritySelected(.high),
303329
tapped: { priorityTapped(.high) }
304330
))
305331
.read(priorityBoxWidthReader)
332+
.read(priorityBoxHeightReader)
306333
}
307334

308335
@ViewBuilder

phoenix-ios/phoenix-ios/views/receive/LightningDualView.swift

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -726,18 +726,43 @@ struct LightningDualView: View {
726726
func lastIncomingPaymentChanged(_ lastIncomingPayment: Lightning_kmpIncomingPayment) {
727727
log.trace("lastIncomingPaymentChanged()")
728728

729-
guard let model = mvi.model as? Receive.Model_Generated else {
729+
let state = lastIncomingPayment.state()
730+
guard state == WalletPaymentState.successOffChain else {
731+
log.debug("lastIncomingPaymentChanged(): state != .successOffChain")
730732
return
731733
}
732734

733-
let state = lastIncomingPayment.state()
734-
if state == WalletPaymentState.successOffChain {
735+
guard let lightningPayment = lastIncomingPayment as? Lightning_kmpLightningIncomingPayment else {
736+
log.debug("lastIncomingPaymentChanged(): not a Lightning_kmpLightningIncomingPayment")
737+
return
738+
}
739+
740+
var didCompletePayment = false
741+
742+
if let b11Payment = lightningPayment as? Lightning_kmpBolt11IncomingPayment {
743+
744+
// While waiting for the payment to arrive,
745+
// the user might tap the "show reusable qr" button.
746+
// This would switch them over to Bolt12 mode.
747+
// But if a matching Bolt11 payment arrives during that moment,
748+
// we should still kick them back to the Home screen,
749+
// and show them the payment was received.
735750

736-
if let lightningPayment = lastIncomingPayment as? Lightning_kmpLightningIncomingPayment {
737-
if lightningPayment.paymentHash.toHex() == model.paymentHash {
738-
presentationMode.wrappedValue.dismiss()
751+
if let model = mvi.model as? Receive.Model_Generated {
752+
if b11Payment.paymentHash.toHex() == model.paymentHash {
753+
didCompletePayment = true
739754
}
740755
}
756+
757+
} else if let b12Payment = lightningPayment as? Lightning_kmpBolt12IncomingPayment {
758+
759+
if activeType == .bolt12_offer {
760+
didCompletePayment = true
761+
}
762+
}
763+
764+
if didCompletePayment {
765+
presentationMode.wrappedValue.dismiss()
741766
}
742767
}
743768

0 commit comments

Comments
 (0)