Skip to content

Commit 2295731

Browse files
committed
feat: update bitkit-core and use new lnurl apis
1 parent 51cf701 commit 2295731

File tree

4 files changed

+16
-21
lines changed

4 files changed

+16
-21
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import com.google.firebase.messaging.FirebaseMessaging
44
import com.synonym.bitkitcore.FeeRates
55
import com.synonym.bitkitcore.LightningInvoice
66
import com.synonym.bitkitcore.Scanner
7+
import com.synonym.bitkitcore.createChannelRequestUrl
78
import com.synonym.bitkitcore.createWithdrawCallbackUrl
89
import com.synonym.bitkitcore.decode
910
import com.synonym.bitkitcore.lnurlAuth
@@ -446,8 +447,14 @@ class LightningRepo @Inject constructor(
446447
callback: String,
447448
nodeId: String,
448449
): Result<LnurlChannelResponse> = executeWhenNodeRunning("requestLnurlChannel") {
449-
// TODO use bitkit-core createChannelRequestUrl after it is fixed to prevent k1 duplicating
450-
lnurlService.requestLnurlChannel(k1 = k1, callback = callback, nodeId = nodeId)
450+
val url = createChannelRequestUrl(
451+
k1 = k1,
452+
callback = callback,
453+
localNodeId = nodeId,
454+
isPrivate = true,
455+
cancel = false,
456+
)
457+
lnurlService.requestLnurlChannel(url)
451458
}
452459

453460
suspend fun requestLnurlAuth(

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,11 @@ class LnurlService @Inject constructor(
7777
}
7878

7979
suspend fun requestLnurlChannel(
80-
k1: String,
81-
callback: String,
82-
nodeId: String,
80+
url: String,
8381
): Result<LnurlChannelResponse> = runCatching {
84-
Logger.debug("Requesting LNURL channel request via: '$callback'")
82+
Logger.debug("Requesting LNURL channel request via: '$url'")
8583

86-
val response = client.get(callback) {
87-
url {
88-
parameters["k1"] = k1
89-
parameters["remoteid"] = nodeId
90-
parameters["private"] = "1" // Private channel
91-
}
92-
}
84+
val response: HttpResponse = client.get(url)
9385
Logger.debug("Http call: $response")
9486

9587
if (!response.status.isSuccess()) throw Exception("HTTP error: ${response.status}")

app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import androidx.annotation.StringRes
55
import androidx.compose.runtime.getValue
66
import androidx.compose.runtime.mutableStateOf
77
import androidx.compose.runtime.setValue
8-
import androidx.core.net.toUri
98
import androidx.lifecycle.ViewModel
109
import androidx.lifecycle.viewModelScope
1110
import com.synonym.bitkitcore.ActivityFilter
@@ -378,6 +377,7 @@ class AppViewModel @Inject constructor(
378377
val newSatsPerVByte = state.feeRates?.getSatsPerVByteFor(speed)
379378
currentSatsPerVByte != newSatsPerVByte
380379
}
380+
381381
else -> false
382382
}
383383
val fee = when (speed is TransactionSpeed.Custom) {
@@ -697,15 +697,11 @@ class AppViewModel @Inject constructor(
697697

698698
private fun onScanLnurlAuth(data: LnurlAuthData, lnurl: String) {
699699
Logger.debug("LNURL: $data", context = TAG)
700-
701-
val domain = runCatching { data.uri.toUri().host }.getOrDefault(data.uri).orEmpty().trim()
702-
703-
showSheet(Sheet.LnurlAuth(domain = domain, lnurl = lnurl, k1 = data.k1))
700+
showSheet(Sheet.LnurlAuth(domain = data.domain, lnurl = lnurl, k1 = data.k1))
704701
}
705702

706703
fun requestLnurlAuth(callback: String, k1: String, domain: String) {
707704
viewModelScope.launch {
708-
// TODO pass callback and domain from bitkit-core when updated to accept decoded callback and return domain
709705
lightningRepo.requestLnurlAuth(
710706
callback = callback,
711707
k1 = k1,

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ activity-compose = { module = "androidx.activity:activity-compose", version.ref
4646
appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" }
4747
barcode-scanning = { module = "com.google.mlkit:barcode-scanning", version.ref = "barcodeScanning" }
4848
biometric = { module = "androidx.biometric:biometric", version.ref = "biometric" }
49-
#bitkitcore = { module = "com.synonym:bitkit-core-android", version = "0.1.3" } # mavenLocal
50-
bitkitcore = { module = "com.github.synonymdev:bitkit-core", version = "v0.1.8" } # jitpack
49+
#bitkitcore = { module = "com.synonym:bitkit-core-android", version = "0.1.9" } # mavenLocal
50+
bitkitcore = { module = "com.github.synonymdev:bitkit-core", version = "v0.1.9" } # jitpack
5151
bouncycastle-provider-jdk = { module = "org.bouncycastle:bcprov-jdk18on", version.ref = "bouncyCastle" }
5252
camera-camera2 = { module = "androidx.camera:camera-camera2", version.ref = "camera" }
5353
camera-lifecycle = { module = "androidx.camera:camera-lifecycle", version.ref = "camera" }

0 commit comments

Comments
 (0)