@@ -99,15 +99,15 @@ object Helpers {
9999 /**
100100 * Called by the fundee
101101 */
102- def validateParamsFundee (nodeParams : NodeParams , initFeatures : Features , channelType : ChannelType , open : OpenChannel , remoteNodeId : PublicKey , remoteFeatures : Features ): Either [ChannelException , (ChannelFeatures , Option [ByteVector ])] = {
102+ def validateParamsFundee (nodeParams : NodeParams , channelType : SupportedChannelType , localFeatures : Features , open : OpenChannel , remoteNodeId : PublicKey , remoteFeatures : Features ): Either [ChannelException , (ChannelFeatures , Option [ByteVector ])] = {
103103 // BOLT #2: if the chain_hash value, within the open_channel, message is set to a hash of a chain that is unknown to the receiver:
104104 // MUST reject the channel.
105105 if (nodeParams.chainHash != open.chainHash) return Left (InvalidChainHash (open.temporaryChannelId, local = nodeParams.chainHash, remote = open.chainHash))
106106
107107 if (open.fundingSatoshis < nodeParams.minFundingSatoshis || open.fundingSatoshis > nodeParams.maxFundingSatoshis) return Left (InvalidFundingAmount (open.temporaryChannelId, open.fundingSatoshis, nodeParams.minFundingSatoshis, nodeParams.maxFundingSatoshis))
108108
109109 // BOLT #2: Channel funding limits
110- if (open.fundingSatoshis >= Channel .MAX_FUNDING && ! initFeatures .hasFeature(Features .Wumbo )) return Left (InvalidFundingAmount (open.temporaryChannelId, open.fundingSatoshis, nodeParams.minFundingSatoshis, Channel .MAX_FUNDING ))
110+ if (open.fundingSatoshis >= Channel .MAX_FUNDING && ! localFeatures .hasFeature(Features .Wumbo )) return Left (InvalidFundingAmount (open.temporaryChannelId, open.fundingSatoshis, nodeParams.minFundingSatoshis, Channel .MAX_FUNDING ))
111111
112112 // BOLT #2: The receiving node MUST fail the channel if: push_msat is greater than funding_satoshis * 1000.
113113 if (open.pushMsat > open.fundingSatoshis) return Left (InvalidPushAmount (open.temporaryChannelId, open.pushMsat, open.fundingSatoshis.toMilliSatoshi))
@@ -147,22 +147,22 @@ object Helpers {
147147 val reserveToFundingRatio = open.channelReserveSatoshis.toLong.toDouble / Math .max(open.fundingSatoshis.toLong, 1 )
148148 if (reserveToFundingRatio > nodeParams.maxReserveToFundingRatio) return Left (ChannelReserveTooHigh (open.temporaryChannelId, open.channelReserveSatoshis, reserveToFundingRatio, nodeParams.maxReserveToFundingRatio))
149149
150- val channelFeatures = ChannelFeatures (channelType, initFeatures , remoteFeatures)
151- extractShutdownScript(open.temporaryChannelId, initFeatures , remoteFeatures, open.upfrontShutdownScript_opt).map(script_opt => (channelFeatures, script_opt))
150+ val channelFeatures = ChannelFeatures (channelType, localFeatures , remoteFeatures)
151+ extractShutdownScript(open.temporaryChannelId, localFeatures , remoteFeatures, open.upfrontShutdownScript_opt).map(script_opt => (channelFeatures, script_opt))
152152 }
153153
154154 /**
155155 * Called by the funder
156156 */
157- def validateParamsFunder (nodeParams : NodeParams , channelType : ChannelType , initFeatures : Features , remoteFeatures : Features , open : OpenChannel , accept : AcceptChannel ): Either [ChannelException , (ChannelFeatures , Option [ByteVector ])] = {
157+ def validateParamsFunder (nodeParams : NodeParams , channelType : SupportedChannelType , localFeatures : Features , remoteFeatures : Features , open : OpenChannel , accept : AcceptChannel ): Either [ChannelException , (ChannelFeatures , Option [ByteVector ])] = {
158158 accept.channelType_opt match {
159- case None if channelType != ChannelTypes .pickChannelType(initFeatures , remoteFeatures) =>
159+ case None if channelType != ChannelTypes .pickChannelType(localFeatures , remoteFeatures) =>
160160 // If we have overridden the default channel type, but they didn't support explicit channel type negotiation,
161161 // we need to abort because they expect a different channel type than what we offered.
162- return Left (InvalidChannelType (open.temporaryChannelId, channelType.features , ChannelTypes .pickChannelType(initFeatures , remoteFeatures).features ))
162+ return Left (InvalidChannelType (open.temporaryChannelId, channelType, ChannelTypes .pickChannelType(localFeatures , remoteFeatures)))
163163 case Some (theirChannelType) if accept.channelType_opt != open.channelType_opt =>
164164 // if channel_type is set, and channel_type was set in open_channel, and they are not equal types: MUST reject the channel.
165- return Left (InvalidChannelType (open.temporaryChannelId, channelType.features , theirChannelType))
165+ return Left (InvalidChannelType (open.temporaryChannelId, channelType, theirChannelType))
166166 case _ => // we agree on channel type
167167 }
168168
@@ -192,8 +192,8 @@ object Helpers {
192192 val reserveToFundingRatio = accept.channelReserveSatoshis.toLong.toDouble / Math .max(open.fundingSatoshis.toLong, 1 )
193193 if (reserveToFundingRatio > nodeParams.maxReserveToFundingRatio) return Left (ChannelReserveTooHigh (open.temporaryChannelId, accept.channelReserveSatoshis, reserveToFundingRatio, nodeParams.maxReserveToFundingRatio))
194194
195- val channelFeatures = ChannelFeatures (channelType, initFeatures , remoteFeatures)
196- extractShutdownScript(accept.temporaryChannelId, initFeatures , remoteFeatures, accept.upfrontShutdownScript_opt).map(script_opt => (channelFeatures, script_opt))
195+ val channelFeatures = ChannelFeatures (channelType, localFeatures , remoteFeatures)
196+ extractShutdownScript(accept.temporaryChannelId, localFeatures , remoteFeatures, accept.upfrontShutdownScript_opt).map(script_opt => (channelFeatures, script_opt))
197197 }
198198
199199 /**
0 commit comments