Skip to content

Commit 8de878e

Browse files
Lightspark Engjklein24
authored andcommitted
Project import generated by Copybara.
GitOrigin-RevId: c284a34b63feef31d95b9cad97d5e70e767800a1
1 parent 07e0c97 commit 8de878e

File tree

9 files changed

+467
-3
lines changed

9 files changed

+467
-3
lines changed

wallet-sdk/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ Start by installing the SDK from maven:
1717

1818
```groovy
1919
dependencies {
20-
implementation "com.lightspark:wallet-sdk:0.1.1"
20+
implementation "com.lightspark:wallet-sdk:0.1.2"
2121
}
2222
```
2323

2424
or with **build.gradle.kts:**
2525

2626
```kotlin
2727
dependencies {
28-
implementation("com.lightspark:wallet-sdk:0.1.1")
28+
implementation("com.lightspark:wallet-sdk:0.1.2")
2929
}
3030
```
3131

wallet-sdk/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
GROUP=com.lightspark
22
POM_ARTIFACT_ID=wallet-sdk
33
# Don't bump this manually. Run `scripts/versions.main.kt <new_version>` to bump the version instead.
4-
VERSION_NAME=0.1.2-SNAPSHOT
4+
VERSION_NAME=0.1.3-SNAPSHOT
55

