diff --git a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/Account.kt b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/Account.kt index ee890e0f..131453d4 100644 --- a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/Account.kt +++ b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/Account.kt @@ -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 { return Query( @@ -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 { @@ -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 { @@ -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 { @@ -1218,6 +1227,7 @@ query FetchAccountToWalletsConnection(${'$'}first: Int) { } } wallet_third_party_identifier: third_party_identifier + wallet_status: status } } } diff --git a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/CreateLnurlInvoiceInput.kt b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/CreateLnurlInvoiceInput.kt new file mode 100644 index 00000000..6cc8a750 --- /dev/null +++ b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/CreateLnurlInvoiceInput.kt @@ -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 { + } +} diff --git a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/Entity.kt b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/Entity.kt index ac4594f9..84b2b627 100644 --- a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/Entity.kt +++ b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/Entity.kt @@ -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 { @@ -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 { @@ -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 { @@ -851,6 +860,7 @@ fragment EntityFragment on Entity { } } wallet_third_party_identifier: third_party_identifier + wallet_status: status } ... on Withdrawal { type: __typename diff --git a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/Invoice.kt b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/Invoice.kt index 77c23710..a358000f 100644 --- a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/Invoice.kt +++ b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/Invoice.kt @@ -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 { diff --git a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/InvoiceData.kt b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/InvoiceData.kt index d23770d4..f9300f9c 100644 --- a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/InvoiceData.kt +++ b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/InvoiceData.kt @@ -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 { diff --git a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/LightningTransaction.kt b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/LightningTransaction.kt index 72168046..e2b5ce25 100644 --- a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/LightningTransaction.kt +++ b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/LightningTransaction.kt @@ -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 { diff --git a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/LightsparkNode.kt b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/LightsparkNode.kt index 61508f1a..b650be9c 100644 --- a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/LightsparkNode.kt +++ b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/LightsparkNode.kt @@ -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). @@ -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") @@ -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 { diff --git a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/LightsparkNodeOwner.kt b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/LightsparkNodeOwner.kt new file mode 100644 index 00000000..685250b7 --- /dev/null +++ b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/LightsparkNodeOwner.kt @@ -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 { + 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 + } +}""" + } +} diff --git a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/Node.kt b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/Node.kt index 3d56edc9..c1cc748b 100644 --- a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/Node.kt +++ b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/Node.kt @@ -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 { diff --git a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/OutgoingPayment.kt b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/OutgoingPayment.kt index 72e333e5..d0067031 100644 --- a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/OutgoingPayment.kt +++ b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/OutgoingPayment.kt @@ -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 { diff --git a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/PaymentRequest.kt b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/PaymentRequest.kt index 69901d41..ee04e43e 100644 --- a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/PaymentRequest.kt +++ b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/PaymentRequest.kt @@ -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 { diff --git a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/PaymentRequestData.kt b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/PaymentRequestData.kt index a9c262d4..0ccd3070 100644 --- a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/PaymentRequestData.kt +++ b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/PaymentRequestData.kt @@ -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 { diff --git a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/Transaction.kt b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/Transaction.kt index f1ab3cab..2d96e51b 100644 --- a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/Transaction.kt +++ b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/Transaction.kt @@ -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 { diff --git a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/Wallet.kt b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/Wallet.kt index 629c2bae..0487d0cb 100644 --- a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/Wallet.kt +++ b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/Wallet.kt @@ -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. */ @@ -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 { return Query( @@ -101,11 +104,11 @@ query FetchWalletTotalAmountSent(${'$'}created_after_date: DateTime, ${'$'}creat companion object { @JvmStatic - fun getWalletQuery(): Query { + fun getWalletQuery(id: String): Query { return Query( queryPayload = """ -query GetWallet { - current_wallet { +query GetWallet(${'$'}id: ID!) { + entity(id: ${'$'}id) { ... on Wallet { ...WalletFragment } @@ -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) } } @@ -156,6 +159,7 @@ fragment WalletFragment on Wallet { } } wallet_third_party_identifier: third_party_identifier + wallet_status: status }""" } } diff --git a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/WalletStatus.kt b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/WalletStatus.kt new file mode 100644 index 00000000..1e87277b --- /dev/null +++ b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/model/WalletStatus.kt @@ -0,0 +1,51 @@ +// 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.util.EnumSerializer +import kotlinx.serialization.Serializable + +@Serializable(with = WalletStatusSerializer::class) +enum class WalletStatus(val rawValue: String) { + /** The wallet has not been set up yet and is ready to be deployed. This is the default status after the first login. **/ + NOT_SETUP("NOT_SETUP"), + + /** The wallet is currently being deployed in the Lightspark infrastructure. **/ + DEPLOYING("DEPLOYING"), + + /** The wallet has been deployed in the Lightspark infrastructure and is ready to be initialized. **/ + DEPLOYED("DEPLOYED"), + + /** The wallet is currently being initialized. **/ + INITIALIZING("INITIALIZING"), + + /** The wallet is available and ready to be used. **/ + READY("READY"), + + /** The wallet is temporarily available, due to a transient issue or a scheduled maintenance. **/ + UNAVAILABLE("UNAVAILABLE"), + + /** The wallet had an unrecoverable failure. This status is not expected to happend and will be investigated by the Lightspark team. **/ + FAILED("FAILED"), + + /** The wallet is being terminated. **/ + TERMINATING("TERMINATING"), + + /** The wallet has been terminated and is not available in the Lightspark infrastructure anymore. It is not connected to the Lightning network and its funds can only be accessed using the Funds Recovery flow. **/ + TERMINATED("TERMINATED"), + + /** + * This is an enum value that represents values that could be added in the future. + * Clients should support unknown values as more of them could be added without notice. + */ + FUTURE_VALUE("FUTURE_VALUE"), +} + +object WalletStatusSerializer : + EnumSerializer( + WalletStatus::class, + { rawValue -> + WalletStatus.values().firstOrNull { it.rawValue == rawValue } ?: WalletStatus.FUTURE_VALUE + }, + ) diff --git a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/util/SerializerFormat.kt b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/util/SerializerFormat.kt index 5905cf39..1ae139ea 100644 --- a/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/util/SerializerFormat.kt +++ b/lightspark-sdk/src/commonMain/kotlin/com/lightspark/sdk/util/SerializerFormat.kt @@ -15,6 +15,7 @@ import com.lightspark.sdk.model.Invoice import com.lightspark.sdk.model.InvoiceData import com.lightspark.sdk.model.LightningTransaction import com.lightspark.sdk.model.LightsparkNode +import com.lightspark.sdk.model.LightsparkNodeOwner import com.lightspark.sdk.model.Node import com.lightspark.sdk.model.OnChainTransaction import com.lightspark.sdk.model.OutgoingPayment @@ -57,6 +58,10 @@ private val serializerModule = SerializersModule { subclass(OutgoingPayment::class) subclass(RoutingTransaction::class) } + polymorphic(LightsparkNodeOwner::class) { + subclass(Account::class) + subclass(Wallet::class) + } polymorphic(Node::class) { subclass(GraphNode::class) subclass(LightsparkNode::class) diff --git a/wallet-sdk/src/commonMain/kotlin/com/lightspark/sdk/wallet/model/AmazonS3FundsRecoveryKit.kt b/wallet-sdk/src/commonMain/kotlin/com/lightspark/sdk/wallet/model/AmazonS3FundsRecoveryKit.kt new file mode 100644 index 00000000..491e9f5f --- /dev/null +++ b/wallet-sdk/src/commonMain/kotlin/com/lightspark/sdk/wallet/model/AmazonS3FundsRecoveryKit.kt @@ -0,0 +1,33 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +@file:Suppress("ktlint:max-line-length") + +package com.lightspark.sdk.wallet.model + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +/** + * + * @param bitcoinWalletAddress The bitcoin address where the funds should be sent if the recovery kit is used. + * @param s3BucketUrl The URL of the Amazon S3 bucket URL where we should upload the funds recovery kit. + */ +@Serializable +@SerialName("AmazonS3FundsRecoveryKit") +data class AmazonS3FundsRecoveryKit( + + @SerialName("amazon_s3_funds_recovery_kit_bitcoin_wallet_address") + override val bitcoinWalletAddress: String, + @SerialName("amazon_s3_funds_recovery_kit_s3_bucket_url") + val s3BucketUrl: String, +) : FundsRecoveryKit { + + companion object { + + const val FRAGMENT = """ +fragment AmazonS3FundsRecoveryKitFragment on AmazonS3FundsRecoveryKit { + type: __typename + amazon_s3_funds_recovery_kit_bitcoin_wallet_address: bitcoin_wallet_address + amazon_s3_funds_recovery_kit_s3_bucket_url: s3_bucket_url +}""" + } +} diff --git a/wallet-sdk/src/commonMain/kotlin/com/lightspark/sdk/wallet/model/DeleteFundsRecoveryKitOutput.kt b/wallet-sdk/src/commonMain/kotlin/com/lightspark/sdk/wallet/model/DeleteFundsRecoveryKitOutput.kt new file mode 100644 index 00000000..ed1e67f3 --- /dev/null +++ b/wallet-sdk/src/commonMain/kotlin/com/lightspark/sdk/wallet/model/DeleteFundsRecoveryKitOutput.kt @@ -0,0 +1,30 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +@file:Suppress("ktlint:max-line-length") + +package com.lightspark.sdk.wallet.model + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +/** + * + */ +@Serializable +@SerialName("DeleteFundsRecoveryKitOutput") +data class DeleteFundsRecoveryKitOutput( + + @SerialName("delete_funds_recovery_kit_output_wallet") + val walletId: EntityId, +) { + + companion object { + + const val FRAGMENT = """ +fragment DeleteFundsRecoveryKitOutputFragment on DeleteFundsRecoveryKitOutput { + type: __typename + delete_funds_recovery_kit_output_wallet: wallet { + id + } +}""" + } +} diff --git a/wallet-sdk/src/commonMain/kotlin/com/lightspark/sdk/wallet/model/FundsRecoveryKit.kt b/wallet-sdk/src/commonMain/kotlin/com/lightspark/sdk/wallet/model/FundsRecoveryKit.kt new file mode 100644 index 00000000..c7fc7c0c --- /dev/null +++ b/wallet-sdk/src/commonMain/kotlin/com/lightspark/sdk/wallet/model/FundsRecoveryKit.kt @@ -0,0 +1,29 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +@file:Suppress("ktlint:max-line-length") + +package com.lightspark.sdk.wallet.model + +import kotlinx.serialization.SerialName + +/** + * + * @property bitcoinWalletAddress The bitcoin address where the funds should be sent if the recovery kit is used. + */ +interface FundsRecoveryKit { + + @SerialName("funds_recovery_kit_bitcoin_wallet_address") + val bitcoinWalletAddress: String + + companion object { + + const val FRAGMENT = """ +fragment FundsRecoveryKitFragment on FundsRecoveryKit { + type: __typename + ... on AmazonS3FundsRecoveryKit { + type: __typename + amazon_s3_funds_recovery_kit_bitcoin_wallet_address: bitcoin_wallet_address + amazon_s3_funds_recovery_kit_s3_bucket_url: s3_bucket_url + } +}""" + } +} diff --git a/wallet-sdk/src/commonMain/kotlin/com/lightspark/sdk/wallet/model/UpdateFundsRecoveryKitInput.kt b/wallet-sdk/src/commonMain/kotlin/com/lightspark/sdk/wallet/model/UpdateFundsRecoveryKitInput.kt new file mode 100644 index 00000000..4bbd1e48 --- /dev/null +++ b/wallet-sdk/src/commonMain/kotlin/com/lightspark/sdk/wallet/model/UpdateFundsRecoveryKitInput.kt @@ -0,0 +1,23 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +@file:Suppress("ktlint:max-line-length") + +package com.lightspark.sdk.wallet.model + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +/** + * + */ +@Serializable +@SerialName("UpdateFundsRecoveryKitInput") +data class UpdateFundsRecoveryKitInput( + + val s3BucketUrl: String, + + val bitcoinWalletAddress: String, +) { + + companion object { + } +} diff --git a/wallet-sdk/src/commonMain/kotlin/com/lightspark/sdk/wallet/model/UpdateFundsRecoveryKitOutput.kt b/wallet-sdk/src/commonMain/kotlin/com/lightspark/sdk/wallet/model/UpdateFundsRecoveryKitOutput.kt new file mode 100644 index 00000000..01133723 --- /dev/null +++ b/wallet-sdk/src/commonMain/kotlin/com/lightspark/sdk/wallet/model/UpdateFundsRecoveryKitOutput.kt @@ -0,0 +1,40 @@ +// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved +@file:Suppress("ktlint:max-line-length") + +package com.lightspark.sdk.wallet.model + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +/** + * + */ +@Serializable +@SerialName("UpdateFundsRecoveryKitOutput") +data class UpdateFundsRecoveryKitOutput( + + @SerialName("update_funds_recovery_kit_output_wallet") + val walletId: EntityId, + @SerialName("update_funds_recovery_kit_output_funds_recovery_kit") + val fundsRecoveryKit: FundsRecoveryKit, +) { + + companion object { + + const val FRAGMENT = """ +fragment UpdateFundsRecoveryKitOutputFragment on UpdateFundsRecoveryKitOutput { + type: __typename + update_funds_recovery_kit_output_wallet: wallet { + id + } + update_funds_recovery_kit_output_funds_recovery_kit: funds_recovery_kit { + type: __typename + ... on AmazonS3FundsRecoveryKit { + type: __typename + amazon_s3_funds_recovery_kit_bitcoin_wallet_address: bitcoin_wallet_address + amazon_s3_funds_recovery_kit_s3_bucket_url: s3_bucket_url + } + } +}""" + } +} diff --git a/wallet-sdk/src/commonMain/kotlin/com/lightspark/sdk/wallet/util/SerializerFormat.kt b/wallet-sdk/src/commonMain/kotlin/com/lightspark/sdk/wallet/util/SerializerFormat.kt index 112ed199..eea1b29a 100644 --- a/wallet-sdk/src/commonMain/kotlin/com/lightspark/sdk/wallet/util/SerializerFormat.kt +++ b/wallet-sdk/src/commonMain/kotlin/com/lightspark/sdk/wallet/util/SerializerFormat.kt @@ -1,9 +1,11 @@ package com.lightspark.sdk.wallet.util +import com.lightspark.sdk.wallet.model.AmazonS3FundsRecoveryKit import com.lightspark.sdk.wallet.model.ChannelClosingTransaction import com.lightspark.sdk.wallet.model.ChannelOpeningTransaction import com.lightspark.sdk.wallet.model.Deposit import com.lightspark.sdk.wallet.model.Entity +import com.lightspark.sdk.wallet.model.FundsRecoveryKit import com.lightspark.sdk.wallet.model.GraphNode import com.lightspark.sdk.wallet.model.IncomingPayment import com.lightspark.sdk.wallet.model.Invoice @@ -36,6 +38,9 @@ private val serializerModule = SerializersModule { subclass(Withdrawal::class) subclass(WithdrawalRequest::class) } + polymorphic(FundsRecoveryKit::class) { + subclass(AmazonS3FundsRecoveryKit::class) + } polymorphic(LightningTransaction::class) { subclass(IncomingPayment::class) subclass(OutgoingPayment::class)