Skip to content

Commit 4c3ed73

Browse files
committed
Add payment_hash to Lightning exceptions
1 parent 023df41 commit 4c3ed73

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

common/src/commonMain/kotlin/com/blockstream/common/CountlyBase.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import com.blockstream.common.data.ApplicationSettings
66
import com.blockstream.common.data.Banner
77
import com.blockstream.common.data.CountlyAsset
88
import com.blockstream.common.data.CredentialType
9+
import com.blockstream.common.data.ExceptionWithSupportData
910
import com.blockstream.common.data.GreenWallet
1011
import com.blockstream.common.data.Promo
1112
import com.blockstream.common.data.SetupArgs
@@ -691,6 +692,7 @@ abstract class CountlyBase(
691692
?.also {
692693
map[PARAM_NODE_ID] = it
693694
}
695+
(error as? ExceptionWithSupportData)?.supportData?.paymentHash?.also { map[PAYMENT_HASH] = it }
694696
}
695697
)
696698
}
@@ -945,7 +947,8 @@ abstract class CountlyBase(
945947
const val PARAM_FIRMWARE = "firmware"
946948
const val PARAM_CONNECTION = "connection"
947949
const val PARAM_ERROR = "error"
948-
const val PARAM_NODE_ID = "NODE_ID"
950+
const val PARAM_NODE_ID = "node_id"
951+
const val PAYMENT_HASH = "payment_hash"
949952
const val PARAM_FLOW = "flow"
950953
const val PARAM_EPHEMERAL_BIP39 = "ephemeral_bip39"
951954
const val PARAM_MAINNET = "mainnet"

common/src/commonMain/kotlin/com/blockstream/common/gdk/GdkSession.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2777,7 +2777,7 @@ class GdkSession constructor(
27772777

27782778
try {
27792779
val response = lightningSdk.sendPayment(
2780-
bolt11 = inputType.invoice.bolt11,
2780+
invoice = inputType.invoice,
27812781
satoshi = satoshi.takeIf { inputType.invoice.amountMsat == null }
27822782
)
27832783

common/src/commonMain/kotlin/com/blockstream/common/lightning/LightningBridge.kt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import breez_sdk.GreenlightNodeConfig
1313
import breez_sdk.HealthCheckStatus
1414
import breez_sdk.InputType
1515
import breez_sdk.ListPaymentsRequest
16+
import breez_sdk.LnInvoice
1617
import breez_sdk.LnUrlAuthRequestData
1718
import breez_sdk.LnUrlCallbackStatus
1819
import breez_sdk.LnUrlPayRequest
@@ -492,10 +493,10 @@ class LightningBridge constructor(
492493
}
493494
}
494495

495-
fun sendPayment(bolt11: String, satoshi: Long?): SendPaymentResponse {
496+
fun sendPayment(invoice: LnInvoice, satoshi: Long?): SendPaymentResponse {
496497
return try {
497498
breezSdk.sendPayment(
498-
SendPaymentRequest(bolt11 = bolt11, amountMsat = satoshi?.milliSatoshi(), useTrampoline = true)
499+
SendPaymentRequest(bolt11 = invoice.bolt11, amountMsat = satoshi?.milliSatoshi(), useTrampoline = true)
499500
)
500501
} catch (e: Exception) {
501502
throw exceptionWithNodeId(e)
@@ -571,7 +572,14 @@ class LightningBridge constructor(
571572
}
572573

573574
private fun exceptionWithNodeId(exception: Exception) =
574-
Exception("${exception.message}\nNodeId: ${_nodeInfoStateFlow.value.id}\nTimestamp: ${Clock.System.now().epochSeconds}", exception.cause)
575+
Exception(
576+
listOfNotNull(
577+
exception.message,
578+
"NodeId: ${_nodeInfoStateFlow.value.id}",
579+
"Timestamp: ${Clock.System.now().epochSeconds}",
580+
).joinToString("\n"),
581+
exception.cause
582+
)
575583

576584
fun release(){
577585
lightningManager.release(this)

0 commit comments

Comments
 (0)