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

Enable route blinding #646

Merged
merged 3 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion src/commonMain/kotlin/fr/acinq/lightning/Features.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<FeatureScope> get() = setOf(FeatureScope.Init, FeatureScope.Node, FeatureScope.Invoice)
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init, FeatureScope.Node)
}

@Serializable
Expand Down Expand Up @@ -319,6 +319,7 @@ data class Features(val activated: Map<Feature, FeatureSupport>, val unknown: Se
Feature.BasicMultiPartPayment,
Feature.Wumbo,
Feature.AnchorOutputs,
Feature.RouteBlinding,
Feature.ShutdownAnySegwit,
Feature.DualFunding,
Feature.ChannelType,
Expand Down
1 change: 1 addition & 0 deletions src/commonMain/kotlin/fr/acinq/lightning/NodeParams.kt
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,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,
t-bast marked this conversation as resolved.
Show resolved Hide resolved
Feature.DualFunding to FeatureSupport.Mandatory,
Feature.ShutdownAnySegwit to FeatureSupport.Mandatory,
Feature.ChannelType to FeatureSupport.Mandatory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ data class Bolt12Invoice(val records: TlvStream<InvoiceTlv>) : PaymentRequest()
val createdAtSeconds: Long = records.get<InvoiceCreatedAt>()!!.timestampSeconds
val relativeExpirySeconds: Long = records.get<InvoiceRelativeExpiry>()?.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<InvoiceFeatures>()?.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<InvoiceFeatures>()?.features?.invoiceFeatures() ?: Features.empty

val blindedPaths: List<PaymentBlindedContactInfo> = records.get<InvoicePaths>()!!.paths.zip(records.get<InvoiceBlindedPay>()!!.paymentInfos).map { PaymentBlindedContactInfo(it.first, it.second) }
val fallbacks: List<FallbackAddress>? = records.get<InvoiceFallbacks>()?.addresses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import fr.acinq.lightning.Features.Companion.validateFeatureGraph
import fr.acinq.lightning.tests.utils.LightningTestSuite
import fr.acinq.lightning.utils.BitField
import fr.acinq.secp256k1.Hex
import org.kodein.memory.text.toHex
t-bast marked this conversation as resolved.
Show resolved Hide resolved
import kotlin.test.*

class FeaturesTestsCommon : LightningTestSuite() {
Expand Down Expand Up @@ -237,17 +238,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))
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down Expand Up @@ -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(
Expand Down
Loading