mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-21 15:04:22 +01:00
fix(hardcoded): extract hardcoded node aliases to "hardcoded" module (and make it configurable)
This commit is contained in:
committed by
Carsten Otto
parent
96e21ae89b
commit
c396bc351d
@@ -2,6 +2,7 @@ package de.cotto.lndmanagej.hardcoded;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
import de.cotto.lndmanagej.model.ChannelId;
|
||||
import de.cotto.lndmanagej.model.Pubkey;
|
||||
import de.cotto.lndmanagej.model.Resolution;
|
||||
import de.cotto.lndmanagej.model.TransactionHash;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -19,6 +20,7 @@ public class HardcodedService {
|
||||
private static final int EXPECTED_NUMBER_OF_COMPONENTS = 3;
|
||||
private static final String RESOLUTIONS_SECTION = "resolutions";
|
||||
private static final Splitter SPLITTER = Splitter.on(":");
|
||||
private static final String ALIASES_SECTION = "aliases";
|
||||
|
||||
private final IniFileReader iniFileReader;
|
||||
|
||||
@@ -26,6 +28,12 @@ public class HardcodedService {
|
||||
this.iniFileReader = iniFileReader;
|
||||
}
|
||||
|
||||
public String getAliasOrDefault(Pubkey pubkey, String defaultAlias) {
|
||||
Map<String, Set<String>> values = iniFileReader.getValues(ALIASES_SECTION);
|
||||
Set<String> alias = values.getOrDefault(pubkey.toString(), Set.of());
|
||||
return alias.stream().findFirst().orElse(defaultAlias);
|
||||
}
|
||||
|
||||
public Set<Resolution> getResolutions(ChannelId channelId) {
|
||||
Map<String, Set<String>> values = iniFileReader.getValues(RESOLUTIONS_SECTION);
|
||||
Set<String> forShortChannelId = values.getOrDefault(String.valueOf(channelId.getShortChannelId()), Set.of());
|
||||
|
||||
Reference in New Issue
Block a user