Skip to content

Commit 4f6d3bf

Browse files
committed
chore: update to ldk-node 0.7.0
1 parent 3369686 commit 4f6d3bf

File tree

7 files changed

+20
-10
lines changed

7 files changed

+20
-10
lines changed

app/src/main/java/to/bitkit/fcm/WakeNodeWorker.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ class WakeNodeWorker @AssistedInject constructor(
144144
self.deliver()
145145
}
146146
}
147+
else -> Unit
147148
}
148149
}
149150

app/src/main/java/to/bitkit/repositories/WalletRepo.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import kotlinx.coroutines.flow.update
1515
import kotlinx.coroutines.launch
1616
import kotlinx.coroutines.withContext
1717
import org.lightningdevkit.ldknode.Event
18+
import org.lightningdevkit.ldknode.WordCount
1819
import to.bitkit.data.CacheStore
1920
import to.bitkit.data.SettingsStore
2021
import to.bitkit.data.keychain.Keychain
@@ -564,7 +565,7 @@ class WalletRepo @Inject constructor(
564565
}
565566

566567
private fun generateEntropyMnemonic(): String {
567-
return org.lightningdevkit.ldknode.generateEntropyMnemonic()
568+
return org.lightningdevkit.ldknode.generateEntropyMnemonic(wordCount = WordCount.WORDS12)
568569
}
569570

570571
private companion object {

app/src/main/java/to/bitkit/services/LightningService.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import org.lightningdevkit.ldknode.ElectrumSyncConfig
2626
import org.lightningdevkit.ldknode.Event
2727
import org.lightningdevkit.ldknode.FeeRate
2828
import org.lightningdevkit.ldknode.Node
29+
import org.lightningdevkit.ldknode.NodeEntropy
2930
import org.lightningdevkit.ldknode.NodeException
3031
import org.lightningdevkit.ldknode.NodeStatus
3132
import org.lightningdevkit.ldknode.PaymentDetails
@@ -99,14 +100,13 @@ class LightningService @Inject constructor(
99100

100101
configureChainSource(customServerUrl)
101102
configureGossipSource(customRgsServerUrl)
102-
103-
setEntropyBip39Mnemonic(mnemonic, passphrase)
104103
}
105104

106105
Logger.debug("Building node…")
107-
108106
val vssStoreId = vssStoreIdProvider.getVssStoreId(walletIndex)
109107

108+
val nodeEntropy = NodeEntropy.fromBip39Mnemonic(mnemonic, passphrase)
109+
110110
ServiceQueue.LDK.background {
111111
node = try {
112112
val lnurlAuthServerUrl = Env.lnurlAuthServerUrl
@@ -119,16 +119,21 @@ class LightningService @Inject constructor(
119119
storeId = vssStoreId,
120120
lnurlAuthServerUrl = lnurlAuthServerUrl,
121121
fixedHeaders = emptyMap(),
122+
nodeEntropy = nodeEntropy,
122123
)
123124
} else {
124125
builder.buildWithVssStoreAndFixedHeaders(
125126
vssUrl = vssUrl,
126127
storeId = vssStoreId,
127128
fixedHeaders = emptyMap(),
129+
nodeEntropy = nodeEntropy,
128130
)
129131
}
130132
} catch (e: BuildException) {
131133
throw LdkError(e)
134+
} finally {
135+
// cleanup sensitive data
136+
nodeEntropy.destroy()
132137
}
133138
}
134139

@@ -760,6 +765,8 @@ class LightningService @Inject constructor(
760765
"⛔ Channel closed: channelId: $channelId userChannelId: $userChannelId counterpartyNodeId: $counterpartyNodeId reason: $reason"
761766
)
762767
}
768+
769+
else -> Logger.info("LDK-node event: $event")
763770
}
764771
}
765772
// endregion

app/src/main/java/to/bitkit/ui/NodeInfoScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,6 @@ private fun PreviewDevMode() {
452452
nodeLifecycleState = NodeLifecycleState.Running,
453453
nodeStatus = NodeStatus(
454454
isRunning = true,
455-
isListening = true,
456455
currentBestBlock = BestBlock(
457456
height = 1000u,
458457
blockHash = "0123456789abcDef",
@@ -463,6 +462,7 @@ private fun PreviewDevMode() {
463462
latestRgsSnapshotTimestamp = null,
464463
latestNodeAnnouncementBroadcastTimestamp = null,
465464
latestChannelMonitorArchivalHeight = null,
465+
latestPathfindingScoresSyncTimestamp = null,
466466
),
467467
nodeId = "0348a2b7c2d3f4e5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9",
468468
peers = listOf(Env.Peers.staging),

app/src/main/java/to/bitkit/utils/Errors.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ class LdkError(private val inner: LdkException) : AppError("Unknown LDK error.")
4646
class Build(exception: BuildException) : LdkException {
4747
override val message = when (exception) {
4848
is BuildException.InvalidChannelMonitor -> "Invalid channel monitor."
49-
is BuildException.InvalidSeedBytes -> "Invalid seed bytes."
50-
is BuildException.InvalidSeedFile -> "Invalid seed file."
5149
is BuildException.InvalidSystemTime -> "Invalid system time."
5250
is BuildException.InvalidListeningAddresses -> "Invalid listening addresses."
5351
is BuildException.ReadFailed -> "Read failed."

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,9 @@ class AppViewModel @Inject constructor(
290290
is Event.PaymentClaimable -> Unit
291291
is Event.PaymentFailed -> Unit
292292
is Event.PaymentForwarded -> Unit
293+
else -> {
294+
Logger.warn("Unhandled LDK event: $event", context = TAG)
295+
}
293296
}
294297
}.onFailure { e ->
295298
Logger.error("LDK event handler error", e, context = TAG)

gradle/libs.versions.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
8181
ktor-client-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor" }
8282
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
8383
ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }
84-
#ldk-node-android = { module = "org.lightningdevkit:ldk-node-android", version = "0.6.2" } # upstream
85-
#ldk-node-android = { module = "org.lightningdevkit:ldk-node-android", version = "0.6.2-rc.4" } # local
86-
ldk-node-android = { module = "com.github.synonymdev:ldk-node", version = "v0.6.2-rc.4" } # fork
84+
#ldk-node-android = { module = "org.lightningdevkit:ldk-node-android", version = "0.7.0" } # upstream
85+
ldk-node-android = { module = "org.lightningdevkit:ldk-node-android", version = "v0.7.0" } # local
86+
#ldk-node-android = { module = "com.github.synonymdev:ldk-node", version = "v0.7.0" } # fork
8787
lifecycle-process = { group = "androidx.lifecycle", name = "lifecycle-process", version.ref = "lifecycle" }
8888
lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "lifecycle" }
8989
lifecycle-runtime-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycle" }

0 commit comments

Comments
 (0)