mirror of
https://github.com/ACINQ/eclair.git
synced 2025-02-22 22:25:26 +01:00
Optional per-node features in conf (#778)
Allow setting specific `globalfeatures` and `localfeatures` for given nodes.
This commit is contained in:
parent
4573d8a1e0
commit
723d0deed2
4 changed files with 26 additions and 2 deletions
|
@ -41,11 +41,19 @@ eclair {
|
|||
|
||||
node-alias = "eclair"
|
||||
node-color = "49daaa"
|
||||
|
||||
global-features = ""
|
||||
local-features = "8a" // initial_routing_sync + option_data_loss_protect + option_channel_range_queries
|
||||
override-features = [ // optional per-node features
|
||||
# {
|
||||
# nodeid = "02aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
# global-features = "",
|
||||
# local-features = ""
|
||||
# }
|
||||
]
|
||||
channel-flags = 1 // announce channels
|
||||
dust-limit-satoshis = 546
|
||||
|
||||
dust-limit-satoshis = 546
|
||||
max-htlc-value-in-flight-msat = 5000000000 // 50 mBTC
|
||||
htlc-minimum-msat = 1
|
||||
max-accepted-htlcs = 30
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.concurrent.TimeUnit
|
|||
|
||||
import com.google.common.net.InetAddresses
|
||||
import com.typesafe.config.{Config, ConfigFactory}
|
||||
import fr.acinq.bitcoin.Crypto.PublicKey
|
||||
import fr.acinq.bitcoin.{BinaryData, Block}
|
||||
import fr.acinq.eclair.NodeParams.WatcherType
|
||||
import fr.acinq.eclair.channel.Channel
|
||||
|
@ -44,6 +45,7 @@ case class NodeParams(keyManager: KeyManager,
|
|||
publicAddresses: List[InetSocketAddress],
|
||||
globalFeatures: BinaryData,
|
||||
localFeatures: BinaryData,
|
||||
overrideFeatures: Map[PublicKey, (BinaryData, BinaryData)],
|
||||
dustLimitSatoshis: Long,
|
||||
maxHtlcValueInFlightMsat: UInt64,
|
||||
maxAcceptedHtlcs: Int,
|
||||
|
@ -161,6 +163,13 @@ object NodeParams {
|
|||
val maxAcceptedHtlcs = config.getInt("max-accepted-htlcs")
|
||||
require(maxAcceptedHtlcs <= Channel.MAX_ACCEPTED_HTLCS, s"max-accepted-htlcs must be lower than ${Channel.MAX_ACCEPTED_HTLCS}")
|
||||
|
||||
val overrideFeatures: Map[PublicKey, (BinaryData, BinaryData)] = config.getConfigList("override-features").map { e =>
|
||||
val p = PublicKey(e.getString("nodeid"))
|
||||
val gf = BinaryData(e.getString("global-features"))
|
||||
val lf = BinaryData(e.getString("local-features"))
|
||||
(p -> (gf, lf))
|
||||
}.toMap
|
||||
|
||||
NodeParams(
|
||||
keyManager = keyManager,
|
||||
alias = config.getString("node-alias").take(32),
|
||||
|
@ -168,6 +177,7 @@ object NodeParams {
|
|||
publicAddresses = config.getStringList("server.public-ips").toList.map(ip => new InetSocketAddress(InetAddresses.forString(ip), config.getInt("server.port"))),
|
||||
globalFeatures = BinaryData(config.getString("global-features")),
|
||||
localFeatures = BinaryData(config.getString("local-features")),
|
||||
overrideFeatures = overrideFeatures,
|
||||
dustLimitSatoshis = dustLimitSatoshis,
|
||||
maxHtlcValueInFlightMsat = UInt64(config.getLong("max-htlc-value-in-flight-msat")),
|
||||
maxAcceptedHtlcs = maxAcceptedHtlcs,
|
||||
|
|
|
@ -77,7 +77,11 @@ class Peer(nodeParams: NodeParams, remoteNodeId: PublicKey, authenticator: Actor
|
|||
log.debug(s"got authenticated connection to $remoteNodeId@${address.getHostString}:${address.getPort}")
|
||||
transport ! TransportHandler.Listener(self)
|
||||
context watch transport
|
||||
val localInit = wire.Init(globalFeatures = nodeParams.globalFeatures, localFeatures = nodeParams.localFeatures)
|
||||
val localInit = nodeParams.overrideFeatures.get(remoteNodeId) match {
|
||||
case Some((gf, lf)) => wire.Init(globalFeatures = gf, localFeatures = lf)
|
||||
case None => wire.Init(globalFeatures = nodeParams.globalFeatures, localFeatures = nodeParams.localFeatures)
|
||||
}
|
||||
log.info(s"using globalFeatures=${localInit.globalFeatures} and localFeatures=${localInit.localFeatures}")
|
||||
transport ! localInit
|
||||
|
||||
// we store the ip upon successful outgoing connection, keeping only the most recent one
|
||||
|
|
|
@ -51,6 +51,7 @@ object TestConstants {
|
|||
publicAddresses = new InetSocketAddress("localhost", 9731) :: Nil,
|
||||
globalFeatures = "",
|
||||
localFeatures = "00",
|
||||
overrideFeatures = Map.empty,
|
||||
dustLimitSatoshis = 1100,
|
||||
maxHtlcValueInFlightMsat = UInt64(150000000),
|
||||
maxAcceptedHtlcs = 100,
|
||||
|
@ -107,6 +108,7 @@ object TestConstants {
|
|||
publicAddresses = new InetSocketAddress("localhost", 9732) :: Nil,
|
||||
globalFeatures = "",
|
||||
localFeatures = "00", // no announcement
|
||||
overrideFeatures = Map.empty,
|
||||
dustLimitSatoshis = 1000,
|
||||
maxHtlcValueInFlightMsat = UInt64.MaxValue, // Bob has no limit on the combined max value of in-flight htlcs
|
||||
maxAcceptedHtlcs = 30,
|
||||
|
|
Loading…
Add table
Reference in a new issue