feat: nwc
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package com.bitcointxoko.gudariwallet.api
|
||||
|
||||
import retrofit2.http.Body
|
||||
import retrofit2.http.DELETE
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Header
|
||||
import retrofit2.http.POST
|
||||
import retrofit2.http.PUT
|
||||
import retrofit2.http.Path
|
||||
import retrofit2.http.Query
|
||||
import retrofit2.http.Url
|
||||
@@ -144,4 +146,61 @@ interface LNbitsApi {
|
||||
*/
|
||||
@GET("api/v1/currencies")
|
||||
suspend fun getSupportedCurrencies(): List<String>
|
||||
|
||||
// ── NWC Provider ──────────────────────────────────────────────────────────
|
||||
|
||||
@GET("nwcprovider/api/v1/permissions")
|
||||
suspend fun getNwcPermissions(
|
||||
@Header("X-Api-Key") apiKey: String
|
||||
): Map<String, Any>
|
||||
|
||||
@GET("nwcprovider/api/v1/nwc")
|
||||
suspend fun getNwcKeys(
|
||||
@Header("X-Api-Key") adminKey: String,
|
||||
@Query("include_expired") includeExpired: Boolean = false
|
||||
): List<NwcGetResponse>
|
||||
|
||||
@GET("nwcprovider/api/v1/nwc/{pubkey}")
|
||||
suspend fun getNwcKey(
|
||||
@Header("X-Api-Key") apiKey: String,
|
||||
@Path("pubkey") pubkey: String,
|
||||
@Query("include_expired") includeExpired: Boolean = false,
|
||||
@Query("refresh_last_used") refreshLastUsed: Boolean = false
|
||||
): NwcGetResponse
|
||||
|
||||
@PUT("nwcprovider/api/v1/nwc/{pubkey}")
|
||||
suspend fun registerNwcKey(
|
||||
@Header("X-Api-Key") adminKey: String,
|
||||
@Path("pubkey") pubkey: String,
|
||||
@Body request: NwcRegistrationRequest
|
||||
): NwcGetResponse
|
||||
|
||||
@DELETE("nwcprovider/api/v1/nwc/{pubkey}")
|
||||
suspend fun deleteNwcKey(
|
||||
@Header("X-Api-Key") adminKey: String,
|
||||
@Path("pubkey") pubkey: String
|
||||
)
|
||||
|
||||
@GET("nwcprovider/api/v1/pairing/{secret}")
|
||||
suspend fun getNwcPairingUrl(
|
||||
@Header("X-Api-Key") apiKey: String,
|
||||
@Path("secret") secret: String
|
||||
): String
|
||||
|
||||
@GET("nwcprovider/api/v1/config")
|
||||
suspend fun getNwcConfig(
|
||||
@Header("X-Api-Key") adminKey: String
|
||||
): Map<String, Any>
|
||||
|
||||
@GET("nwcprovider/api/v1/config/{key}")
|
||||
suspend fun getNwcConfigValue(
|
||||
@Header("X-Api-Key") adminKey: String,
|
||||
@Path("key") key: String
|
||||
): Map<String, Any>
|
||||
|
||||
@POST("nwcprovider/api/v1/config")
|
||||
suspend fun setNwcConfig(
|
||||
@Header("X-Api-Key") adminKey: String,
|
||||
@Body config: Map<String, Any>
|
||||
): Map<String, Any>
|
||||
}
|
||||
|
||||
@@ -322,3 +322,43 @@ data class PaginatedPaymentsResponse(
|
||||
@SerializedName("data") val data: List<PaymentRecord>,
|
||||
@SerializedName("total") val total: Int
|
||||
)
|
||||
|
||||
// ── NWC Provider models ───────────────────────────────────────────────────────
|
||||
|
||||
data class NwcKey(
|
||||
val pubkey: String,
|
||||
val wallet: String,
|
||||
val description: String,
|
||||
val expires_at: Long,
|
||||
val permissions: String, // comma-separated permission names
|
||||
val created_at: Long,
|
||||
val last_used: Long
|
||||
)
|
||||
|
||||
data class NwcBudget(
|
||||
val id: Int,
|
||||
val pubkey: String,
|
||||
val budget_msats: Long,
|
||||
val refresh_window: Int, // seconds
|
||||
val created_at: Long,
|
||||
val used_budget_msats: Long = 0
|
||||
)
|
||||
|
||||
/** Response for GET /nwc and GET /nwc/{pubkey} */
|
||||
data class NwcGetResponse(
|
||||
val data: NwcKey,
|
||||
val budgets: List<NwcBudget>
|
||||
)
|
||||
|
||||
data class NwcNewBudget(
|
||||
val budget_msats: Long,
|
||||
val refresh_window: Int // seconds
|
||||
)
|
||||
|
||||
/** Request body for PUT /nwc/{pubkey} */
|
||||
data class NwcRegistrationRequest(
|
||||
val permissions: List<String>,
|
||||
val description: String,
|
||||
val expires_at: Long, // unix timestamp; 0 = no expiry
|
||||
val budgets: List<NwcNewBudget> = emptyList()
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user