@@ -1219,27 +1219,13 @@ async def on_open_channel(self, payload):
1219
1219
1220
1220
Channel configurations are initialized in this method.
1221
1221
"""
1222
- if self .lnworker .has_recoverable_channels ():
1223
- # FIXME: we might want to keep the connection open
1224
- raise Exception ('not accepting channels' )
1222
+
1225
1223
# <- open_channel
1226
1224
if payload ['chain_hash' ] != constants .net .rev_genesis_bytes ():
1227
1225
raise Exception ('wrong chain_hash' )
1228
- funding_sat = payload ['funding_satoshis' ]
1229
- push_msat = payload ['push_msat' ]
1230
- feerate = payload ['feerate_per_kw' ] # note: we are not validating this
1231
- temp_chan_id = payload ['temporary_channel_id' ]
1232
- # store the temp id now, so that it is recognized for e.g. 'error' messages
1233
- # TODO: this is never cleaned up; the dict grows unbounded until disconnect
1234
- self .temp_id_to_id [temp_chan_id ] = None
1235
1226
1236
1227
open_channel_tlvs = payload .get ('open_channel_tlvs' )
1237
1228
channel_type = open_channel_tlvs .get ('channel_type' ) if open_channel_tlvs else None
1238
-
1239
- channel_opening_fee = open_channel_tlvs .get ('channel_opening_fee' ) if open_channel_tlvs else None
1240
- if channel_opening_fee :
1241
- # todo check that the fee is reasonable
1242
- pass
1243
1229
# The receiving node MAY fail the channel if:
1244
1230
# option_channel_type was negotiated but the message doesn't include a channel_type
1245
1231
if self .is_channel_type () and channel_type is None :
@@ -1251,6 +1237,29 @@ async def on_open_channel(self, payload):
1251
1237
if not channel_type .complies_with_features (self .features ):
1252
1238
raise Exception ("sender has sent a channel type we don't support" )
1253
1239
1240
+ if self .is_channel_type ():
1241
+ is_zeroconf = bool (channel_type & ChannelType .OPTION_ZEROCONF )
1242
+ if is_zeroconf and not self .network .config .ZEROCONF_TRUSTED_NODE .startswith (self .pubkey .hex ()):
1243
+ raise Exception (f"not accepting zeroconf from node { self .pubkey } " )
1244
+ else :
1245
+ is_zeroconf = False
1246
+
1247
+ if self .lnworker .has_recoverable_channels () and not is_zeroconf :
1248
+ # FIXME: we might want to keep the connection open
1249
+ raise Exception ('not accepting channels' )
1250
+
1251
+ funding_sat = payload ['funding_satoshis' ]
1252
+ push_msat = payload ['push_msat' ]
1253
+ feerate = payload ['feerate_per_kw' ] # note: we are not validating this
1254
+ temp_chan_id = payload ['temporary_channel_id' ]
1255
+ # store the temp id now, so that it is recognized for e.g. 'error' messages
1256
+ # TODO: this is never cleaned up; the dict grows unbounded until disconnect
1257
+ self .temp_id_to_id [temp_chan_id ] = None
1258
+ channel_opening_fee = open_channel_tlvs .get ('channel_opening_fee' ) if open_channel_tlvs else None
1259
+ if channel_opening_fee :
1260
+ # todo check that the fee is reasonable
1261
+ pass
1262
+
1254
1263
if self .use_anchors ():
1255
1264
multisig_funding_keypair = lnutil .derive_multisig_funding_key_if_they_opened (
1256
1265
funding_root_secret = self .lnworker .funding_root_keypair .privkey ,
@@ -1311,9 +1320,6 @@ async def on_open_channel(self, payload):
1311
1320
per_commitment_point_first = secret_to_pubkey (
1312
1321
int .from_bytes (per_commitment_secret_first , 'big' ))
1313
1322
1314
- is_zeroconf = channel_type & channel_type .OPTION_ZEROCONF
1315
- if is_zeroconf and not self .network .config .ZEROCONF_TRUSTED_NODE .startswith (self .pubkey .hex ()):
1316
- raise Exception (f"not accepting zeroconf from node { self .pubkey } " )
1317
1323
min_depth = 0 if is_zeroconf else 3
1318
1324
1319
1325
accept_channel_tlvs = {
0 commit comments