Skip to content

Commit 1a8b468

Browse files
committed
Remove deprecated serialization format and fields
The v4 serialization format was released in July 2023 with better support for backwards-compatibility: the v2 and v3 formats used kotlin's serialization, which prevents us from removing legacy classes and requires additional code whenever we change something in the channel state. Users who haven't migrated their data to the v4 format will not be able to deserialize their channel data: they will need to use a previous version of the app to read their old channel data, write it to the v4 format and then upgrade to the latest version. We also remove a bunch of fields/options that were deprecated a while ago: - legacy channel funding states - unused legacy features - legacy private key generation - legacy node events
1 parent e6f9236 commit 1a8b468

File tree

136 files changed

+2493
-14252
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+2493
-14252
lines changed

src/commonMain/kotlin/fr/acinq/lightning/Features.kt

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,6 @@ sealed class Feature {
149149

150150
// The following features have not been standardised, hence the high feature bits to avoid conflicts.
151151

152-
// We historically used the following feature bit in our invoices.
153-
// However, the spec assigned the same feature bit to `option_scid_alias` (https://github.com/lightning/bolts/pull/910).
154-
// We're moving this feature bit to 148, but we have to keep supporting it until enough wallet users have migrated, then we can remove it.
155-
// We cannot rename that object otherwise we will not be able to read old serialized data.
156-
@Serializable
157-
object TrampolinePayment : Feature() {
158-
override val rfcName get() = "trampoline_payment_backwards_compat"
159-
override val mandatory get() = 50
160-
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init, FeatureScope.Node, FeatureScope.Invoice)
161-
}
162-
163152
/** This feature bit should be activated when a node accepts having their channel reserve set to 0. */
164153
@Serializable
165154
object ZeroReserveChannels : Feature() {
@@ -168,14 +157,6 @@ sealed class Feature {
168157
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init, FeatureScope.Node)
169158
}
170159

171-
/** DEPRECATED: this feature bit should not be used, it is only kept for serialization backwards-compatibility. */
172-
@Serializable
173-
object ZeroConfChannels : Feature() {
174-
override val rfcName get() = "zero_conf_channels"
175-
override val mandatory get() = 130
176-
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init, FeatureScope.Node)
177-
}
178-
179160
/** This feature bit should be activated when a mobile node supports waking up via push notifications. */
180161
@Serializable
181162
object WakeUpNotificationClient : Feature() {
@@ -192,38 +173,6 @@ sealed class Feature {
192173
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init, FeatureScope.Node)
193174
}
194175

