Skip to content

Commit

Permalink
Remove old compatibility workaround for eclair mobile (#1625)
Browse files Browse the repository at this point in the history
  • Loading branch information
pm47 committed Dec 8, 2020
1 parent 8d6af35 commit 4e56705
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 33 deletions.
17 changes: 0 additions & 17 deletions eclair-core/src/main/scala/fr/acinq/eclair/Features.scala
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,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
)
}

override def toString: String = {
val a = activated.map(f => f.feature.rfcName + ":" + f.support).mkString(",")
val u = unknown.map(_.bitIndex).mkString(",")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Switchboard(nodeParams: NodeParams, watcher: ActorRef, relayer: ActorRef,
case authenticated: PeerConnection.Authenticated =>
// if this is an incoming connection, we might not yet have created the peer
val peer = createOrGetPeer(authenticated.remoteNodeId, offlineChannels = Set.empty)
val features = nodeParams.featuresFor(authenticated.remoteNodeId).maskFeaturesForEclairMobile()
val features = nodeParams.featuresFor(authenticated.remoteNodeId)
val doSync = nodeParams.syncWhitelist.isEmpty || nodeParams.syncWhitelist.contains(authenticated.remoteNodeId)
authenticated.peerConnection ! PeerConnection.InitializeConnection(peer, nodeParams.chainHash, features, doSync)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,4 @@ class SwitchboardSpec extends TestKitBaseClass with AnyFunSuiteLike {
sendFeatures(remoteNodeId, Alice.nodeParams.features, Set(randomKey.publicKey, randomKey.publicKey, randomKey.publicKey), Alice.nodeParams.features, expectedSync = false)
}

test("on peer authentication, mask off MPP and PaymentSecret features") {
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) {
sendFeatures(randomKey.publicKey, Features(configuredFeatures), Set.empty, Features(sentFeatures), expectedSync = true)
}
}

}

0 comments on commit 4e56705

Please sign in to comment.