mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-27 09:54:51 +01:00
fix fee computation
- compute fees per hop - fees for first hop are not paid - show fees for first hop
This commit is contained in:
@@ -4,14 +4,14 @@ import de.cotto.lndmanagej.pickhardtpayments.model.MultiPathPayment;
|
||||
import de.cotto.lndmanagej.pickhardtpayments.model.Route;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public record MultiPathPaymentDto(
|
||||
String amountSat,
|
||||
double probability,
|
||||
String feesMilliSat,
|
||||
String feesWithFirstHopMilliSat,
|
||||
long feeRate,
|
||||
long feeRateWithFirstHop,
|
||||
List<RouteDto> routes
|
||||
) {
|
||||
public static MultiPathPaymentDto fromModel(MultiPathPayment multiPathPayment) {
|
||||
@@ -19,12 +19,14 @@ public record MultiPathPaymentDto(
|
||||
String.valueOf(multiPathPayment.amount().satoshis()),
|
||||
multiPathPayment.probability(),
|
||||
String.valueOf(multiPathPayment.fees().milliSatoshis()),
|
||||
String.valueOf(multiPathPayment.feesWithFirstHop().milliSatoshis()),
|
||||
multiPathPayment.getFeeRate(),
|
||||
multiPathPayment.getFeeRateWithFirstHop(),
|
||||
getRoutes(multiPathPayment.routes())
|
||||
);
|
||||
}
|
||||
|
||||
private static List<RouteDto> getRoutes(Set<Route> routes) {
|
||||
return routes.stream().map(RouteDto::fromModel).collect(Collectors.toList());
|
||||
private static List<RouteDto> getRoutes(List<Route> routes) {
|
||||
return routes.stream().map(RouteDto::fromModel).toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,9 @@ public record RouteDto(
|
||||
List<ChannelId> channelIds,
|
||||
double probability,
|
||||
String feesMilliSat,
|
||||
long feeRate
|
||||
String feesWithFirstHopMilliSat,
|
||||
long feeRate,
|
||||
long feeRateWithFirstHop
|
||||
) {
|
||||
public static RouteDto fromModel(Route route) {
|
||||
return new RouteDto(
|
||||
@@ -19,7 +21,9 @@ public record RouteDto(
|
||||
route.edges().stream().map(Edge::channelId).toList(),
|
||||
route.getProbability(),
|
||||
String.valueOf(route.fees().milliSatoshis()),
|
||||
route.getFeeRate()
|
||||
String.valueOf(route.feesWithFirstHop().milliSatoshis()),
|
||||
route.getFeeRate(),
|
||||
route.getFeeRateWithFirstHop()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user