1
0
Fork 0
mirror of https://github.com/ACINQ/eclair.git synced 2025-03-13 19:37:35 +01:00

Stop masking feature bits (#1814)

Remove a legacy work-around for very old eclair-mobile users.
This commit is contained in:
Bastien Teinturier 2021-05-19 15:32:18 +02:00 committed by GitHub
parent fbb996eb1a
commit fdb7a86621
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 1 additions and 43 deletions

View file

@ -77,23 +77,6 @@ case class Features(activated: Set[ActivatedFeature], unknown: Set[UnknownFeatur
buf.reverse.bytes
}
/**
* Eclair-mobile thinks feature bit 15 (payment_secret) is gossip_queries_ex which creates issues, so we mask
* off basic_mpp and payment_secret. As long as they're provided in the invoice it's not an issue.
* We use a long enough mask to account for future features.
* TODO: remove that once eclair-mobile is patched.
*/
def maskFeaturesForEclairMobile(): Features = {
Features(
activated = activated.filter {
case ActivatedFeature(PaymentSecret, _) => false
case ActivatedFeature(BasicMultiPartPayment, _) => false
case _ => true
},
unknown = unknown
)
}
}
object Features {

View file

@ -101,7 +101,7 @@ class PeerConnection(nodeParams: NodeParams, switchboard: ActorRef, router: Acto
Metrics.PeerConnectionsConnecting.withTag(Tags.ConnectionState, Tags.ConnectionStates.Initializing).increment()
val localFeatures = nodeParams.overrideFeatures.get(d.remoteNodeId) match {
case Some(f) => f
case None => nodeParams.features.maskFeaturesForEclairMobile()
case None => nodeParams.features
}
log.info(s"using features=$localFeatures")
val localInit = wire.Init(localFeatures, TlvStream(InitTlv.Networks(nodeParams.chainHash :: Nil)))

View file

@ -160,31 +160,6 @@ class PeerConnectionSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike wi
origin.expectMsg(PeerConnection.ConnectionResult.InitializationFailed("incompatible features"))
}
test("masks off MPP and PaymentSecret features") { f =>
import f._
val probe = TestProbe()
val testCases = Seq(
(bin" 00000010", bin" 00000010"), // option_data_loss_protect
(bin" 0000101010001010", bin" 0000101010001010"), // option_data_loss_protect, initial_routing_sync, gossip_queries, var_onion_optin, gossip_queries_ex
(bin" 1000101010001010", bin" 0000101010001010"), // option_data_loss_protect, initial_routing_sync, gossip_queries, var_onion_optin, gossip_queries_ex, payment_secret
(bin" 0100101010001010", bin" 0000101010001010"), // option_data_loss_protect, initial_routing_sync, gossip_queries, var_onion_optin, gossip_queries_ex, payment_secret
(bin"000000101000101010001010", bin" 0000101010001010"), // option_data_loss_protect, initial_routing_sync, gossip_queries, var_onion_optin, gossip_queries_ex, payment_secret, basic_mpp
(bin"000010101000101010001010", bin"000010000000101010001010") // option_data_loss_protect, initial_routing_sync, gossip_queries, var_onion_optin, gossip_queries_ex, payment_secret, basic_mpp and large_channel_support (optional)
)
for ((configuredFeatures, sentFeatures) <- testCases) {
val nodeParams = TestConstants.Alice.nodeParams.copy(features = Features(configuredFeatures))
val peerConnection = TestFSMRef(new PeerConnection(nodeParams, switchboard.ref, router.ref))
probe.send(peerConnection, PeerConnection.PendingAuth(connection.ref, Some(remoteNodeId), address, origin_opt = None, transport_opt = Some(transport.ref)))
transport.send(peerConnection, TransportHandler.HandshakeCompleted(remoteNodeId))
probe.send(peerConnection, PeerConnection.InitializeConnection(peer.ref))
transport.expectMsgType[TransportHandler.Listener]
val init = transport.expectMsgType[wire.Init]
assert(init.features.toByteVector === sentFeatures.bytes)
}
}
test("disconnect if incompatible networks") { f =>
import f._
val probe = TestProbe()