Skip to content

Commit 2418531

Browse files
committed
fix: create cjit order
1 parent 2929a74 commit 2418531

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@ import androidx.lifecycle.ViewModel
1111
import androidx.lifecycle.viewModelScope
1212
import androidx.navigation.NavOptions
1313
import androidx.navigation.navOptions
14+
import com.synonym.bitkitcore.Activity
1415
import com.synonym.bitkitcore.ActivityFilter
1516
import com.synonym.bitkitcore.FeeRates
17+
import com.synonym.bitkitcore.LightningActivity
1618
import com.synonym.bitkitcore.LightningInvoice
1719
import com.synonym.bitkitcore.LnurlAuthData
1820
import com.synonym.bitkitcore.LnurlChannelData
1921
import com.synonym.bitkitcore.LnurlPayData
2022
import com.synonym.bitkitcore.LnurlWithdrawData
2123
import com.synonym.bitkitcore.OnChainInvoice
24+
import com.synonym.bitkitcore.PaymentState
2225
import com.synonym.bitkitcore.PaymentType
2326
import com.synonym.bitkitcore.Scanner
2427
import com.synonym.bitkitcore.decode
@@ -54,12 +57,14 @@ import to.bitkit.di.BgDispatcher
5457
import to.bitkit.env.Env
5558
import to.bitkit.ext.WatchResult
5659
import to.bitkit.ext.amountOnClose
60+
import to.bitkit.ext.amountSats
5761
import to.bitkit.ext.getClipboardText
5862
import to.bitkit.ext.getSatsPerVByteFor
5963
import to.bitkit.ext.maxSendableSat
6064
import to.bitkit.ext.maxWithdrawableSat
6165
import to.bitkit.ext.minSendableSat
6266
import to.bitkit.ext.minWithdrawableSat
67+
import to.bitkit.ext.nowTimestamp
6368
import to.bitkit.ext.rawId
6469
import to.bitkit.ext.removeSpaces
6570
import to.bitkit.ext.setClipboardText
@@ -222,14 +227,33 @@ class AppViewModel @Inject constructor(
222227
is Event.ChannelReady -> {
223228
val channel = lightningRepo.getChannels()?.find { it.channelId == event.channelId }
224229
if (channel != null && blocktankRepo.isCjitOrder(channel)) {
230+
val amount = channel.amountOnClose.toLong()
225231
showNewTransactionSheet(
226232
NewTransactionSheetDetails(
227233
type = NewTransactionSheetType.LIGHTNING,
228234
direction = NewTransactionSheetDirection.RECEIVED,
229-
sats = channel.amountOnClose.toLong(),
235+
sats = amount,
230236
),
231237
event = event
232238
)
239+
val now = nowTimestamp().toEpochMilli().toULong()
240+
activityRepo.insertActivity(
241+
Activity.Lightning(
242+
LightningActivity(
243+
id = channel.fundingTxo?.txid.orEmpty(),
244+
txType = PaymentType.RECEIVED,
245+
status = PaymentState.SUCCEEDED,
246+
value = amount.toULong(),
247+
fee = 0U,
248+
invoice = "Loading...", // todo
249+
message = "",
250+
timestamp = now,
251+
preimage = null,
252+
createdAt = now,
253+
updatedAt = null,
254+
)
255+
)
256+
)
233257
} else {
234258
toast(
235259
type = Toast.ToastType.LIGHTNING,

0 commit comments

Comments
 (0)