Skip to content

Commit

Permalink
Remove deprecated serialization format and fields
Browse files Browse the repository at this point in the history
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
  • Loading branch information
t-bast committed Dec 5, 2024
1 parent 7cfdb96 commit 9e57421
Show file tree
Hide file tree
Showing 137 changed files with 2,489 additions and 14,250 deletions.
58 changes: 0 additions & 58 deletions modules/core/src/commonMain/kotlin/fr/acinq/lightning/Features.kt
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,6 @@ sealed class Feature {

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

// We historically used the following feature bit in our invoices.
// However, the spec assigned the same feature bit to `option_scid_alias` (https://github.com/lightning/bolts/pull/910).
// 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.
// We cannot rename that object otherwise we will not be able to read old serialized data.
@Serializable
object TrampolinePayment : Feature() {
override val rfcName get() = "trampoline_payment_backwards_compat"
override val mandatory get() = 50
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init, FeatureScope.Node, FeatureScope.Invoice)
}

/** This feature bit should be activated when a node accepts having their channel reserve set to 0. */
@Serializable
object ZeroReserveChannels : Feature() {
Expand All @@ -168,14 +157,6 @@ sealed class Feature {
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init, FeatureScope.Node)
}

/** DEPRECATED: this feature bit should not be used, it is only kept for serialization backwards-compatibility. */
@Serializable
object ZeroConfChannels : Feature() {
override val rfcName get() = "zero_conf_channels"
override val mandatory get() = 130
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init, FeatureScope.Node)
}

/** This feature bit should be activated when a mobile node supports waking up via push notifications. */
@Serializable
object WakeUpNotificationClient : Feature() {
Expand All @@ -192,38 +173,6 @@ sealed class Feature {
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init, FeatureScope.Node)
}

/** DEPRECATED: this feature bit was used for the legacy pay-to-open protocol. */
@Serializable
object PayToOpenClient : Feature() {
override val rfcName get() = "pay_to_open_client"
override val mandatory get() = 136
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init)
}

/** DEPRECATED: this feature bit was used for the legacy pay-to-open protocol. */
@Serializable
object PayToOpenProvider : Feature() {
override val rfcName get() = "pay_to_open_provider"
override val mandatory get() = 138
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init, FeatureScope.Node)
}

/** DEPRECATED: this feature bit should not be used, it is only kept for serialization backwards-compatibility. */
@Serializable
object TrustedSwapInClient : Feature() {
override val rfcName get() = "trusted_swap_in_client"
override val mandatory get() = 140
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init)
}

/** DEPRECATED: this feature bit should not be used, it is only kept for serialization backwards-compatibility. */
@Serializable
object TrustedSwapInProvider : Feature() {
override val rfcName get() = "trusted_swap_in_provider"
override val mandatory get() = 142
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init, FeatureScope.Node)
}

