feat: migrate secret management to datastore proto and tink

This commit is contained in:
2026-06-02 18:15:22 +02:00
parent 2be68d38a5
commit e8b3f898e8
16 changed files with 328 additions and 128 deletions
@@ -1,7 +1,11 @@
package com.bitcointxoko.gudariwallet.api
import com.bitcointxoko.gudariwallet.BuildConfig
import com.bitcointxoko.gudariwallet.security.SecretStore
import com.bitcointxoko.gudariwallet.util.WalletConstants
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
@@ -25,10 +29,14 @@ object LNbitsClient {
}
.build()
fun create(baseUrl: String): LNbitsApi {
val url = if (baseUrl.endsWith("/")) baseUrl else "$baseUrl/"
fun create(secrets: SecretStore): LNbitsApi {
val baseUrl = runBlocking(Dispatchers.IO) {
secrets.credentials.first().baseUrl
}.ifBlank { "https://placeholder.invalid" }
val normalizedUrl = if (baseUrl.endsWith("/")) baseUrl else "$baseUrl/"
return Retrofit.Builder()
.baseUrl(url)
.baseUrl(normalizedUrl)
.client(httpClient)
.addConverterFactory(GsonConverterFactory.create(GsonProvider.gson))
.build()