mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-02-23 15:04:39 +01:00
improve node with warnings
This commit is contained in:
committed by
Carsten Otto
parent
4c710e036d
commit
ca63acff7a
@@ -1,6 +1,9 @@
|
||||
package de.cotto.lndmanagej.ui.demo;
|
||||
|
||||
import de.cotto.lndmanagej.controller.dto.ChannelWithWarningsDto;
|
||||
import de.cotto.lndmanagej.controller.dto.NodeDetailsDto;
|
||||
import de.cotto.lndmanagej.controller.dto.NodeWithWarningsDto;
|
||||
import de.cotto.lndmanagej.controller.dto.NodesAndChannelsWithWarningsDto;
|
||||
import de.cotto.lndmanagej.model.ChannelId;
|
||||
import de.cotto.lndmanagej.model.Pubkey;
|
||||
import de.cotto.lndmanagej.ui.UiDataService;
|
||||
@@ -11,71 +14,80 @@ import de.cotto.lndmanagej.ui.dto.StatusModel;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static de.cotto.lndmanagej.ui.demo.utils.ChannelDataUtil.createOpenChannel;
|
||||
import static de.cotto.lndmanagej.ui.demo.utils.ChannelDetailsUtil.createChannelDetails;
|
||||
import static de.cotto.lndmanagej.ui.demo.utils.NodeDetailsUtil.createNodeDetails;
|
||||
import static de.cotto.lndmanagej.ui.demo.utils.NodeWarningsUtil.getStatusModel;
|
||||
|
||||
@Component
|
||||
public class DemoDataService extends UiDataService {
|
||||
|
||||
private static final List<OpenChannelDto> OPEN_CHANNELS = List.of(
|
||||
createOpenChannel(
|
||||
"799999x456x1",
|
||||
"c-otto.de",
|
||||
"027ce055380348d7812d2ae7745701c9f93e70c1adeb2657f053f91df4f2843c71",
|
||||
1_500,
|
||||
20_000_000),
|
||||
createOpenChannel(
|
||||
"799999x456x2",
|
||||
"ACINQ",
|
||||
"03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f",
|
||||
600_100,
|
||||
2_500_000),
|
||||
createOpenChannel(
|
||||
"799999x456x3",
|
||||
"try-bitcoin.com",
|
||||
"03de6bc7ed1badd0827b99c5b1ad2865322815e761572717a536f0a482864c4427",
|
||||
5_700_000,
|
||||
14_300_000),
|
||||
createOpenChannel(
|
||||
"799999x456x4",
|
||||
"Kraken 🐙⚡",
|
||||
"02f1a8c87607f415c8f22c00593002775941dea48869ce23096af27b0cfdcc0b69",
|
||||
5_050_000,
|
||||
8_000_000),
|
||||
createOpenChannel(
|
||||
"799999x456x5",
|
||||
"PocketBitcoin.com",
|
||||
"02765a281bd188e80a89e6ea5092dcb8ebaaa5c5da341e64327e3fadbadcbc686c",
|
||||
10_500_900,
|
||||
12_000_000),
|
||||
createOpenChannel(
|
||||
"799999x456x6",
|
||||
"BCash_Is_Trash",
|
||||
"0298f6074a454a1f5345cb2a7c6f9fce206cd0bf675d177cdbf0ca7508dd28852f",
|
||||
11_100_600,
|
||||
9_800_400),
|
||||
createOpenChannel(
|
||||
"799999x456x7",
|
||||
"WalletOfSatoshi.com",
|
||||
"035e4ff418fc8b5554c5d9eea66396c227bd429a3251c8cbc711002ba215bfc226",
|
||||
8_500_000,
|
||||
3_500_000),
|
||||
createOpenChannel(
|
||||
"799999x456x8",
|
||||
"ACINQ",
|
||||
"03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f",
|
||||
12_400_100,
|
||||
1_500_900),
|
||||
createOpenChannel(
|
||||
"799999x456x9",
|
||||
"BCash_Is_Trash",
|
||||
"0298f6074a454a1f5345cb2a7c6f9fce206cd0bf675d177cdbf0ca7508dd28852f",
|
||||
19_000_100,
|
||||
900_900)
|
||||
);
|
||||
public static final OpenChannelDto C_OTTO = createOpenChannel(
|
||||
"799999x456x1",
|
||||
"c-otto.de",
|
||||
"027ce055380348d7812d2ae7745701c9f93e70c1adeb2657f053f91df4f2843c71",
|
||||
1_500,
|
||||
20_000_000);
|
||||
public static final OpenChannelDto ACINQ = createOpenChannel(
|
||||
"799999x456x2",
|
||||
"ACINQ",
|
||||
"03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f",
|
||||
600_100,
|
||||
2_500_000);
|
||||
public static final OpenChannelDto TRY_BITCOIN = createOpenChannel(
|
||||
"799999x456x3",
|
||||
"try-bitcoin.com",
|
||||
"03de6bc7ed1badd0827b99c5b1ad2865322815e761572717a536f0a482864c4427",
|
||||
5_700_000,
|
||||
14_300_000);
|
||||
public static final OpenChannelDto KRAKEN = createOpenChannel(
|
||||
"799999x456x4",
|
||||
"Kraken 🐙⚡",
|
||||
"02f1a8c87607f415c8f22c00593002775941dea48869ce23096af27b0cfdcc0b69",
|
||||
5_050_000,
|
||||
8_000_000);
|
||||
public static final OpenChannelDto POCKET = createOpenChannel(
|
||||
"799999x456x5",
|
||||
"PocketBitcoin.com",
|
||||
"02765a281bd188e80a89e6ea5092dcb8ebaaa5c5da341e64327e3fadbadcbc686c",
|
||||
10_500_900,
|
||||
12_000_000);
|
||||
public static final OpenChannelDto B_CASH_IS_TRASH = createOpenChannel(
|
||||
"799999x456x6",
|
||||
"BCash_Is_Trash",
|
||||
"0298f6074a454a1f5345cb2a7c6f9fce206cd0bf675d177cdbf0ca7508dd28852f",
|
||||
11_100_600,
|
||||
9_800_400);
|
||||
public static final OpenChannelDto WOS = createOpenChannel(
|
||||
"799999x456x7",
|
||||
"WalletOfSatoshi.com",
|
||||
"035e4ff418fc8b5554c5d9eea66396c227bd429a3251c8cbc711002ba215bfc226",
|
||||
8_500_000,
|
||||
3_500_000);
|
||||
public static final OpenChannelDto ACINQ2 = createOpenChannel(
|
||||
"799999x456x8",
|
||||
"ACINQ",
|
||||
"03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f",
|
||||
12_400_100,
|
||||
1_500_900);
|
||||
public static final OpenChannelDto B_CASH_IS_TRASH2 = createOpenChannel(
|
||||
"799999x456x9",
|
||||
"BCash_Is_Trash",
|
||||
"0298f6074a454a1f5345cb2a7c6f9fce206cd0bf675d177cdbf0ca7508dd28852f",
|
||||
19_000_100,
|
||||
900_900);
|
||||
|
||||
public static final NodeWithWarningsDto ACINQ_WARNING = createNodeWarnings(
|
||||
ACINQ.remoteAlias(),
|
||||
ACINQ.remotePubkey(),
|
||||
"No flow in the past 21 days.",
|
||||
"Node has been online 86% in the past 14 days");
|
||||
|
||||
public static final NodeWithWarningsDto POCKET_WARNING = createNodeWarnings(
|
||||
POCKET.remoteAlias(),
|
||||
POCKET.remotePubkey(),
|
||||
"No flow in the past 35 days.");
|
||||
|
||||
public DemoDataService() {
|
||||
super();
|
||||
@@ -83,12 +95,14 @@ public class DemoDataService extends UiDataService {
|
||||
|
||||
@Override
|
||||
public StatusModel getStatus() {
|
||||
return getStatusModel();
|
||||
return new StatusModel(true, 735_642, new NodesAndChannelsWithWarningsDto(
|
||||
List.of(ACINQ_WARNING, POCKET_WARNING),
|
||||
List.of(createChannelWarnings(KRAKEN.channelId(), "Warning channel"))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OpenChannelDto> getOpenChannels() {
|
||||
return OPEN_CHANNELS;
|
||||
return List.of(C_OTTO, ACINQ, TRY_BITCOIN, KRAKEN, WOS, B_CASH_IS_TRASH, POCKET, ACINQ2, B_CASH_IS_TRASH2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -117,6 +131,15 @@ public class DemoDataService extends UiDataService {
|
||||
return channel.channelId().getShortChannelId() % 4 != 0;
|
||||
}
|
||||
|
||||
|
||||
public static NodeWithWarningsDto createNodeWarnings(String alias, Pubkey pubkey, String... warnings) {
|
||||
return new NodeWithWarningsDto(Set.of(warnings), alias, pubkey);
|
||||
}
|
||||
|
||||
public static ChannelWithWarningsDto createChannelWarnings(ChannelId channelId, String... warnings) {
|
||||
return new ChannelWithWarningsDto(Set.of(warnings), channelId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
package de.cotto.lndmanagej.ui.demo.utils;
|
||||
|
||||
import de.cotto.lndmanagej.controller.dto.ChannelWithWarningsDto;
|
||||
import de.cotto.lndmanagej.controller.dto.NodeWithWarningsDto;
|
||||
import de.cotto.lndmanagej.controller.dto.NodesAndChannelsWithWarningsDto;
|
||||
import de.cotto.lndmanagej.model.warnings.Warning;
|
||||
import de.cotto.lndmanagej.ui.dto.StatusModel;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID_3;
|
||||
import static de.cotto.lndmanagej.model.PubkeyFixtures.PUBKEY;
|
||||
import static de.cotto.lndmanagej.model.warnings.ChannelWarningsFixtures.CHANNEL_WARNINGS;
|
||||
import static de.cotto.lndmanagej.model.warnings.NodeWarningsFixtures.NODE_WARNINGS;
|
||||
|
||||
public final class NodeWarningsUtil {
|
||||
|
||||
private NodeWarningsUtil() {
|
||||
// util class
|
||||
}
|
||||
|
||||
public static StatusModel getStatusModel() {
|
||||
return new StatusModel(true, 735_642, createNodeWarnings());
|
||||
}
|
||||
|
||||
public static NodesAndChannelsWithWarningsDto createNodeWarnings() {
|
||||
return new NodesAndChannelsWithWarningsDto(
|
||||
List.of(new NodeWithWarningsDto(NODE_WARNINGS.warnings().stream()
|
||||
.map(Warning::description)
|
||||
.collect(Collectors.toSet()), "WalletOfSatoshi", PUBKEY),
|
||||
new NodeWithWarningsDto(NODE_WARNINGS.warnings().stream()
|
||||
.map(Warning::description)
|
||||
.collect(Collectors.toSet()), "Albert", PUBKEY)
|
||||
),
|
||||
List.of(new ChannelWithWarningsDto(CHANNEL_WARNINGS.warnings().stream()
|
||||
.map(Warning::description)
|
||||
.collect(Collectors.toSet()), CHANNEL_ID_3)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user