/** This feature bit should be activated when a node wants to send channel backups to their peers. */
@Serializable
object ChannelBackupClient : Feature() {
Expand Down Expand Up @@ -339,16 +288,10 @@ data class Features(val activated: Map<Feature, FeatureSupport>, val unknown: Se
Feature.Quiescence,
Feature.ChannelType,
Feature.PaymentMetadata,
Feature.TrampolinePayment,
Feature.ExperimentalTrampolinePayment,
Feature.ZeroReserveChannels,
Feature.ZeroConfChannels,
Feature.WakeUpNotificationClient,
Feature.WakeUpNotificationProvider,
Feature.PayToOpenClient,
Feature.PayToOpenProvider,
Feature.TrustedSwapInClient,
Feature.TrustedSwapInProvider,
Feature.ChannelBackupClient,
Feature.ChannelBackupProvider,
Feature.ExperimentalSplice,
Expand Down Expand Up @@ -384,7 +327,6 @@ data class Features(val activated: Map<Feature, FeatureSupport>, val unknown: Se
Feature.PaymentSecret to listOf(Feature.VariableLengthOnion),
Feature.BasicMultiPartPayment to listOf(Feature.PaymentSecret),
Feature.AnchorOutputs to listOf(Feature.StaticRemoteKey),
Feature.TrampolinePayment to listOf(Feature.PaymentSecret),
Feature.ExperimentalTrampolinePayment to listOf(Feature.PaymentSecret),
Feature.OnTheFlyFunding to listOf(Feature.ExperimentalSplice),
Feature.FundingFeeCredit to listOf(Feature.OnTheFlyFunding)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,6 @@ data class NodeParams(
require(features.hasFeature(Feature.ChannelType, FeatureSupport.Mandatory)) { "${Feature.ChannelType.rfcName} should be mandatory" }
require(features.hasFeature(Feature.DualFunding, FeatureSupport.Mandatory)) { "${Feature.DualFunding.rfcName} should be mandatory" }
require(features.hasFeature(Feature.RouteBlinding)) { "${Feature.RouteBlinding.rfcName} should be supported" }
require(!features.hasFeature(Feature.ZeroConfChannels)) { "${Feature.ZeroConfChannels.rfcName} has been deprecated: use the zeroConfPeers whitelist instead" }
require(!features.hasFeature(Feature.TrustedSwapInClient)) { "${Feature.TrustedSwapInClient.rfcName} has been deprecated" }
require(!features.hasFeature(Feature.TrustedSwapInProvider)) { "${Feature.TrustedSwapInProvider.rfcName} has been deprecated" }
require(!features.hasFeature(Feature.PayToOpenClient)) { "${Feature.PayToOpenClient.rfcName} has been deprecated" }
require(!features.hasFeature(Feature.PayToOpenProvider)) { "${Feature.PayToOpenProvider.rfcName} has been deprecated" }
Features.validateFeatureGraph(features)
// Verify expiry parameters are consistent with each other.
require((fulfillSafetyBeforeTimeoutBlocks * 2) < minFinalCltvExpiryDelta) { "min_final_expiry_delta must be at least twice as long as fulfill_safety_before_timeout_blocks" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,6 @@ sealed class ChannelState {
is Offline -> state.run { handleLocalError(cmd, t) }
is Syncing -> state.run { handleLocalError(cmd, t) }
is WaitForRemotePublishFutureCommitment -> Pair(state, emptyList())
is LegacyWaitForFundingConfirmed -> forceClose(state)
is LegacyWaitForFundingLocked -> forceClose(state)
}
}

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ data class Syncing(val state: PersistedChannelState, val channelReestablishSent:
is ChannelCommand.MessageReceived -> when (cmd.message) {
is ChannelReestablish -> {
val (nextState, actions) = when (state) {
is LegacyWaitForFundingConfirmed -> {
Pair(state, listOf())
}
is WaitForFundingSigned -> {
when (cmd.message.nextFundingTxId) {
// We retransmit our commit_sig, and will send our tx_signatures once we've received their commit_sig.
Expand Down Expand Up @@ -107,13 +104,6 @@ data class Syncing(val state: PersistedChannelState, val channelReestablishSent:

Pair(state, actions)
}
is LegacyWaitForFundingLocked -> {
logger.debug { "re-sending channel_ready" }
val nextPerCommitmentPoint = channelKeys().commitmentPoint(1)
val channelReady = ChannelReady(state.commitments.channelId, nextPerCommitmentPoint)
val actions = listOf(ChannelAction.Message.Send(channelReady))
Pair(state, actions)
}
is Normal -> {
when (val syncResult = handleSync(state.commitments, cmd.message)) {
is SyncResult.Failure -> handleSyncFailure(state.commitments, cmd.message, syncResult)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ interface KeyManager {
* Keys used for the node. They are used to generate the node id, to secure communication with other peers, and
* to sign network-wide public announcements.
*/
data class NodeKeys(
/** The node key that the same seed would have produced on the legacy eclair-based Phoenix implementation on Android. Useful to automate the migration. */
val legacyNodeKey: DeterministicWallet.ExtendedPrivateKey,
val nodeKey: DeterministicWallet.ExtendedPrivateKey,
)
data class NodeKeys(val nodeKey: DeterministicWallet.ExtendedPrivateKey)

/**
* Secrets and keys for a given channel.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ data class LocalKeyManager(val seed: ByteVector, val chain: Chain, val remoteSwa
private val master = DeterministicWallet.generate(seed)

override val nodeKeys: KeyManager.NodeKeys = KeyManager.NodeKeys(
legacyNodeKey = @Suppress("DEPRECATION") master.derivePrivateKey(eclairNodeKeyBasePath(chain)),
nodeKey = master.derivePrivateKey(nodeKeyBasePath(chain)),
)

Expand Down Expand Up @@ -153,13 +152,6 @@ data class LocalKeyManager(val seed: ByteVector, val chain: Chain, val remoteSwa
Chain.Mainnet -> KeyPath.empty / hardened(50) / hardened(1)
}

/** Path for node keys generated by eclair-core */
@Deprecated("used for backward-compat with eclair-core", replaceWith = ReplaceWith("nodeKeyBasePath(chain)"))
fun eclairNodeKeyBasePath(chain: Chain) = when (chain) {
Chain.Testnet4, Chain.Testnet3, Chain.Regtest, Chain.Signet -> KeyPath.empty / hardened(46) / hardened(0)
Chain.Mainnet -> KeyPath.empty / hardened(47) / hardened(0)
}

fun nodeKeyBasePath(chain: Chain) = when (chain) {
Chain.Testnet4, Chain.Testnet3, Chain.Regtest, Chain.Signet -> KeyPath.empty / hardened(48) / hardened(0)
Chain.Mainnet -> KeyPath.empty / hardened(50) / hardened(0)
Expand Down
Loading

0 comments on commit 9e57421

Please sign in to comment.