Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ data class Account(
override val updatedAt: Instant,
@SerialName("account_name")
val name: String? = null,
) : Entity {
) : LightsparkNodeOwner, Entity {
@JvmOverloads
fun getApiTokensQuery(first: Int? = null): Query<AccountToApiTokensConnection> {
return Query(
Expand Down Expand Up @@ -231,6 +231,9 @@ query FetchAccountToNodesConnection(${'$'}first: Int, ${'$'}bitcoin_networks: [B
lightspark_node_account: account {
id
}
lightspark_node_owner: owner {
id
}
lightspark_node_blockchain_balance: blockchain_balance {
type: __typename
blockchain_balance_total_balance: total_balance {
Expand Down Expand Up @@ -769,6 +772,9 @@ query FetchAccountToTransactionsConnection(${'$'}first: Int, ${'$'}after: String
lightspark_node_account: account {
id
}
lightspark_node_owner: owner {
id
}
lightspark_node_blockchain_balance: blockchain_balance {
type: __typename
blockchain_balance_total_balance: total_balance {
Expand Down Expand Up @@ -1036,6 +1042,9 @@ query FetchAccountToPaymentRequestsConnection(${'$'}first: Int, ${'$'}after: Str
lightspark_node_account: account {
id
}
lightspark_node_owner: owner {
id
}
lightspark_node_blockchain_balance: blockchain_balance {
type: __typename
blockchain_balance_total_balance: total_balance {
Expand Down Expand Up @@ -1218,6 +1227,7 @@ query FetchAccountToWalletsConnection(${'$'}first: Int) {
}
}
wallet_third_party_identifier: third_party_identifier
wallet_status: status
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
@file:Suppress("ktlint:max-line-length")

package com.lightspark.sdk.model

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
*
* @param nodeId The node from which to create the invoice.
* @param amountMsats The amount for which the invoice should be created, in millisatoshis.
* @param metadataHash The SHA256 hash of the LNURL metadata payload. This will be present in the h-tag (SHA256 purpose of payment) of the resulting Bolt 11 invoice.
*/
@Serializable
@SerialName("CreateLnurlInvoiceInput")
data class CreateLnurlInvoiceInput(

val nodeId: String,

val amountMsats: Long,

val metadataHash: String,
) {

companion object {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,9 @@ fragment EntityFragment on Entity {
lightspark_node_account: account {
id
}
lightspark_node_owner: owner {
id
}
lightspark_node_blockchain_balance: blockchain_balance {
type: __typename
blockchain_balance_total_balance: total_balance {
Expand Down Expand Up @@ -485,6 +488,9 @@ fragment EntityFragment on Entity {
lightspark_node_account: account {
id
}
lightspark_node_owner: owner {
id
}
lightspark_node_blockchain_balance: blockchain_balance {
type: __typename
blockchain_balance_total_balance: total_balance {
Expand Down Expand Up @@ -652,6 +658,9 @@ fragment EntityFragment on Entity {
lightspark_node_account: account {
id
}
lightspark_node_owner: owner {
id
}
lightspark_node_blockchain_balance: blockchain_balance {
type: __typename
blockchain_balance_total_balance: total_balance {
Expand Down Expand Up @@ -851,6 +860,7 @@ fragment EntityFragment on Entity {
}
}
wallet_third_party_identifier: third_party_identifier
wallet_status: status
}
... on Withdrawal {
type: __typename
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ fragment InvoiceFragment on Invoice {
lightspark_node_account: account {
id
}
lightspark_node_owner: owner {
id
}
lightspark_node_blockchain_balance: blockchain_balance {
type: __typename
blockchain_balance_total_balance: total_balance {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ fragment InvoiceDataFragment on InvoiceData {
lightspark_node_account: account {
id
}
lightspark_node_owner: owner {
id
}
lightspark_node_blockchain_balance: blockchain_balance {
type: __typename
blockchain_balance_total_balance: total_balance {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ fragment LightningTransactionFragment on LightningTransaction {
lightspark_node_account: account {
id
}
lightspark_node_owner: owner {
id
}
lightspark_node_blockchain_balance: blockchain_balance {
type: __typename
blockchain_balance_total_balance: total_balance {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import kotlinx.serialization.json.jsonObject
* @param bitcoinNetwork The Bitcoin Network this node is deployed in.
* @param displayName The name of this node in the network. It will be the most human-readable option possible, depending on the data available for this node.
* @param accountId The account that owns this LightsparkNode.
* @param ownerId The owner of this LightsparkNode.
* @param alias A name that identifies the node. It has no importance in terms of operating the node, it is just a way to identify and search for commercial services or popular nodes. This alias can be changed at any time by the node operator.
* @param color A hexadecimal string that describes a color. For example "#000000" is black, "#FFFFFF" is white. It has no importance in terms of operating the node, it is just a way to visually differentiate nodes. That color can be changed at any time by the node operator.
* @param conductivity A summary metric used to capture how well positioned a node is to send, receive, or route transactions efficiently. Maximizing a node's conductivity helps a node’s transactions to be capital efficient. The value is an integer ranging between 0 and 10 (bounds included).
Expand Down Expand Up @@ -50,6 +51,8 @@ data class LightsparkNode(
override val displayName: String,
@SerialName("lightspark_node_account")
val accountId: EntityId,
@SerialName("lightspark_node_owner")
val ownerId: EntityId,
@SerialName("lightspark_node_alias")
override val alias: String? = null,
@SerialName("lightspark_node_color")
Expand Down Expand Up @@ -270,6 +273,9 @@ fragment LightsparkNodeFragment on LightsparkNode {
lightspark_node_account: account {
id
}
lightspark_node_owner: owner {
id
}
lightspark_node_blockchain_balance: blockchain_balance {
type: __typename
blockchain_balance_total_balance: total_balance {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
@file:Suppress("ktlint:max-line-length")

package com.lightspark.sdk.model

import com.lightspark.sdk.core.requester.Query
import com.lightspark.sdk.util.serializerFormat
import kotlin.jvm.JvmStatic
import kotlinx.datetime.Instant
import kotlinx.serialization.SerialName
import kotlinx.serialization.json.decodeFromJsonElement

/**
*
* @property id The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string.
* @property createdAt The date and time when the entity was first created.
* @property updatedAt The date and time when the entity was last updated.
*/
interface LightsparkNodeOwner : Entity {

@SerialName("lightspark_node_owner_id")
override val id: String

@SerialName("lightspark_node_owner_created_at")
override val createdAt: Instant

@SerialName("lightspark_node_owner_updated_at")
override val updatedAt: Instant

companion object {
@JvmStatic
fun getLightsparkNodeOwnerQuery(id: String): Query<LightsparkNodeOwner> {
return Query(
queryPayload = """
query GetLightsparkNodeOwner(${'$'}id: ID!) {
entity(id: ${'$'}id) {
... on LightsparkNodeOwner {
...LightsparkNodeOwnerFragment
}
}
}

$FRAGMENT
""",
variableBuilder = { add("id", id) },
) {
val entity = requireNotNull(it["entity"]) { "Entity not found" }
serializerFormat.decodeFromJsonElement(entity)
}
}

const val FRAGMENT = """
fragment LightsparkNodeOwnerFragment on LightsparkNodeOwner {
type: __typename
... on Account {
type: __typename
account_id: id
account_created_at: created_at
account_updated_at: updated_at
account_name: name
}
... on Wallet {
type: __typename
wallet_id: id
wallet_created_at: created_at
wallet_updated_at: updated_at
wallet_last_login_at: last_login_at
wallet_balances: balances {
type: __typename
balances_owned_balance: owned_balance {
type: __typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
balances_available_to_send_balance: available_to_send_balance {
type: __typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
balances_available_to_withdraw_balance: available_to_withdraw_balance {
type: __typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
}
wallet_third_party_identifier: third_party_identifier
wallet_status: status
}
}"""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ fragment NodeFragment on Node {
lightspark_node_account: account {
id
}
lightspark_node_owner: owner {
id
}
lightspark_node_blockchain_balance: blockchain_balance {
type: __typename
blockchain_balance_total_balance: total_balance {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ fragment OutgoingPaymentFragment on OutgoingPayment {
lightspark_node_account: account {
id
}
lightspark_node_owner: owner {
id
}
lightspark_node_blockchain_balance: blockchain_balance {
type: __typename
blockchain_balance_total_balance: total_balance {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ fragment PaymentRequestFragment on PaymentRequest {
lightspark_node_account: account {
id
}
lightspark_node_owner: owner {
id
}
lightspark_node_blockchain_balance: blockchain_balance {
type: __typename
blockchain_balance_total_balance: total_balance {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ fragment PaymentRequestDataFragment on PaymentRequestData {
lightspark_node_account: account {
id
}
lightspark_node_owner: owner {
id
}
lightspark_node_blockchain_balance: blockchain_balance {
type: __typename
blockchain_balance_total_balance: total_balance {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ fragment TransactionFragment on Transaction {
lightspark_node_account: account {
id
}
lightspark_node_owner: owner {
id
}
lightspark_node_blockchain_balance: blockchain_balance {
type: __typename
blockchain_balance_total_balance: total_balance {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import kotlinx.serialization.json.jsonObject
* @param createdAt The date and time when the entity was first created.
* @param updatedAt The date and time when the entity was last updated.
* @param thirdPartyIdentifier The unique identifier of this wallet, as provided by the Lightspark Customer during login.
* @param status The status of this wallet.
* @param lastLoginAt The date and time when the wallet user last logged in.
* @param balances The balances that describe the funds in this wallet.
*/
Expand All @@ -34,11 +35,13 @@ data class Wallet(
override val updatedAt: Instant,
@SerialName("wallet_third_party_identifier")
val thirdPartyIdentifier: String,
@SerialName("wallet_status")
val status: WalletStatus,
@SerialName("wallet_last_login_at")
val lastLoginAt: Instant? = null,
@SerialName("wallet_balances")
val balances: Balances? = null,
) : Entity {
) : LightsparkNodeOwner, Entity {
@JvmOverloads
fun getTotalAmountReceivedQuery(createdAfterDate: Instant? = null, createdBeforeDate: Instant? = null): Query<CurrencyAmount> {
return Query(
Expand Down Expand Up @@ -101,11 +104,11 @@ query FetchWalletTotalAmountSent(${'$'}created_after_date: DateTime, ${'$'}creat

companion object {
@JvmStatic
fun getWalletQuery(): Query<Wallet> {
fun getWalletQuery(id: String): Query<Wallet> {
return Query(
queryPayload = """
query GetWallet {
current_wallet {
query GetWallet(${'$'}id: ID!) {
entity(id: ${'$'}id) {
... on Wallet {
...WalletFragment
}
Expand All @@ -114,9 +117,9 @@ query GetWallet {

$FRAGMENT
""",
variableBuilder = { },
variableBuilder = { add("id", id) },
) {
val entity = requireNotNull(it["current_wallet"]) { "Entity not found" }
val entity = requireNotNull(it["entity"]) { "Entity not found" }
serializerFormat.decodeFromJsonElement(entity)
}
}
Expand Down Expand Up @@ -156,6 +159,7 @@ fragment WalletFragment on Wallet {
}
}
wallet_third_party_identifier: third_party_identifier
wallet_status: status
}"""
}
}
Loading