commonMain.com.lightspark.sdk.wallet.model.OnChainTransaction.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of wallet-sdk Show documentation
Show all versions of wallet-sdk Show documentation
The Lightspark Wallet SDK for Kotlin and Java.
The newest version!
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
@file:Suppress("ktlint:standard:max-line-length")
package com.lightspark.sdk.wallet.model
import com.lightspark.sdk.core.requester.Query
import com.lightspark.sdk.wallet.util.serializerFormat
import kotlin.jvm.JvmStatic
import kotlinx.datetime.Instant
import kotlinx.serialization.SerialName
import kotlinx.serialization.json.decodeFromJsonElement
/**
* This object represents an L1 transaction that occurred on the Bitcoin Network. You can retrieve this object to receive information about a specific on-chain transaction made on the Lightning Network associated with your Lightspark Node.
* @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 this transaction was initiated.
* @property updatedAt The date and time when the entity was last updated.
* @property status The current status of this transaction.
* @property amount The amount of money involved in this transaction.
* @property blockHeight The height of the block that included this transaction. This will be zero for unconfirmed transactions.
* @property destinationAddresses The Bitcoin blockchain addresses this transaction was sent to.
* @property resolvedAt The date and time when this transaction was completed or failed.
* @property transactionHash The hash of this transaction, so it can be uniquely identified on the Lightning Network.
* @property fees The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin blockchain.
* @property blockHash The hash of the block that included this transaction. This will be null for unconfirmed transactions.
* @property numConfirmations The number of blockchain confirmations for this transaction in real time.
*/
interface OnChainTransaction : Transaction, Entity {
@SerialName("on_chain_transaction_id")
override val id: String
@SerialName("on_chain_transaction_created_at")
override val createdAt: Instant
@SerialName("on_chain_transaction_updated_at")
override val updatedAt: Instant
@SerialName("on_chain_transaction_status")
override val status: TransactionStatus
@SerialName("on_chain_transaction_amount")
override val amount: CurrencyAmount
@SerialName("on_chain_transaction_block_height")
val blockHeight: Int
@SerialName("on_chain_transaction_destination_addresses")
val destinationAddresses: List
@SerialName("on_chain_transaction_resolved_at")
override val resolvedAt: Instant?
@SerialName("on_chain_transaction_transaction_hash")
override val transactionHash: String?
@SerialName("on_chain_transaction_fees")
val fees: CurrencyAmount?
@SerialName("on_chain_transaction_block_hash")
val blockHash: String?
@SerialName("on_chain_transaction_num_confirmations")
val numConfirmations: Int?
companion object {
@JvmStatic
fun getOnChainTransactionQuery(id: String): Query {
return Query(
queryPayload = """
query GetOnChainTransaction(${'$'}id: ID!) {
entity(id: ${'$'}id) {
... on OnChainTransaction {
...OnChainTransactionFragment
}
}
}
$FRAGMENT
""",
variableBuilder = { add("id", id) },
) {
val entity = requireNotNull(it["entity"]) { "Entity not found" }
serializerFormat.decodeFromJsonElement(entity)
}
}
const val FRAGMENT = """
fragment OnChainTransactionFragment on OnChainTransaction {
type: __typename
... on ChannelClosingTransaction {
type: __typename
channel_closing_transaction_id: id
channel_closing_transaction_created_at: created_at
channel_closing_transaction_updated_at: updated_at
channel_closing_transaction_status: status
channel_closing_transaction_resolved_at: resolved_at
channel_closing_transaction_amount: amount {
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
}
channel_closing_transaction_transaction_hash: transaction_hash
channel_closing_transaction_fees: fees {
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
}
channel_closing_transaction_block_hash: block_hash
channel_closing_transaction_block_height: block_height
channel_closing_transaction_destination_addresses: destination_addresses
channel_closing_transaction_num_confirmations: num_confirmations
}
... on ChannelOpeningTransaction {
type: __typename
channel_opening_transaction_id: id
channel_opening_transaction_created_at: created_at
channel_opening_transaction_updated_at: updated_at
channel_opening_transaction_status: status
channel_opening_transaction_resolved_at: resolved_at
channel_opening_transaction_amount: amount {
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
}
channel_opening_transaction_transaction_hash: transaction_hash
channel_opening_transaction_fees: fees {
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
}
channel_opening_transaction_block_hash: block_hash
channel_opening_transaction_block_height: block_height
channel_opening_transaction_destination_addresses: destination_addresses
channel_opening_transaction_num_confirmations: num_confirmations
}
... on Deposit {
type: __typename
deposit_id: id
deposit_created_at: created_at
deposit_updated_at: updated_at
deposit_status: status
deposit_resolved_at: resolved_at
deposit_amount: amount {
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
}
deposit_transaction_hash: transaction_hash
deposit_fees: fees {
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
}
deposit_block_hash: block_hash
deposit_block_height: block_height
deposit_destination_addresses: destination_addresses
deposit_num_confirmations: num_confirmations
}
... on Withdrawal {
type: __typename
withdrawal_id: id
withdrawal_created_at: created_at
withdrawal_updated_at: updated_at
withdrawal_status: status
withdrawal_resolved_at: resolved_at
withdrawal_amount: amount {
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
}
withdrawal_transaction_hash: transaction_hash
withdrawal_fees: fees {
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
}
withdrawal_block_hash: block_hash
withdrawal_block_height: block_height
withdrawal_destination_addresses: destination_addresses
withdrawal_num_confirmations: num_confirmations
}
}"""
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy