diff --git a/electrum/mpp_split.py b/electrum/mpp_split.py index 3b0aa6417..c8d9d3e38 100644 --- a/electrum/mpp_split.py +++ b/electrum/mpp_split.py @@ -82,14 +82,10 @@ def remove_single_part_configs(configs: List[SplitConfig]) -> List[SplitConfig]: def remove_single_channel_splits(configs: List[SplitConfig]) -> List[SplitConfig]: - filtered = [] - for config in configs: - for v in config.values(): - if len(v) > 1: - continue - filtered.append(config) - return filtered - + return [ + config for config in configs + if all(len(channel_splits) <= 1 for channel_splits in config.values()) + ] def rate_config( config: SplitConfig, diff --git a/tests/test_mpp_split.py b/tests/test_mpp_split.py index 2c6bfe244..5da50a5e9 100644 --- a/tests/test_mpp_split.py +++ b/tests/test_mpp_split.py @@ -87,6 +87,12 @@ class TestMppSplit(ElectrumTestCase): # check that the whole amount has been split on this channel self.assertEqual(sum(split.config[(b"0", b"0")]), 1_000_000_000) + with self.subTest(msg="test exclude single channel splits"): + splits = mpp_split.suggest_splits(1_000_000_000, self.channels_with_funds, exclude_single_channel_splits=True) + for split in splits: + for channel_split in split.config.values(): + assert len(channel_split) <= 1, split + def test_send_to_single_node(self): splits = mpp_split.suggest_splits(1_000_000_000, self.channels_with_funds, exclude_single_part_payments=False, exclude_multinode_payments=True) for split in splits: