Skip to content

Commit

Permalink
Add features bits for swap-in and notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
t-bast committed Apr 1, 2021
1 parent f006f3d commit f793daf
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ object TestConstants {
Feature.StaticRemoteKey to FeatureSupport.Mandatory,
Feature.AnchorOutputs to FeatureSupport.Mandatory,
Feature.TrampolinePayment to FeatureSupport.Optional,
Feature.PayToOpen to FeatureSupport.Optional
Feature.PayToOpen to FeatureSupport.Optional,
Feature.TrustedSwapIn to FeatureSupport.Optional,
Feature.WakeUpNotification to FeatureSupport.Optional,
),
dustLimit = 1_100.sat,
maxRemoteDustLimit = 1_500.sat,
Expand Down Expand Up @@ -120,7 +122,9 @@ object TestConstants {
Feature.StaticRemoteKey to FeatureSupport.Mandatory,
Feature.AnchorOutputs to FeatureSupport.Mandatory,
Feature.TrampolinePayment to FeatureSupport.Optional,
Feature.PayToOpen to FeatureSupport.Optional
Feature.PayToOpen to FeatureSupport.Optional,
Feature.TrustedSwapIn to FeatureSupport.Optional,
Feature.WakeUpNotification to FeatureSupport.Optional,
),
dustLimit = 1_000.sat,
maxRemoteDustLimit = 1_500.sat,
Expand Down
24 changes: 18 additions & 6 deletions src/commonMain/kotlin/fr/acinq/eclair/Features.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,30 @@ 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 has not been standardised, hence the high feature bit to avoid conflicts.
@Serializable
object PayToOpen : Feature() {
override val rfcName get() = "pay_to_open"
override val mandatory get() = 60
override val mandatory get() = 80
}

@Serializable
object TrustedSwapIn : Feature() {
override val rfcName get() = "trusted_swap_in"
override val mandatory get() = 82
}

@Serializable
object WakeUpNotification : Feature() {
override val rfcName get() = "wake_up_notification"
override val mandatory get() = 84
}
}

Expand Down Expand Up @@ -161,7 +171,9 @@ data class Features(val activated: Map<Feature, FeatureSupport>, val unknown: Se
Feature.Wumbo,
Feature.AnchorOutputs,
Feature.TrampolinePayment,
Feature.PayToOpen
Feature.PayToOpen,
Feature.TrustedSwapIn,
Feature.WakeUpNotification,
)

operator fun invoke(bytes: ByteVector): Features = invoke(bytes.toByteArray())
Expand Down
4 changes: 3 additions & 1 deletion src/jvmTest/kotlin/fr/acinq/eclair/Node.kt
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ object Node {
Feature.StaticRemoteKey to FeatureSupport.Optional,
Feature.AnchorOutputs to FeatureSupport.Optional,
Feature.TrampolinePayment to FeatureSupport.Optional,
Feature.PayToOpen to FeatureSupport.Optional
Feature.PayToOpen to FeatureSupport.Optional,
Feature.TrustedSwapIn to FeatureSupport.Optional,
Feature.WakeUpNotification to FeatureSupport.Optional,
),
dustLimit = 546.sat,
maxRemoteDustLimit = 600.sat,
Expand Down

0 comments on commit f793daf

Please sign in to comment.