load transaction details for outpoints of pending HTLCs in force-closing channels

This commit is contained in:
Carsten Otto
2021-11-16 23:40:28 +01:00
parent a63a8f96bd
commit 1d4ecb4813
7 changed files with 110 additions and 19 deletions

View File

@@ -3,6 +3,7 @@ package de.cotto.lndmanagej.service;
import de.cotto.lndmanagej.model.Channel;
import de.cotto.lndmanagej.model.ChannelPoint;
import de.cotto.lndmanagej.model.ClosedOrClosingChannel;
import de.cotto.lndmanagej.model.ForceClosingChannel;
import de.cotto.lndmanagej.transactions.service.TransactionService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -33,7 +34,9 @@ public class TransactionBackgroundLoader {
private Stream<String> getTransactionHashes() {
Stream<String> openTransactionHashes = getOpenTransactionHashes();
Stream<String> closeTransactionHashes = getCloseTransactionHashes();
return Stream.concat(openTransactionHashes, closeTransactionHashes);
Stream<String> htlcOutpointHashes = getHtlcOutpointHashes();
return Stream.of(openTransactionHashes, closeTransactionHashes, htlcOutpointHashes)
.flatMap(s -> s);
}
private Stream<String> getOpenTransactionHashes() {
@@ -54,4 +57,11 @@ public class TransactionBackgroundLoader {
.map(ClosedOrClosingChannel::getCloseTransactionHash);
}
private Stream<String> getHtlcOutpointHashes() {
return channelService.getForceClosingChannels().stream()
.map(ForceClosingChannel::getHtlcOutpoints)
.flatMap(Collection::stream)
.map(ChannelPoint::getTransactionHash);
}
}