Skip to content

Commit

Permalink
Add feature bits for custom wallet features
Browse files Browse the repository at this point in the history
Wallets should explicitly advertise support for pay-to-open, trusted swaps
and wake-up notifications  in their `init` message, to allow the LSPs they
connect to to know what they're allowed to do.

This lets LSPs know for example whether they can open a channel on-the-fly
when liquidity is missing to receive a payment.
  • Loading branch information
t-bast committed Jul 8, 2021
1 parent 5fb3ff0 commit 179346b
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ 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.ZeroConfChannels to FeatureSupport.Optional,
Feature.WakeUpNotificationClient to FeatureSupport.Optional,
Feature.PayToOpenClient to FeatureSupport.Optional,
Feature.TrustedSwapInClient to FeatureSupport.Optional,
),
dustLimit = 1_100.sat,
maxRemoteDustLimit = 1_500.sat,
Expand Down Expand Up @@ -123,7 +127,11 @@ 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.ZeroConfChannels to FeatureSupport.Optional,
Feature.WakeUpNotificationClient to FeatureSupport.Optional,
Feature.PayToOpenClient to FeatureSupport.Optional,
Feature.TrustedSwapInClient to FeatureSupport.Optional,
),
dustLimit = 1_000.sat,
maxRemoteDustLimit = 1_500.sat,
Expand Down
56 changes: 52 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,55 @@ 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
}

@Serializable
object ZeroConfChannels : Feature() {
override val rfcName get() = "zero_conf_channels"
override val mandatory get() = 130
}

@Serializable
object WakeUpNotificationClient : Feature() {
override val rfcName get() = "wake_up_notification_client"
override val mandatory get() = 132
}

@Serializable
object WakeUpNotificationProvider : Feature() {
override val rfcName get() = "wake_up_notification_provider"
override val mandatory get() = 134
}

@Serializable
object PayToOpenClient : Feature() {
override val rfcName get() = "pay_to_open_client"
override val mandatory get() = 136
}

@Serializable
object PayToOpenProvider : Feature() {
override val rfcName get() = "pay_to_open_provider"
override val mandatory get() = 138
}

@Serializable
object TrustedSwapInClient : Feature() {
override val rfcName get() = "trusted_swap_in_client"
override val mandatory get() = 140
}

@Serializable
object TrustedSwapInProvider : Feature() {
override val rfcName get() = "trusted_swap_in_provider"
override val mandatory get() = 142
}
}

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

operator fun invoke(bytes: ByteVector): Features = invoke(bytes.toByteArray())
Expand Down
4 changes: 4 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,10 @@ object Node {
Feature.StaticRemoteKey to FeatureSupport.Optional,
Feature.AnchorOutputs to FeatureSupport.Optional,
Feature.TrampolinePayment to FeatureSupport.Optional,
Feature.ZeroConfChannels to FeatureSupport.Optional,
Feature.WakeUpNotificationClient to FeatureSupport.Optional,
Feature.PayToOpenClient to FeatureSupport.Optional,
Feature.TrustedSwapInClient to FeatureSupport.Optional,
),
dustLimit = 546.sat,
maxRemoteDustLimit = 600.sat,
Expand Down

0 comments on commit 179346b

Please sign in to comment.