diff --git a/src/commonMain/kotlin/fr/acinq/lightning/Features.kt b/src/commonMain/kotlin/fr/acinq/lightning/Features.kt index a819b9ecb..86c8235e4 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/Features.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/Features.kt @@ -109,7 +109,7 @@ sealed class Feature { object RouteBlinding : Feature() { override val rfcName get() = "option_route_blinding" override val mandatory get() = 24 - override val scopes: Set get() = setOf(FeatureScope.Init, FeatureScope.Node, FeatureScope.Invoice) + override val scopes: Set get() = setOf(FeatureScope.Init, FeatureScope.Node) } @Serializable @@ -319,6 +319,7 @@ data class Features(val activated: Map, val unknown: Se Feature.BasicMultiPartPayment, Feature.Wumbo, Feature.AnchorOutputs, + Feature.RouteBlinding, Feature.ShutdownAnySegwit, Feature.DualFunding, Feature.ChannelType, diff --git a/src/commonMain/kotlin/fr/acinq/lightning/NodeParams.kt b/src/commonMain/kotlin/fr/acinq/lightning/NodeParams.kt index 9dc66f2e3..9ce43b8dd 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/NodeParams.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/NodeParams.kt @@ -168,6 +168,7 @@ data class NodeParams( require(features.hasFeature(Feature.PaymentSecret, FeatureSupport.Mandatory)) { "${Feature.PaymentSecret.rfcName} should be mandatory" } 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" } @@ -189,6 +190,7 @@ data class NodeParams( Feature.Wumbo to FeatureSupport.Optional, Feature.StaticRemoteKey to FeatureSupport.Mandatory, Feature.AnchorOutputs to FeatureSupport.Optional, // can't set Mandatory because peers prefers AnchorOutputsZeroFeeHtlcTx + Feature.RouteBlinding to FeatureSupport.Optional, Feature.DualFunding to FeatureSupport.Mandatory, Feature.ShutdownAnySegwit to FeatureSupport.Mandatory, Feature.ChannelType to FeatureSupport.Mandatory, diff --git a/src/commonMain/kotlin/fr/acinq/lightning/payment/Bolt12Invoice.kt b/src/commonMain/kotlin/fr/acinq/lightning/payment/Bolt12Invoice.kt index fb141e5c1..9b890906c 100644 --- a/src/commonMain/kotlin/fr/acinq/lightning/payment/Bolt12Invoice.kt +++ b/src/commonMain/kotlin/fr/acinq/lightning/payment/Bolt12Invoice.kt @@ -41,11 +41,7 @@ data class Bolt12Invoice(val records: TlvStream) : PaymentRequest() val createdAtSeconds: Long = records.get()!!.timestampSeconds val relativeExpirySeconds: Long = records.get()?.seconds ?: DEFAULT_EXPIRY_SECONDS - // We add invoice features that are implicitly required for Bolt 12 (the spec doesn't allow explicitly setting them). - override val features: Features = - (records.get()?.features?.invoiceFeatures() ?: Features.empty).let { - it.copy(activated = it.activated + (Feature.VariableLengthOnion to FeatureSupport.Mandatory) + (Feature.RouteBlinding to FeatureSupport.Mandatory)) - } + override val features: Features = records.get()?.features?.invoiceFeatures() ?: Features.empty val blindedPaths: List = records.get()!!.paths.zip(records.get()!!.paymentInfos).map { PaymentBlindedContactInfo(it.first, it.second) } val fallbacks: List? = records.get()?.addresses diff --git a/src/commonTest/kotlin/fr/acinq/lightning/FeaturesTestsCommon.kt b/src/commonTest/kotlin/fr/acinq/lightning/FeaturesTestsCommon.kt index 34201442a..37c8ac408 100644 --- a/src/commonTest/kotlin/fr/acinq/lightning/FeaturesTestsCommon.kt +++ b/src/commonTest/kotlin/fr/acinq/lightning/FeaturesTestsCommon.kt @@ -237,17 +237,17 @@ class FeaturesTestsCommon : LightningTestSuite() { PaymentSecret to FeatureSupport.Optional, BasicMultiPartPayment to FeatureSupport.Optional ), - Hex.decode("09004200") to Features( + Hex.decode("08404200") to Features( mapOf( VariableLengthOnion to FeatureSupport.Optional, PaymentSecret to FeatureSupport.Mandatory, ShutdownAnySegwit to FeatureSupport.Optional ), - setOf(UnknownFeature(24)) + setOf(UnknownFeature(22)) ), - Hex.decode("52000000") to Features( + Hex.decode("50800000") to Features( mapOf(DualFunding to FeatureSupport.Mandatory), - setOf(UnknownFeature(25), UnknownFeature(30)) + setOf(UnknownFeature(23), UnknownFeature(30)) ) ) diff --git a/src/commonTest/kotlin/fr/acinq/lightning/payment/Bolt12InvoiceTestsCommon.kt b/src/commonTest/kotlin/fr/acinq/lightning/payment/Bolt12InvoiceTestsCommon.kt index 7d97d4e1a..38874cbc5 100644 --- a/src/commonTest/kotlin/fr/acinq/lightning/payment/Bolt12InvoiceTestsCommon.kt +++ b/src/commonTest/kotlin/fr/acinq/lightning/payment/Bolt12InvoiceTestsCommon.kt @@ -133,7 +133,6 @@ class Bolt12InvoiceTestsCommon : LightningTestSuite() { listOf(createPaymentBlindedRoute(nodeKey.publicKey())) ) assertEquals(invoice.records.unknown, setOf(GenericTlv(87, ByteVector.fromHex("0404")))) - println(invoice.validateFor(requestWithUnknownTlv)) assertTrue(invoice.validateFor(requestWithUnknownTlv).isRight) assertEquals(Bolt12Invoice.fromString(invoice.toString()).get().toString(), invoice.toString()) } @@ -337,7 +336,7 @@ class Bolt12InvoiceTestsCommon : LightningTestSuite() { val chain = Block.TestnetGenesisBlock.hash val amount = 123456.msat val description = "invoice with many fields" - val features = Features(Feature.VariableLengthOnion to FeatureSupport.Mandatory, Feature.RouteBlinding to FeatureSupport.Mandatory) + val features = Features.empty val issuer = "alice" val nodeKey = PrivateKey.fromHex("998cf8ecab46f949bb960813b79d3317cabf4193452a211795cd8af1b9a25d90") val path = createPaymentBlindedRoute( diff --git a/src/commonTest/kotlin/fr/acinq/lightning/payment/OutgoingPaymentHandlerTestsCommon.kt b/src/commonTest/kotlin/fr/acinq/lightning/payment/OutgoingPaymentHandlerTestsCommon.kt index 15cf97a5a..33250c457 100644 --- a/src/commonTest/kotlin/fr/acinq/lightning/payment/OutgoingPaymentHandlerTestsCommon.kt +++ b/src/commonTest/kotlin/fr/acinq/lightning/payment/OutgoingPaymentHandlerTestsCommon.kt @@ -51,7 +51,8 @@ class OutgoingPaymentHandlerTestsCommon : LightningTestSuite() { Feature.VariableLengthOnion to FeatureSupport.Mandatory, Feature.PaymentSecret to FeatureSupport.Mandatory, Feature.BasicMultiPartPayment to FeatureSupport.Optional, - Feature.DualFunding to FeatureSupport.Mandatory + Feature.DualFunding to FeatureSupport.Mandatory, + Feature.RouteBlinding to FeatureSupport.Optional, ) // The following invoice requires payment_metadata. val invoice1 = diff --git a/src/commonTest/kotlin/fr/acinq/lightning/tests/TestConstants.kt b/src/commonTest/kotlin/fr/acinq/lightning/tests/TestConstants.kt index e7eec6023..5263c8ba4 100644 --- a/src/commonTest/kotlin/fr/acinq/lightning/tests/TestConstants.kt +++ b/src/commonTest/kotlin/fr/acinq/lightning/tests/TestConstants.kt @@ -60,6 +60,7 @@ object TestConstants { Feature.Wumbo to FeatureSupport.Optional, Feature.StaticRemoteKey to FeatureSupport.Mandatory, Feature.AnchorOutputs to FeatureSupport.Mandatory, + Feature.RouteBlinding to FeatureSupport.Optional, Feature.DualFunding to FeatureSupport.Mandatory, Feature.ChannelType to FeatureSupport.Mandatory, Feature.PaymentMetadata to FeatureSupport.Optional,