195-
/** DEPRECATED: this feature bit was used for the legacy pay-to-open protocol. */
196-
@Serializable
197-
object PayToOpenClient : Feature() {
198-
override val rfcName get() = "pay_to_open_client"
199-
override val mandatory get() = 136
200-
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init)
201-
}
202-
203-
/** DEPRECATED: this feature bit was used for the legacy pay-to-open protocol. */
204-
@Serializable
205-
object PayToOpenProvider : Feature() {
206-
override val rfcName get() = "pay_to_open_provider"
207-
override val mandatory get() = 138
208-
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init, FeatureScope.Node)
209-
}
210-
211-
/** DEPRECATED: this feature bit should not be used, it is only kept for serialization backwards-compatibility. */
212-
@Serializable
213-
object TrustedSwapInClient : Feature() {
214-
override val rfcName get() = "trusted_swap_in_client"
215-
override val mandatory get() = 140
216-
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init)
217-
}
218-
219-
/** DEPRECATED: this feature bit should not be used, it is only kept for serialization backwards-compatibility. */
220-
@Serializable
221-
object TrustedSwapInProvider : Feature() {
222-
override val rfcName get() = "trusted_swap_in_provider"
223-
override val mandatory get() = 142
224-
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init, FeatureScope.Node)
225-
}
226-
227176
/** This feature bit should be activated when a node wants to send channel backups to their peers. */
228177
@Serializable
229178
object ChannelBackupClient : Feature() {
@@ -339,16 +288,10 @@ data class Features(val activated: Map<Feature, FeatureSupport>, val unknown: Se
339288
Feature.Quiescence,
340289
Feature.ChannelType,
341290
Feature.PaymentMetadata,
342-
Feature.TrampolinePayment,
343291
Feature.ExperimentalTrampolinePayment,
344292
Feature.ZeroReserveChannels,
345-
Feature.ZeroConfChannels,
346293
Feature.WakeUpNotificationClient,
347294
Feature.WakeUpNotificationProvider,
348-
Feature.PayToOpenClient,
349-
Feature.PayToOpenProvider,
350-
Feature.TrustedSwapInClient,
351-
Feature.TrustedSwapInProvider,
352295
Feature.ChannelBackupClient,
353296
Feature.ChannelBackupProvider,
354297
Feature.ExperimentalSplice,
@@ -384,7 +327,6 @@ data class Features(val activated: Map<Feature, FeatureSupport>, val unknown: Se
384327
Feature.PaymentSecret to listOf(Feature.VariableLengthOnion),
385328
Feature.BasicMultiPartPayment to listOf(Feature.PaymentSecret),
386329
Feature.AnchorOutputs to listOf(Feature.StaticRemoteKey),
387-
Feature.TrampolinePayment to listOf(Feature.PaymentSecret),
388330
Feature.ExperimentalTrampolinePayment to listOf(Feature.PaymentSecret),
389331
Feature.OnTheFlyFunding to listOf(Feature.ExperimentalSplice),
390332
Feature.FundingFeeCredit to listOf(Feature.OnTheFlyFunding)

src/commonMain/kotlin/fr/acinq/lightning/NodeParams.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,6 @@ data class NodeParams(
173173
require(features.hasFeature(Feature.ChannelType, FeatureSupport.Mandatory)) { "${Feature.ChannelType.rfcName} should be mandatory" }
174174
require(features.hasFeature(Feature.DualFunding, FeatureSupport.Mandatory)) { "${Feature.DualFunding.rfcName} should be mandatory" }
175175
require(features.hasFeature(Feature.RouteBlinding)) { "${Feature.RouteBlinding.rfcName} should be supported" }
176-
require(!features.hasFeature(Feature.ZeroConfChannels)) { "${Feature.ZeroConfChannels.rfcName} has been deprecated: use the zeroConfPeers whitelist instead" }
177-
require(!features.hasFeature(Feature.TrustedSwapInClient)) { "${Feature.TrustedSwapInClient.rfcName} has been deprecated" }
178-
require(!features.hasFeature(Feature.TrustedSwapInProvider)) { "${Feature.TrustedSwapInProvider.rfcName} has been deprecated" }
179-
require(!features.hasFeature(Feature.PayToOpenClient)) { "${Feature.PayToOpenClient.rfcName} has been deprecated" }
180-
require(!features.hasFeature(Feature.PayToOpenProvider)) { "${Feature.PayToOpenProvider.rfcName} has been deprecated" }
181176
Features.validateFeatureGraph(features)
182177
}
183178

src/commonMain/kotlin/fr/acinq/lightning/channel/states/Channel.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,6 @@ sealed class ChannelState {
256256
is Offline -> state.run { handleLocalError(cmd, t) }
257257
is Syncing -> state.run { handleLocalError(cmd, t) }
258258
is WaitForRemotePublishFutureCommitment -> Pair(state, emptyList())
259-
is LegacyWaitForFundingConfirmed -> forceClose(state)
260-
is LegacyWaitForFundingLocked -> forceClose(state)
261259
}
262260
}
263261

src/commonMain/kotlin/fr/acinq/lightning/channel/states/LegacyWaitForFundingConfirmed.kt

Lines changed: 0 additions & 85 deletions
This file was deleted.

src/commonMain/kotlin/fr/acinq/lightning/channel/states/LegacyWaitForFundingLocked.kt

Lines changed: 0 additions & 79 deletions
This file was deleted.

src/commonMain/kotlin/fr/acinq/lightning/channel/states/Syncing.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ data class Syncing(val state: PersistedChannelState, val channelReestablishSent:
2323
is ChannelCommand.MessageReceived -> when (cmd.message) {
2424
is ChannelReestablish -> {
2525
val (nextState, actions) = when (state) {
26-
is LegacyWaitForFundingConfirmed -> {
27-
Pair(state, listOf())
28-
}
2926
is WaitForFundingSigned -> {
3027
when (cmd.message.nextFundingTxId) {
3128
// We retransmit our commit_sig, and will send our tx_signatures once we've received their commit_sig.
@@ -107,13 +104,6 @@ data class Syncing(val state: PersistedChannelState, val channelReestablishSent:
107104

108105
Pair(state, actions)
109106
}
110-
is LegacyWaitForFundingLocked -> {
111-
logger.debug { "re-sending channel_ready" }
112-
val nextPerCommitmentPoint = channelKeys().commitmentPoint(1)
113-
val channelReady = ChannelReady(state.commitments.channelId, nextPerCommitmentPoint)
114-
val actions = listOf(ChannelAction.Message.Send(channelReady))
115-
Pair(state, actions)
116-
}
117107
is Normal -> {
118108
when (val syncResult = handleSync(state.commitments, cmd.message)) {
119109
is SyncResult.Failure -> handleSyncFailure(state.commitments, cmd.message, syncResult)

src/commonMain/kotlin/fr/acinq/lightning/crypto/KeyManager.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ interface KeyManager {
4141
* Keys used for the node. They are used to generate the node id, to secure communication with other peers, and
4242
* to sign network-wide public announcements.
4343
*/
44-
data class NodeKeys(
45-
/** The node key that the same seed would have produced on the legacy eclair-based Phoenix implementation on Android. Useful to automate the migration. */
46-
val legacyNodeKey: DeterministicWallet.ExtendedPrivateKey,
47-
val nodeKey: DeterministicWallet.ExtendedPrivateKey,
48-
)
44+
data class NodeKeys(val nodeKey: DeterministicWallet.ExtendedPrivateKey)
4945

5046
/**
5147
* Secrets and keys for a given channel.

src/commonMain/kotlin/fr/acinq/lightning/crypto/LocalKeyManager.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ data class LocalKeyManager(val seed: ByteVector, val chain: Chain, val remoteSwa
3838
private val master = DeterministicWallet.generate(seed)
3939

4040
override val nodeKeys: KeyManager.NodeKeys = KeyManager.NodeKeys(
41-
legacyNodeKey = @Suppress("DEPRECATION") derivePrivateKey(master, eclairNodeKeyBasePath(chain)),
4241
nodeKey = derivePrivateKey(master, nodeKeyBasePath(chain)),
4342
)
4443

@@ -154,13 +153,6 @@ data class LocalKeyManager(val seed: ByteVector, val chain: Chain, val remoteSwa
154153
Chain.Mainnet -> KeyPath.empty / hardened(50) / hardened(1)
155154
}
156155

157-
/** Path for node keys generated by eclair-core */
158-
@Deprecated("used for backward-compat with eclair-core", replaceWith = ReplaceWith("nodeKeyBasePath(chain)"))
159-
fun eclairNodeKeyBasePath(chain: Chain) = when (chain) {
160-
Chain.Regtest, Chain.Testnet, Chain.Signet -> KeyPath.empty / hardened(46) / hardened(0)
161-
Chain.Mainnet -> KeyPath.empty / hardened(47) / hardened(0)
162-
}
163-
164156
fun nodeKeyBasePath(chain: Chain) = when (chain) {
165157
Chain.Regtest, Chain.Testnet, Chain.Signet -> KeyPath.empty / hardened(48) / hardened(0)
166158
Chain.Mainnet -> KeyPath.empty / hardened(50) / hardened(0)

0 commit comments

Comments
 (0)