Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature bits for experimental wallet features #237

Merged
merged 1 commit into from
Jul 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ object TestConstants {
Feature.Wumbo to FeatureSupport.Optional,
Feature.StaticRemoteKey to FeatureSupport.Mandatory,
Feature.AnchorOutputs to FeatureSupport.Mandatory,
Feature.TrampolinePayment to FeatureSupport.Optional
Feature.TrampolinePayment to FeatureSupport.Optional,
Feature.ZeroReserveChannels to FeatureSupport.Optional,
Feature.ZeroConfChannels to FeatureSupport.Optional,
Feature.WakeUpNotificationClient to FeatureSupport.Optional,
Feature.PayToOpenClient to FeatureSupport.Optional,
Feature.TrustedSwapInClient to FeatureSupport.Optional,
Feature.ChannelBackupClient to FeatureSupport.Optional,
),
dustLimit = 1_100.sat,
maxRemoteDustLimit = 1_500.sat,
Expand Down Expand Up @@ -123,7 +129,13 @@ object TestConstants {
Feature.Wumbo to FeatureSupport.Optional,
Feature.StaticRemoteKey to FeatureSupport.Mandatory,
Feature.AnchorOutputs to FeatureSupport.Mandatory,
Feature.TrampolinePayment to FeatureSupport.Optional
Feature.TrampolinePayment to FeatureSupport.Optional,
Feature.ZeroReserveChannels to FeatureSupport.Optional,
Feature.ZeroConfChannels to FeatureSupport.Optional,
Feature.WakeUpNotificationClient to FeatureSupport.Optional,
Feature.PayToOpenClient to FeatureSupport.Optional,
Feature.TrustedSwapInClient to FeatureSupport.Optional,
Feature.ChannelBackupClient to FeatureSupport.Optional,
),
dustLimit = 1_000.sat,
maxRemoteDustLimit = 1_500.sat,
Expand Down
87 changes: 83 additions & 4 deletions src/commonMain/kotlin/fr/acinq/lightning/Features.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,83 @@ sealed class Feature {
override val mandatory get() = 20
}

// TODO: @t-bast: update feature bits once spec-ed (currently reserved here: https://github.com/lightningnetwork/lightning-rfc/issues/605)
// We're not advertising these bits yet in our announcements, clients have to assume support.
// This is why we haven't added them yet to `areSupported`.
// The following features have not been standardised, hence the high feature bits to avoid conflicts.

@Serializable
object TrampolinePayment : Feature() {
override val rfcName get() = "trampoline_payment"
override val mandatory get() = 50
}

/** This feature bit should be activated when a node accepts having their channel reserve set to 0. */
@Serializable
object ZeroReserveChannels : Feature() {
override val rfcName get() = "zero_reserve_channels"
override val mandatory get() = 128
}

/** This feature bit should be activated when a node accepts unconfirmed channels (will set min_depth to 0 in accept_channel). */
@Serializable
object ZeroConfChannels : Feature() {
override val rfcName get() = "zero_conf_channels"
override val mandatory get() = 130
}

/** This feature bit should be activated when a mobile node supports waking up via push notifications. */
@Serializable
object WakeUpNotificationClient : Feature() {
override val rfcName get() = "wake_up_notification_client"
override val mandatory get() = 132
}

/** This feature bit should be activated when a node supports waking up their peers via push notifications. */
@Serializable
object WakeUpNotificationProvider : Feature() {
override val rfcName get() = "wake_up_notification_provider"
override val mandatory get() = 134
}

/** This feature bit should be activated when a node accepts on-the-fly channel creation. */
@Serializable
object PayToOpenClient : Feature() {
override val rfcName get() = "pay_to_open_client"
override val mandatory get() = 136
}

/** This feature bit should be activated when a node supports opening channels on-the-fly when liquidity is missing to receive a payment. */
@Serializable
object PayToOpenProvider : Feature() {
override val rfcName get() = "pay_to_open_provider"
override val mandatory get() = 138
}

/** This feature bit should be activated when a node accepts channel creation via trusted swaps-in. */
@Serializable
object TrustedSwapInClient : Feature() {
override val rfcName get() = "trusted_swap_in_client"
override val mandatory get() = 140
}

/** This feature bit should be activated when a node supports opening channels in exchange for on-chain funds (swap-in). */
@Serializable
object TrustedSwapInProvider : Feature() {
override val rfcName get() = "trusted_swap_in_provider"
override val mandatory get() = 142
}

/** This feature bit should be activated when a node wants to send channel backups to their peers. */
@Serializable
object ChannelBackupClient : Feature() {
override val rfcName get() = "channel_backup_client"
override val mandatory get() = 144
}

/** This feature bit should be activated when a node stores channel backups for their peers. */
@Serializable
object ChannelBackupProvider : Feature() {
override val rfcName get() = "channel_backup_provider"
override val mandatory get() = 146
}
}

@Serializable
Expand Down Expand Up @@ -153,7 +222,17 @@ data class Features(val activated: Map<Feature, FeatureSupport>, val unknown: Se
Feature.BasicMultiPartPayment,
Feature.Wumbo,
Feature.AnchorOutputs,
Feature.TrampolinePayment
Feature.TrampolinePayment,
Feature.ZeroReserveChannels,
Feature.ZeroConfChannels,
Feature.WakeUpNotificationClient,
Feature.WakeUpNotificationProvider,
Feature.PayToOpenClient,
Feature.PayToOpenProvider,
Feature.TrustedSwapInClient,
Feature.TrustedSwapInProvider,
Feature.ChannelBackupClient,
Feature.ChannelBackupProvider,
)

operator fun invoke(bytes: ByteVector): Features = invoke(bytes.toByteArray())
Expand Down
6 changes: 6 additions & 0 deletions src/jvmTest/kotlin/fr/acinq/lightning/Node.kt
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ object Node {
Feature.StaticRemoteKey to FeatureSupport.Optional,
Feature.AnchorOutputs to FeatureSupport.Optional,
Feature.TrampolinePayment to FeatureSupport.Optional,
Feature.ZeroReserveChannels to FeatureSupport.Optional,
Feature.ZeroConfChannels to FeatureSupport.Optional,
Feature.WakeUpNotificationClient to FeatureSupport.Optional,
Feature.PayToOpenClient to FeatureSupport.Optional,
Feature.TrustedSwapInClient to FeatureSupport.Optional,
Feature.ChannelBackupClient to FeatureSupport.Optional,
),
dustLimit = 546.sat,
maxRemoteDustLimit = 600.sat,
Expand Down