Skip to content

Commit d2f67c3

Browse files
committed
Adding additional UI components to help with debugging / inspection
1 parent e924811 commit d2f67c3

File tree

2 files changed

+113
-0
lines changed

2 files changed

+113
-0
lines changed

phoenix-ios/phoenix-ios/Localizable.xcstrings

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9103,6 +9103,9 @@
91039103
}
91049104
}
91059105
}
9106+
},
9107+
"BLIP 42 (DEBUG build only)" : {
9108+
91069109
},
91079110
"Block height" : {
91089111
"localizations" : {
@@ -12519,6 +12522,9 @@
1251912522
}
1252012523
}
1252112524
}
12525+
},
12526+
"contact secret" : {
12527+
1252212528
},
1252312529
"Contact support if needed." : {
1252412530
"localizations" : {
@@ -29891,6 +29897,12 @@
2989129897
}
2989229898
}
2989329899
}
29900+
},
29901+
"payer address" : {
29902+
29903+
},
29904+
"payer offer" : {
29905+
2989429906
},
2989529907
"Payment" : {
2989629908
"localizations" : {

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

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,19 @@ fileprivate struct DetailsInfoGrid: InfoGridView {
180180
paymentRequest_invoice(paymentRequest)
181181
}
182182
}
183+
184+
#if DEBUG
185+
if let metadata = incomingPayment.incomingOfferMetadataV2() {
186+
187+
InlineSection {
188+
header("BLIP 42 (DEBUG build only)")
189+
} content: {
190+
blip42_contactSecret(metadata.contactSecret)
191+
blip42_offer(metadata.payerOffer)
192+
blip42_address(metadata.payerAddress)
193+
}
194+
}
195+
#endif
183196

184197
if let received = incomingPayment.received {
185198

@@ -274,6 +287,19 @@ fileprivate struct DetailsInfoGrid: InfoGridView {
274287
}
275288
}
276289

290+
#if DEBUG
291+
if let request = outgoingPayment.outgoingInvoiceRequest() {
292+
293+
InlineSection {
294+
header("BLIP 42 (DEBUG build only)")
295+
} content: {
296+
blip42_contactSecret(request.contactSecret)
297+
blip42_offer(request.payerOffer)
298+
blip42_address(request.payerAddress)
299+
}
300+
}
301+
#endif
302+
277303
} else if let spliceOut = outgoingPayment as? Lightning_kmpSpliceOutgoingPayment {
278304

279305
InlineSection {
@@ -1163,6 +1189,81 @@ fileprivate struct DetailsInfoGrid: InfoGridView {
11631189
common_channelId(payment.channelId)
11641190
}
11651191

1192+
@ViewBuilder
1193+
func blip42_contactSecret(
1194+
_ secret: Bitcoin_kmpByteVector32?
1195+
) -> some View {
1196+
let identifier: String = #function
1197+
1198+
InfoGridRowWrapper(
1199+
identifier: identifier,
1200+
keyColumnWidth: keyColumnWidth(identifier: identifier)
1201+
) {
1202+
keyColumn("contact secret")
1203+
1204+
} valueColumn: {
1205+
1206+
if let str = secret?.toHex() {
1207+
Text(str)
1208+
.lineLimit(2)
1209+
.truncationMode(.middle)
1210+
} else {
1211+
Text(verbatim: "<null>")
1212+
.foregroundStyle(Color.secondary)
1213+
}
1214+
}
1215+
}
1216+
1217+
@ViewBuilder
1218+
func blip42_offer(
1219+
_ offer: Lightning_kmpOfferTypesOffer?
1220+
) -> some View {
1221+
let identifier: String = #function
1222+
1223+
InfoGridRowWrapper(
1224+
identifier: identifier,
1225+
keyColumnWidth: keyColumnWidth(identifier: identifier)
1226+
) {
1227+
keyColumn("payer offer")
1228+
1229+
} valueColumn: {
1230+
1231+
if let str = offer?.encode() {
1232+
Text(str)
1233+
.lineLimit(2)
1234+
.truncationMode(.middle)
1235+
} else {
1236+
Text(verbatim: "<null>")
1237+
.foregroundStyle(Color.secondary)
1238+
}
1239+
}
1240+
}
1241+
1242+
@ViewBuilder
1243+
func blip42_address(
1244+
_ address: Lightning_kmpContactAddress?
1245+
) -> some View {
1246+
let identifier: String = #function
1247+
1248+
InfoGridRowWrapper(
1249+
identifier: identifier,
1250+
keyColumnWidth: keyColumnWidth(identifier: identifier)
1251+
) {
1252+
keyColumn("payer address")
1253+
1254+
} valueColumn: {
1255+
1256+
if let str = address?.description() {
1257+
Text(str)
1258+
.lineLimit(2)
1259+
.truncationMode(.middle)
1260+
} else {
1261+
Text(verbatim: "<null>")
1262+
.foregroundStyle(Color.secondary)
1263+
}
1264+
}
1265+
}
1266+
11661267
// --------------------------------------------------
11671268
// MARK: View Builders: Common Rows
11681269
// --------------------------------------------------

0 commit comments

Comments
 (0)