mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-20 14:34:24 +01:00
channel-list add capacity
This commit is contained in:
committed by
Carsten Otto
parent
7756e623b3
commit
b223aa5cea
@@ -39,13 +39,13 @@ public class DemoDataService extends UiDataService {
|
||||
"c-otto.de",
|
||||
"027ce055380348d7812d2ae7745701c9f93e70c1adeb2657f053f91df4f2843c71",
|
||||
1_500,
|
||||
20_000_000);
|
||||
19_998_500);
|
||||
public static final OpenChannelDto ACINQ = createOpenChannel(
|
||||
"799999x456x2",
|
||||
"ACINQ",
|
||||
"03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f",
|
||||
600_100,
|
||||
2_500_000);
|
||||
500_100,
|
||||
2_499_900);
|
||||
public static final OpenChannelDto TRY_BITCOIN = createOpenChannel(
|
||||
"799999x456x3",
|
||||
"try-bitcoin.com",
|
||||
@@ -57,19 +57,19 @@ public class DemoDataService extends UiDataService {
|
||||
"Kraken 🐙⚡",
|
||||
"02f1a8c87607f415c8f22c00593002775941dea48869ce23096af27b0cfdcc0b69",
|
||||
5_050_000,
|
||||
8_000_000);
|
||||
8_450_000);
|
||||
public static final OpenChannelDto POCKET = createOpenChannel(
|
||||
"799999x456x5",
|
||||
"PocketBitcoin.com",
|
||||
"02765a281bd188e80a89e6ea5092dcb8ebaaa5c5da341e64327e3fadbadcbc686c",
|
||||
10_500_900,
|
||||
12_000_000);
|
||||
11_499_100);
|
||||
public static final OpenChannelDto B_CASH_IS_TRASH = createOpenChannel(
|
||||
"799999x456x6",
|
||||
"BCash_Is_Trash",
|
||||
"0298f6074a454a1f5345cb2a7c6f9fce206cd0bf675d177cdbf0ca7508dd28852f",
|
||||
11_100_600,
|
||||
9_800_400);
|
||||
8_899_400);
|
||||
public static final OpenChannelDto WOS = createOpenChannel(
|
||||
"799999x456x7",
|
||||
"WalletOfSatoshi.com",
|
||||
@@ -80,13 +80,13 @@ public class DemoDataService extends UiDataService {
|
||||
"799999x456x8",
|
||||
"ACINQ",
|
||||
"03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f",
|
||||
12_400_100,
|
||||
1_500_900);
|
||||
11_899_100,
|
||||
1_600_900);
|
||||
public static final OpenChannelDto B_CASH_IS_TRASH2 = createOpenChannel(
|
||||
"799999x456x9",
|
||||
"BCash_Is_Trash",
|
||||
"0298f6074a454a1f5345cb2a7c6f9fce206cd0bf675d177cdbf0ca7508dd28852f",
|
||||
19_000_100,
|
||||
18_099_100,
|
||||
900_900);
|
||||
|
||||
public static final NodeWithWarningsDto ACINQ_WARNING = createNodeWithWarnings(
|
||||
@@ -164,17 +164,18 @@ public class DemoDataService extends UiDataService {
|
||||
long remote
|
||||
) {
|
||||
ChannelId channelId = ChannelId.fromCompactForm(compactChannelId);
|
||||
return new OpenChannelDto(
|
||||
channelId,
|
||||
alias,
|
||||
Pubkey.create(pubkey),
|
||||
PoliciesDto.createFromModel(derivePolicies(channelId)),
|
||||
BalanceInformationDto.createFromModel(new BalanceInformation(
|
||||
Coins.ofSatoshis(local),
|
||||
Coins.ofSatoshis(200),
|
||||
Coins.ofSatoshis(remote),
|
||||
Coins.ofSatoshis(500)
|
||||
)));
|
||||
Pubkey remotePubkey = Pubkey.create(pubkey);
|
||||
PoliciesDto policies = PoliciesDto.createFromModel(derivePolicies(channelId));
|
||||
long localReserve = 200;
|
||||
long remoteReserve = 500;
|
||||
long capacity = local + remote;
|
||||
BalanceInformationDto balance = BalanceInformationDto.createFromModel(new BalanceInformation(
|
||||
Coins.ofSatoshis(local),
|
||||
Coins.ofSatoshis(localReserve),
|
||||
Coins.ofSatoshis(remote),
|
||||
Coins.ofSatoshis(remoteReserve)
|
||||
));
|
||||
return new OpenChannelDto(channelId, alias, remotePubkey, policies, balance, capacity);
|
||||
}
|
||||
|
||||
private static ChannelDetailsDto createChannelDetails(OpenChannelDto channel) {
|
||||
@@ -184,6 +185,7 @@ public class DemoDataService extends UiDataService {
|
||||
channel.remoteAlias(),
|
||||
deriveOpenInitiator(channel.channelId()),
|
||||
channel.balanceInformation(),
|
||||
channel.capacitySat(),
|
||||
deriveOnChainCosts(channel.channelId()),
|
||||
channel.policies(),
|
||||
deriveFeeReport(channel.channelId()),
|
||||
|
||||
@@ -126,7 +126,9 @@ class SearchControllerIT extends BaseControllerIT {
|
||||
channelDetails.remoteAlias(),
|
||||
channelDetails.remotePubkey(),
|
||||
channelDetails.policies(),
|
||||
channelDetails.balanceInformation());
|
||||
channelDetails.balanceInformation(),
|
||||
channelDetails.capacitySat()
|
||||
);
|
||||
}
|
||||
|
||||
public NodeDto nodeDto(OpenChannelDto channel) {
|
||||
|
||||
@@ -65,11 +65,12 @@ public class UiDataServiceImpl extends UiDataService {
|
||||
|
||||
private OpenChannelDto toOpenChannelDto(ChannelId channelId) {
|
||||
LocalChannel localChannel = channelService.getLocalChannel(channelId).orElseThrow();
|
||||
Pubkey remotePubkey = localChannel.getRemotePubkey();
|
||||
String alias = nodeController.getAlias(remotePubkey);
|
||||
Pubkey pubkey = localChannel.getRemotePubkey();
|
||||
long capacitySat = localChannel.getCapacity().satoshis();
|
||||
String alias = nodeController.getAlias(pubkey);
|
||||
PoliciesDto policies = channelController.getPolicies(channelId);
|
||||
BalanceInformationDto balance = channelController.getBalance(channelId);
|
||||
return new OpenChannelDto(channelId, alias, remotePubkey, policies, balance);
|
||||
return new OpenChannelDto(channelId, alias, pubkey, policies, balance, capacitySat);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -81,6 +82,7 @@ public class UiDataServiceImpl extends UiDataService {
|
||||
details.remoteAlias(),
|
||||
details.openInitiator(),
|
||||
details.balance(),
|
||||
Long.parseLong(details.capacitySat()),
|
||||
details.onChainCosts(),
|
||||
details.policies(),
|
||||
details.feeReport(),
|
||||
|
||||
@@ -18,6 +18,7 @@ public record ChannelDetailsDto(
|
||||
String remoteAlias,
|
||||
OpenInitiator openInitiator,
|
||||
BalanceInformationDto balanceInformation,
|
||||
long capacitySat,
|
||||
OnChainCostsDto onChainCosts,
|
||||
PoliciesDto policies,
|
||||
FeeReportDto feeReport,
|
||||
|
||||
@@ -10,7 +10,8 @@ public record OpenChannelDto(
|
||||
String remoteAlias,
|
||||
Pubkey remotePubkey,
|
||||
PoliciesDto policies,
|
||||
BalanceInformationDto balanceInformation
|
||||
BalanceInformationDto balanceInformation,
|
||||
long capacitySat
|
||||
) {
|
||||
|
||||
public String getRatio() {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
<th scope="col" style="text-align: right;">Inbound</th>
|
||||
<th scope="col" style="text-align: center;">Ratio</th>
|
||||
<th scope="col" style="text-align: right;">Outbound</th>
|
||||
<th scope="col" style="text-align: right;">Capacity</th>
|
||||
<th scope="col" style="text-align: right;">Base Fee (local)</th>
|
||||
<th scope="col" style="text-align: right;">Fee Rate (local)</th>
|
||||
<th scope="col" style="text-align: right;">Base Fee (remote)</th>
|
||||
@@ -22,6 +23,7 @@
|
||||
<td th:text="${@formatter.formatNumber(channel.inbound)}" style="color: darkRed; text-align: right; padding-left:0;"></td>
|
||||
<td th:text="${channel.ratio}"></td>
|
||||
<td th:text="${@formatter.formatNumber(channel.outbound)}" style="color: darkGreen; text-align: right;"></td>
|
||||
<td th:text="${@formatter.formatNumber(channel.capacitySat)}" style="text-align: right;"></td>
|
||||
<td th:text="${@formatter.formatNumber(channel.policies.local.baseFeeMilliSat)}" style="text-align: right;"></td>
|
||||
<td th:text="${@formatter.formatNumber(channel.policies.local.feeRatePpm)}" style="text-align: right;"></td>
|
||||
<td th:text="${@formatter.formatNumber(channel.policies.remote.baseFeeMilliSat)}" style="text-align: right;"></td>
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import static de.cotto.lndmanagej.controller.dto.NodeDetailsDtoFixture.NODE_DETAILS_DTO;
|
||||
import static de.cotto.lndmanagej.controller.dto.OpenChannelDtoFixture.CAPACITY_SAT;
|
||||
import static de.cotto.lndmanagej.model.BalanceInformationFixtures.BALANCE_INFORMATION;
|
||||
import static de.cotto.lndmanagej.model.ChannelDetailsFixtures.CHANNEL_DETAILS;
|
||||
import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID;
|
||||
@@ -90,7 +91,7 @@ class UiDataServiceImplTest {
|
||||
when(statusController.getOpenChannels()).thenReturn(new ChannelsDto(List.of(CHANNEL_ID)));
|
||||
|
||||
assertThat(uiDataService.getOpenChannels()).containsExactly(
|
||||
new OpenChannelDto(CHANNEL_ID, alias, PUBKEY_2, policies, balance)
|
||||
new OpenChannelDto(CHANNEL_ID, alias, PUBKEY_2, policies, balance, CAPACITY_SAT)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -104,6 +105,7 @@ class UiDataServiceImplTest {
|
||||
ALIAS,
|
||||
LOCAL,
|
||||
BalanceInformationDto.createFromModel(BALANCE_INFORMATION),
|
||||
CAPACITY_SAT,
|
||||
OnChainCostsDto.createFromModel(ON_CHAIN_COSTS),
|
||||
PoliciesDto.createFromModel(POLICIES_FOR_LOCAL_CHANNEL),
|
||||
FeeReportDto.createFromModel(FEE_REPORT),
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.springframework.ui.Model;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static de.cotto.lndmanagej.controller.dto.OpenChannelDtoFixture.CAPACITY_SAT;
|
||||
import static de.cotto.lndmanagej.controller.dto.OpenChannelDtoFixture.OPEN_CHANNEL_DTO;
|
||||
import static de.cotto.lndmanagej.model.BalanceInformationFixtures.REMOTE_BALANCE;
|
||||
import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID;
|
||||
@@ -88,7 +89,8 @@ class DashboardControllerTest {
|
||||
"Albert",
|
||||
PUBKEY,
|
||||
PoliciesDto.createFromModel(POLICIES_FOR_LOCAL_CHANNEL),
|
||||
BalanceInformationDto.createFromModel(balanceInformation)
|
||||
BalanceInformationDto.createFromModel(balanceInformation),
|
||||
CAPACITY_SAT
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,11 @@ class ChannelDetailsDtoTest {
|
||||
.isEqualTo(BalanceInformationDto.createFromModel(BALANCE_INFORMATION));
|
||||
}
|
||||
|
||||
@Test
|
||||
void capacitySat() {
|
||||
assertThat(CHANNEL_DETAILS_DTO.capacitySat()).isEqualTo(21_000_000);
|
||||
}
|
||||
|
||||
@Test
|
||||
void onChainCosts() {
|
||||
assertThat(CHANNEL_DETAILS_DTO.onChainCosts()).isEqualTo(OnChainCostsDto.createFromModel(ON_CHAIN_COSTS));
|
||||
|
||||
@@ -6,6 +6,7 @@ import de.cotto.lndmanagej.model.BalanceInformation;
|
||||
import de.cotto.lndmanagej.model.Coins;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static de.cotto.lndmanagej.controller.dto.OpenChannelDtoFixture.CAPACITY_SAT;
|
||||
import static de.cotto.lndmanagej.controller.dto.OpenChannelDtoFixture.OPEN_CHANNEL_DTO;
|
||||
import static de.cotto.lndmanagej.model.BalanceInformationFixtures.BALANCE_INFORMATION;
|
||||
import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID;
|
||||
@@ -34,6 +35,11 @@ class OpenChannelDtoTest {
|
||||
assertThat(OPEN_CHANNEL_DTO.policies()).isEqualTo(PoliciesDto.createFromModel(POLICIES_FOR_LOCAL_CHANNEL));
|
||||
}
|
||||
|
||||
@Test
|
||||
void capacitySat() {
|
||||
assertThat(OPEN_CHANNEL_DTO.capacitySat()).isEqualTo(21_000_000);
|
||||
}
|
||||
|
||||
@Test
|
||||
void balanceInformation() {
|
||||
assertThat(OPEN_CHANNEL_DTO.balanceInformation())
|
||||
@@ -62,7 +68,8 @@ class OpenChannelDtoTest {
|
||||
"Albert",
|
||||
PUBKEY,
|
||||
PoliciesDto.createFromModel(POLICIES_FOR_LOCAL_CHANNEL),
|
||||
BalanceInformationDto.createFromModel(balanceInformation)
|
||||
BalanceInformationDto.createFromModel(balanceInformation),
|
||||
CAPACITY_SAT
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package de.cotto.lndmanagej.controller.dto;
|
||||
|
||||
import de.cotto.lndmanagej.ui.dto.ChannelDetailsDto;
|
||||
|
||||
import static de.cotto.lndmanagej.controller.dto.OpenChannelDtoFixture.CAPACITY_SAT;
|
||||
import static de.cotto.lndmanagej.model.BalanceInformationFixtures.BALANCE_INFORMATION;
|
||||
import static de.cotto.lndmanagej.model.ChannelIdFixtures.CHANNEL_ID;
|
||||
import static de.cotto.lndmanagej.model.FeeReportFixtures.FEE_REPORT;
|
||||
@@ -21,6 +22,7 @@ public class ChannelDetailsDtoFixture {
|
||||
"Albert",
|
||||
LOCAL,
|
||||
BalanceInformationDto.createFromModel(BALANCE_INFORMATION),
|
||||
CAPACITY_SAT,
|
||||
OnChainCostsDto.createFromModel(ON_CHAIN_COSTS),
|
||||
PoliciesDto.createFromModel(POLICIES_FOR_LOCAL_CHANNEL),
|
||||
FeeReportDto.createFromModel(FEE_REPORT),
|
||||
|
||||
@@ -12,18 +12,22 @@ import static de.cotto.lndmanagej.model.PubkeyFixtures.PUBKEY_2;
|
||||
|
||||
public class OpenChannelDtoFixture {
|
||||
|
||||
public static final long CAPACITY_SAT = 21_000_000;
|
||||
|
||||
public static final OpenChannelDto OPEN_CHANNEL_DTO = new OpenChannelDto(
|
||||
CHANNEL_ID,
|
||||
"Albert",
|
||||
PUBKEY,
|
||||
PoliciesDto.createFromModel(POLICIES_FOR_LOCAL_CHANNEL),
|
||||
BalanceInformationDto.createFromModel(BALANCE_INFORMATION));
|
||||
BalanceInformationDto.createFromModel(BALANCE_INFORMATION),
|
||||
CAPACITY_SAT);
|
||||
|
||||
public static final OpenChannelDto OPEN_CHANNEL_DTO2 = new OpenChannelDto(
|
||||
CHANNEL_ID_2,
|
||||
"Albert II",
|
||||
PUBKEY_2,
|
||||
PoliciesDto.createFromModel(POLICIES_FOR_LOCAL_CHANNEL),
|
||||
BalanceInformationDto.createFromModel(BALANCE_INFORMATION_2));
|
||||
BalanceInformationDto.createFromModel(BALANCE_INFORMATION_2),
|
||||
CAPACITY_SAT);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user