Skip to content

Commit dee14a9

Browse files
committed
fix: adapt lnurl channel to new bitkit-core impl
1 parent 3a98c0e commit dee14a9

3 files changed

Lines changed: 5 additions & 38 deletions

File tree

app/src/main/java/to/bitkit/repositories/LightningRepo.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,8 +659,6 @@ class LightningRepo @Inject constructor(
659659
lnurlService.requestLnurlWithdraw(callbackUrl)
660660
}
661661

662-
suspend fun fetchLnurlChannelInfo(url: String) = lnurlService.fetchLnurlChannelInfo(url)
663-
664662
suspend fun requestLnurlChannel(
665663
k1: String,
666664
callback: String,

app/src/main/java/to/bitkit/services/LnurlService.kt

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,6 @@ class LnurlService @Inject constructor(
6363
return@runCatching response.body<LnurlPayResponse>()
6464
}
6565

66-
suspend fun fetchLnurlChannelInfo(url: String): Result<LnurlChannelInfoResponse> = runCatching {
67-
Logger.debug("Fetching LNURL channel info from: $url", context = TAG)
68-
69-
val response: HttpResponse = client.get(url)
70-
Logger.debug("Http call: $response", context = TAG)
71-
72-
if (!response.status.isSuccess()) {
73-
throw HttpError("fetchLnurlChannelInfo error: '${response.status.description}'", response.status.value)
74-
}
75-
76-
return@runCatching response.body<LnurlChannelInfoResponse>()
77-
}.onFailure {
78-
Logger.warn("Failed to fetch channel info", it, context = TAG)
79-
}
80-
8166
suspend fun requestLnurlChannel(url: String): Result<LnurlChannelResponse> = runCatching {
8267
Logger.debug("Requesting LNURL channel request via: '$url'", context = TAG)
8368

@@ -127,11 +112,3 @@ data class LnurlChannelResponse(
127112
val status: String? = null,
128113
val reason: String? = null,
129114
)
130-
131-
@Serializable
132-
data class LnurlChannelInfoResponse(
133-
val uri: String,
134-
val tag: String,
135-
val callback: String,
136-
val k1: String,
137-
)

app/src/main/java/to/bitkit/ui/screens/transfer/external/LnurlChannelViewModel.kt

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,11 @@ class LnurlChannelViewModel @Inject constructor(
3636

3737
private fun fetchChannelInfo() {
3838
viewModelScope.launch {
39-
lightningRepo.fetchLnurlChannelInfo(params.uri)
40-
.onSuccess { channelInfo ->
41-
val peer = runCatching { PeerDetails.of(channelInfo.uri) }.getOrElse {
42-
errorToast(it)
43-
return@onSuccess
44-
}
45-
_uiState.update { it.copy(peer = peer) }
46-
}
47-
.onFailure { error ->
48-
val message = context.getString(R.string.other__lnurl_channel_error_raw)
49-
.replace("{raw}", error.message.orEmpty())
50-
errorToast(Exception(message))
51-
}
39+
val peer = runCatching { PeerDetails.of(params.uri) }.getOrElse {
40+
errorToast(it)
41+
return@launch
42+
}
43+
_uiState.update { it.copy(peer = peer) }
5244
}
5345
}
5446

0 commit comments

Comments
 (0)