Merge pull request #7636 from bitromortac/2201-channel-type
lightning: implement channel types
This commit is contained in:
@@ -107,6 +107,7 @@ def create_channel_state(funding_txid, funding_index, funding_sat, is_initiator,
|
||||
'fail_htlc_reasons': {},
|
||||
'unfulfilled_htlcs': {},
|
||||
'revocation_store': {},
|
||||
'channel_type': lnutil.ChannelType.OPTION_STATIC_REMOTEKEY
|
||||
}
|
||||
return StoredDict(state, None, [])
|
||||
|
||||
|
||||
@@ -138,6 +138,7 @@ class MockLNWallet(Logger, NetworkRetryManager[LNPeerAddr]):
|
||||
self.features |= LnFeatures.VAR_ONION_OPT
|
||||
self.features |= LnFeatures.PAYMENT_SECRET_OPT
|
||||
self.features |= LnFeatures.OPTION_TRAMPOLINE_ROUTING_OPT
|
||||
self.features |= LnFeatures.OPTION_CHANNEL_TYPE_OPT
|
||||
self.pending_payments = defaultdict(asyncio.Future)
|
||||
for chan in chans:
|
||||
chan.lnworker = self
|
||||
|
||||
@@ -9,7 +9,7 @@ from electrum.lnutil import (RevocationStore, get_per_commitment_secret_from_see
|
||||
derive_pubkey, make_htlc_tx, extract_ctn_from_tx, UnableToDeriveSecret,
|
||||
get_compressed_pubkey_from_bech32, split_host_port, ConnStringFormatError,
|
||||
ScriptHtlc, extract_nodeid, calc_fees_for_commitment_tx, UpdateAddHtlc, LnFeatures,
|
||||
ln_compare_features, IncompatibleLightningFeatures)
|
||||
ln_compare_features, IncompatibleLightningFeatures, ChannelType)
|
||||
from electrum.util import bh2u, bfh, MyEncoder
|
||||
from electrum.transaction import Transaction, PartialTransaction
|
||||
from electrum.lnworker import LNWallet
|
||||
@@ -890,3 +890,15 @@ class TestLNUtil(ElectrumTestCase):
|
||||
self.assertEqual(
|
||||
None,
|
||||
LNWallet._decode_channel_update_msg(bytes.fromhex("0101") + msg_without_prefix))
|
||||
|
||||
def test_channel_type(self):
|
||||
# test compliance and non compliance with LN features
|
||||
features = LnFeatures(LnFeatures.BASIC_MPP_OPT | LnFeatures.OPTION_STATIC_REMOTEKEY_OPT)
|
||||
self.assertTrue(ChannelType.OPTION_STATIC_REMOTEKEY.complies_with_features(features))
|
||||
|
||||
features = LnFeatures(LnFeatures.BASIC_MPP_OPT | LnFeatures.OPTION_TRAMPOLINE_ROUTING_OPT)
|
||||
self.assertFalse(ChannelType.OPTION_STATIC_REMOTEKEY.complies_with_features(features))
|
||||
|
||||
# ignore unknown channel types
|
||||
channel_type = ChannelType(0b10000000001000000000010).discard_unknown_and_check()
|
||||
self.assertEqual(ChannelType(0b10000000001000000000000), channel_type)
|
||||
Reference in New Issue
Block a user