66
POM_DESCRIPTION=The Lightspark Wallet SDK for Kotlin and Java.
77
POM_INCEPTION_YEAR=2023
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2+
@file:Suppress("ktlint:max-line-length")
3+
4+
package com.lightspark.sdk.wallet.model
5+
6+
import com.lightspark.sdk.core.requester.Query
7+
import com.lightspark.sdk.wallet.util.serializerFormat
8+
import kotlinx.datetime.Instant
9+
import kotlinx.serialization.SerialName
10+
import kotlinx.serialization.Serializable
11+
import kotlinx.serialization.json.decodeFromJsonElement
12+
import kotlin.jvm.JvmStatic
13+
14+
/**
15+
* The transaction on Bitcoin blockchain to close a channel on Lightning Network where the balances are allocated back to local and remote nodes.
16+
* @param id The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string.
17+
* @param createdAt The date and time when this transaction was initiated.
18+
* @param updatedAt The date and time when the entity was last updated.
19+
* @param status The current status of this transaction.
20+
* @param amount The amount of money involved in this transaction.
21+
* @param blockHeight The height of the block that included this transaction. This will be zero for unconfirmed transactions.
22+
* @param destinationAddresses The Bitcoin blockchain addresses this transaction was sent to.
23+
* @param resolvedAt The date and time when this transaction was completed or failed.
24+
* @param transactionHash The hash of this transaction, so it can be uniquely identified on the Lightning Network.
25+
* @param fees The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin blockchain.
26+
* @param blockHash The hash of the block that included this transaction. This will be null for unconfirmed transactions.
27+
* @param numConfirmations The number of blockchain confirmations for this transaction in real time.
28+
*/
29+
@Serializable
30+
@SerialName("ChannelClosingTransaction")
31+
data class ChannelClosingTransaction(
32+
33+
@SerialName("channel_closing_transaction_id")
34+
override val id: String,
35+
@SerialName("channel_closing_transaction_created_at")
36+
override val createdAt: Instant,
37+
@SerialName("channel_closing_transaction_updated_at")
38+
override val updatedAt: Instant,
39+
@SerialName("channel_closing_transaction_status")
40+
override val status: TransactionStatus,
41+
@SerialName("channel_closing_transaction_amount")
42+
override val amount: CurrencyAmount,
43+
@SerialName("channel_closing_transaction_block_height")
44+
override val blockHeight: Int,
45+
@SerialName("channel_closing_transaction_destination_addresses")
46+
override val destinationAddresses: List<String>,
47+
@SerialName("channel_closing_transaction_resolved_at")
48+
override val resolvedAt: Instant? = null,
49+
@SerialName("channel_closing_transaction_transaction_hash")
50+
override val transactionHash: String? = null,
51+
@SerialName("channel_closing_transaction_fees")
52+
override val fees: CurrencyAmount? = null,
53+
@SerialName("channel_closing_transaction_block_hash")
54+
override val blockHash: String? = null,
55+
@SerialName("channel_closing_transaction_num_confirmations")
56+
override val numConfirmations: Int? = null,
57+
) : OnChainTransaction, Transaction, Entity {
58+
59+
companion object {
60+
@JvmStatic
61+
fun getChannelClosingTransactionQuery(id: String): Query<ChannelClosingTransaction> {
62+
return Query(
63+
queryPayload = """
64+
query GetChannelClosingTransaction(${'$'}id: ID!) {
65+
entity(id: ${'$'}id) {
66+
... on ChannelClosingTransaction {
67+
...ChannelClosingTransactionFragment
68+
}
69+
}
70+
}
71+
72+
$FRAGMENT
73+
""",
74+
variableBuilder = { add("id", id) },
75+
) {
76+
val entity = requireNotNull(it["entity"]) { "Entity not found" }
77+
serializerFormat.decodeFromJsonElement(entity)
78+
}
79+
}
80+
81+
const val FRAGMENT = """
82+
fragment ChannelClosingTransactionFragment on ChannelClosingTransaction {
83+
type: __typename
84+
channel_closing_transaction_id: id
85+
channel_closing_transaction_created_at: created_at
86+
channel_closing_transaction_updated_at: updated_at
87+
channel_closing_transaction_status: status
88+
channel_closing_transaction_resolved_at: resolved_at
89+
channel_closing_transaction_amount: amount {
90+
type: __typename
91+
currency_amount_original_value: original_value
92+
currency_amount_original_unit: original_unit
93+
currency_amount_preferred_currency_unit: preferred_currency_unit
94+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
95+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
96+
}
97+
channel_closing_transaction_transaction_hash: transaction_hash
98+
channel_closing_transaction_fees: fees {
99+
type: __typename
100+
currency_amount_original_value: original_value
101+
currency_amount_original_unit: original_unit
102+
currency_amount_preferred_currency_unit: preferred_currency_unit
103+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
104+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
105+
}
106+
channel_closing_transaction_block_hash: block_hash
107+
channel_closing_transaction_block_height: block_height
108+
channel_closing_transaction_destination_addresses: destination_addresses
109+
channel_closing_transaction_num_confirmations: num_confirmations
110+
}"""
111+
}
112+
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
// Copyright ©, 2023-present, Lightspark Group, Inc. - All Rights Reserved
2+
@file:Suppress("ktlint:max-line-length")
3+
4+
package com.lightspark.sdk.wallet.model
5+
6+
import com.lightspark.sdk.core.requester.Query
7+
import com.lightspark.sdk.wallet.util.serializerFormat
8+
import kotlinx.datetime.Instant
9+
import kotlinx.serialization.SerialName
10+
import kotlinx.serialization.Serializable
11+
import kotlinx.serialization.json.decodeFromJsonElement
12+
import kotlin.jvm.JvmStatic
13+
14+
/**
15+
* The transaction on Bitcoin blockchain to open a channel on Lightning Network funded by the local Lightspark node.
16+
* @param id The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string.
17+
* @param createdAt The date and time when this transaction was initiated.
18+
* @param updatedAt The date and time when the entity was last updated.
19+
* @param status The current status of this transaction.
20+
* @param amount The amount of money involved in this transaction.
21+
* @param blockHeight The height of the block that included this transaction. This will be zero for unconfirmed transactions.
22+
* @param destinationAddresses The Bitcoin blockchain addresses this transaction was sent to.
23+
* @param resolvedAt The date and time when this transaction was completed or failed.
24+
* @param transactionHash The hash of this transaction, so it can be uniquely identified on the Lightning Network.
25+
* @param fees The fees that were paid by the wallet sending the transaction to commit it to the Bitcoin blockchain.
26+
* @param blockHash The hash of the block that included this transaction. This will be null for unconfirmed transactions.
27+
* @param numConfirmations The number of blockchain confirmations for this transaction in real time.
28+
*/
29+
@Serializable
30+
@SerialName("ChannelOpeningTransaction")
31+
data class ChannelOpeningTransaction(
32+
33+
@SerialName("channel_opening_transaction_id")
34+
override val id: String,
35+
@SerialName("channel_opening_transaction_created_at")
36+
override val createdAt: Instant,
37+
@SerialName("channel_opening_transaction_updated_at")
38+
override val updatedAt: Instant,
39+
@SerialName("channel_opening_transaction_status")
40+
override val status: TransactionStatus,
41+
@SerialName("channel_opening_transaction_amount")
42+
override val amount: CurrencyAmount,
43+
@SerialName("channel_opening_transaction_block_height")
44+
override val blockHeight: Int,
45+
@SerialName("channel_opening_transaction_destination_addresses")
46+
override val destinationAddresses: List<String>,
47+
@SerialName("channel_opening_transaction_resolved_at")
48+
override val resolvedAt: Instant? = null,
49+
@SerialName("channel_opening_transaction_transaction_hash")
50+
override val transactionHash: String? = null,
51+
@SerialName("channel_opening_transaction_fees")
52+
override val fees: CurrencyAmount? = null,
53+
@SerialName("channel_opening_transaction_block_hash")
54+
override val blockHash: String? = null,
55+
@SerialName("channel_opening_transaction_num_confirmations")
56+
override val numConfirmations: Int? = null,
57+
) : OnChainTransaction, Transaction, Entity {
58+
59+
companion object {
60+
@JvmStatic
61+
fun getChannelOpeningTransactionQuery(id: String): Query<ChannelOpeningTransaction> {
62+
return Query(
63+
queryPayload = """
64+
query GetChannelOpeningTransaction(${'$'}id: ID!) {
65+
entity(id: ${'$'}id) {
66+
... on ChannelOpeningTransaction {
67+
...ChannelOpeningTransactionFragment
68+
}
69+
}
70+
}
71+
72+
$FRAGMENT
73+
""",
74+
variableBuilder = { add("id", id) },
75+
) {
76+
val entity = requireNotNull(it["entity"]) { "Entity not found" }
77+
serializerFormat.decodeFromJsonElement(entity)
78+
}
79+
}
80+
81+
const val FRAGMENT = """
82+
fragment ChannelOpeningTransactionFragment on ChannelOpeningTransaction {
83+
type: __typename
84+
channel_opening_transaction_id: id
85+
channel_opening_transaction_created_at: created_at
86+
channel_opening_transaction_updated_at: updated_at
87+
channel_opening_transaction_status: status
88+
channel_opening_transaction_resolved_at: resolved_at
89+
channel_opening_transaction_amount: amount {
90+
type: __typename
91+
currency_amount_original_value: original_value
92+
currency_amount_original_unit: original_unit
93+
currency_amount_preferred_currency_unit: preferred_currency_unit
94+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
95+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
96+
}
97+
channel_opening_transaction_transaction_hash: transaction_hash
98+
channel_opening_transaction_fees: fees {
99+
type: __typename
100+
currency_amount_original_value: original_value
101+
currency_amount_original_unit: original_unit
102+
currency_amount_preferred_currency_unit: preferred_currency_unit
103+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
104+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
105+
}
106+
channel_opening_transaction_block_hash: block_hash
107+
channel_opening_transaction_block_height: block_height
108+
channel_opening_transaction_destination_addresses: destination_addresses
109+
channel_opening_transaction_num_confirmations: num_confirmations
110+
}"""
111+
}
112+
}

wallet-sdk/src/commonMain/kotlin/com/lightspark/sdk/wallet/model/Entity.kt

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,64 @@ interface Entity {
2828
const val FRAGMENT = """
2929
fragment EntityFragment on Entity {
3030
type: __typename
31+
... on ChannelClosingTransaction {
32+
type: __typename
33+
channel_closing_transaction_id: id
34+
channel_closing_transaction_created_at: created_at
35+
channel_closing_transaction_updated_at: updated_at
36+
channel_closing_transaction_status: status
37+
channel_closing_transaction_resolved_at: resolved_at
38+
channel_closing_transaction_amount: amount {
39+
type: __typename
40+
currency_amount_original_value: original_value
41+
currency_amount_original_unit: original_unit
42+
currency_amount_preferred_currency_unit: preferred_currency_unit
43+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
44+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
45+
}
46+
channel_closing_transaction_transaction_hash: transaction_hash
47+
channel_closing_transaction_fees: fees {
48+
type: __typename
49+
currency_amount_original_value: original_value
50+
currency_amount_original_unit: original_unit
51+
currency_amount_preferred_currency_unit: preferred_currency_unit
52+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
53+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
54+
}
55+
channel_closing_transaction_block_hash: block_hash
56+
channel_closing_transaction_block_height: block_height
57+
channel_closing_transaction_destination_addresses: destination_addresses
58+
channel_closing_transaction_num_confirmations: num_confirmations
59+
}
60+
... on ChannelOpeningTransaction {
61+
type: __typename
62+
channel_opening_transaction_id: id
63+
channel_opening_transaction_created_at: created_at
64+
channel_opening_transaction_updated_at: updated_at
65+
channel_opening_transaction_status: status
66+
channel_opening_transaction_resolved_at: resolved_at
67+
channel_opening_transaction_amount: amount {
68+
type: __typename
69+
currency_amount_original_value: original_value
70+
currency_amount_original_unit: original_unit
71+
currency_amount_preferred_currency_unit: preferred_currency_unit
72+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
73+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
74+
}
75+
channel_opening_transaction_transaction_hash: transaction_hash
76+
channel_opening_transaction_fees: fees {
77+
type: __typename
78+
currency_amount_original_value: original_value
79+
currency_amount_original_unit: original_unit
80+
currency_amount_preferred_currency_unit: preferred_currency_unit
81+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
82+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
83+
}
84+
channel_opening_transaction_block_hash: block_hash
85+
channel_opening_transaction_block_height: block_height
86+
channel_opening_transaction_destination_addresses: destination_addresses
87+
channel_opening_transaction_num_confirmations: num_confirmations
88+
}
3189
... on Deposit {
3290
type: __typename
3391
deposit_id: id

wallet-sdk/src/commonMain/kotlin/com/lightspark/sdk/wallet/model/OnChainTransaction.kt

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,64 @@ $FRAGMENT
8888
const val FRAGMENT = """
8989
fragment OnChainTransactionFragment on OnChainTransaction {
9090
type: __typename
91+
... on ChannelClosingTransaction {
92+
type: __typename
93+
channel_closing_transaction_id: id
94+
channel_closing_transaction_created_at: created_at
95+
channel_closing_transaction_updated_at: updated_at
96+
channel_closing_transaction_status: status
97+
channel_closing_transaction_resolved_at: resolved_at
98+
channel_closing_transaction_amount: amount {
99+
type: __typename
100+
currency_amount_original_value: original_value
101+
currency_amount_original_unit: original_unit
102+
currency_amount_preferred_currency_unit: preferred_currency_unit
103+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
104+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
105+
}
106+
channel_closing_transaction_transaction_hash: transaction_hash
107+
channel_closing_transaction_fees: fees {
108+
type: __typename
109+
currency_amount_original_value: original_value
110+
currency_amount_original_unit: original_unit
111+
currency_amount_preferred_currency_unit: preferred_currency_unit
112+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
113+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
114+
}
115+
channel_closing_transaction_block_hash: block_hash
116+
channel_closing_transaction_block_height: block_height
117+
channel_closing_transaction_destination_addresses: destination_addresses
118+
channel_closing_transaction_num_confirmations: num_confirmations
119+
}
120+
... on ChannelOpeningTransaction {
121+
type: __typename
122+
channel_opening_transaction_id: id
123+
channel_opening_transaction_created_at: created_at
124+
channel_opening_transaction_updated_at: updated_at
125+
channel_opening_transaction_status: status
126+
channel_opening_transaction_resolved_at: resolved_at
127+
channel_opening_transaction_amount: amount {
128+
type: __typename
129+
currency_amount_original_value: original_value
130+
currency_amount_original_unit: original_unit
131+
currency_amount_preferred_currency_unit: preferred_currency_unit
132+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
133+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
134+
}
135+
channel_opening_transaction_transaction_hash: transaction_hash
136+
channel_opening_transaction_fees: fees {
137+
type: __typename
138+
currency_amount_original_value: original_value
139+
currency_amount_original_unit: original_unit
140+
currency_amount_preferred_currency_unit: preferred_currency_unit
141+
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
142+
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
143+
}
144+
channel_opening_transaction_block_hash: block_hash
145+
channel_opening_transaction_block_height: block_height
146+
channel_opening_transaction_destination_addresses: destination_addresses
147+
channel_opening_transaction_num_confirmations: num_confirmations
148+
}
91149
... on Deposit {
92150
type: __typename
93151
deposit_id: id

0 commit comments

Comments
 (0)