feat: migrate secret management to datastore proto and tink
This commit is contained in:
@@ -18,7 +18,7 @@ class LNbitsWalletRepository(
|
||||
// ── Balance ───────────────────────────────────────────────────────────────
|
||||
|
||||
override suspend fun getBalance(): WalletBalance {
|
||||
val response = api.getWallet(secrets.invoiceKey)
|
||||
val response = api.getWallet(secrets.invoiceKey())
|
||||
return WalletBalance(sats = response.balance / WalletConstants.MSAT_PER_SAT)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class LNbitsWalletRepository(
|
||||
|
||||
override suspend fun createInvoice(amountSats: Long, memo: String): CreatedInvoice {
|
||||
val response = api.createInvoice(
|
||||
secrets.invoiceKey,
|
||||
secrets.invoiceKey(),
|
||||
CreateInvoiceRequest(
|
||||
out = false,
|
||||
amount = amountSats,
|
||||
@@ -41,13 +41,13 @@ class LNbitsWalletRepository(
|
||||
}
|
||||
|
||||
override suspend fun isPaymentReceived(paymentHash: String): Boolean {
|
||||
return api.checkPayment(secrets.invoiceKey, paymentHash).paid
|
||||
return api.checkPayment(secrets.invoiceKey(), paymentHash).paid
|
||||
}
|
||||
|
||||
// ── Send ──────────────────────────────────────────────────────────────────
|
||||
|
||||
override suspend fun decodeBolt11(bolt11: String): DecodedBolt11 {
|
||||
val response = api.decodeInvoice(secrets.invoiceKey, DecodeInvoiceRequest(data = bolt11))
|
||||
val response = api.decodeInvoice(secrets.invoiceKey(), DecodeInvoiceRequest(data = bolt11))
|
||||
val amountSats = response.amountMsat
|
||||
?.takeIf { it > 0L }
|
||||
?.div(WalletConstants.MSAT_PER_SAT)
|
||||
@@ -64,7 +64,7 @@ class LNbitsWalletRepository(
|
||||
|
||||
|
||||
override suspend fun scanLnurl(code: String): ScannedLnurl {
|
||||
val r = api.lnurlScan(secrets.invoiceKey, code)
|
||||
val r = api.lnurlScan(secrets.invoiceKey(), code)
|
||||
return ScannedLnurl(
|
||||
tag = r.tag,
|
||||
callback = r.callback,
|
||||
@@ -169,7 +169,7 @@ class LNbitsWalletRepository(
|
||||
|
||||
override suspend fun payBolt11(bolt11: String): PaymentConfirmation {
|
||||
val response = api.payInvoice(
|
||||
secrets.adminKey,
|
||||
secrets.adminKey(),
|
||||
PayInvoiceRequest(out = true, bolt11 = bolt11)
|
||||
)
|
||||
return PaymentConfirmation(paymentHash = response.paymentHash)
|
||||
@@ -182,7 +182,7 @@ class LNbitsWalletRepository(
|
||||
comment: String?
|
||||
): PaymentConfirmation {
|
||||
val response = api.payLnurl(
|
||||
secrets.adminKey,
|
||||
secrets.adminKey(),
|
||||
PayLnurlRequest(
|
||||
res = LnurlPayRes(
|
||||
tag = rawRes.tag,
|
||||
@@ -220,10 +220,10 @@ class LNbitsWalletRepository(
|
||||
}
|
||||
|
||||
override suspend fun getLightningAddress(): String? {
|
||||
val links = api.getLnurlpLinks(secrets.invoiceKey, allWallets = false)
|
||||
val links = api.getLnurlpLinks(secrets.invoiceKey(), allWallets = false)
|
||||
val username = links.firstOrNull { !it.username.isNullOrBlank() }?.username
|
||||
?: return null
|
||||
val domain = secrets.baseUrl
|
||||
val domain = secrets.baseUrl()
|
||||
.removePrefix("https://")
|
||||
.removePrefix("http://")
|
||||
.trimEnd('/')
|
||||
@@ -246,10 +246,10 @@ class LNbitsWalletRepository(
|
||||
// ── History ───────────────────────────────────────────────────────────────
|
||||
|
||||
override suspend fun getPayments(offset: Int, limit: Int): List<PaymentRecord> {
|
||||
return api.getPayments(secrets.invoiceKey, limit, offset)
|
||||
return api.getPayments(secrets.invoiceKey(), limit, offset)
|
||||
}
|
||||
|
||||
override suspend fun getPaymentDetail(checkingId: String): PaymentDetailResponse {
|
||||
return api.getPaymentDetail(secrets.invoiceKey, checkingId)
|
||||
return api.getPaymentDetail(secrets.invoiceKey(), checkingId)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user