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 Apr 21, 2021
1 parent c90cc49 commit cc4b360
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ 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.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 @@ -116,7 +119,10 @@ 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.PayToOpen to FeatureSupport.Optional,
Feature.TrustedSwapIn to FeatureSupport.Optional,
Feature.WakeUpNotification to FeatureSupport.Optional,
),
dustLimit = 1_000.sat,
maxRemoteDustLimit = 1_500.sat,
Expand Down
28 changes: 24 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,31 @@ 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 PayToOpen : Feature() {
override val rfcName get() = "pay_to_open"
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
}
}

@Serializable
Expand Down Expand Up @@ -153,7 +170,10 @@ data class Features(val activated: Map<Feature, FeatureSupport>, val unknown: Se
Feature.BasicMultiPartPayment,
Feature.Wumbo,
Feature.AnchorOutputs,
Feature.TrampolinePayment
Feature.TrampolinePayment,
Feature.PayToOpen,
Feature.TrustedSwapIn,
Feature.WakeUpNotification,
)

operator fun invoke(bytes: ByteVector): Features = invoke(bytes.toByteArray())
Expand Down
3 changes: 3 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,9 @@ object Node {
Feature.StaticRemoteKey to FeatureSupport.Optional,
Feature.AnchorOutputs to FeatureSupport.Optional,
Feature.TrampolinePayment 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 cc4b360

Please sign in to comment.