mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-22 22:45:21 +01:00
Payout tx confidence should be after block height of deposit.
This commit is contained in:
parent
d83a205fe2
commit
030bb3f64c
2 changed files with 22 additions and 1 deletions
|
@ -451,6 +451,23 @@ public abstract class WalletService {
|
|||
return getMostRecentConfidence(transactionConfidenceList);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TransactionConfidence getConfidenceForAddressFromBlockHeight(Address address, long targetHeight) {
|
||||
List<TransactionConfidence> transactionConfidenceList = new ArrayList<>();
|
||||
if (wallet != null) {
|
||||
Set<Transaction> transactions = getAddressToMatchingTxSetMultimap().get(address);
|
||||
// "acceptable confidence" is either a new (pending) Tx, or a Tx confirmed after target block height
|
||||
transactionConfidenceList.addAll(transactions.stream()
|
||||
.map(tx -> getTransactionConfidence(tx, address))
|
||||
.filter(Objects::nonNull)
|
||||
.filter(con -> con.getConfidenceType() == TransactionConfidence.ConfidenceType.PENDING ||
|
||||
(con.getConfidenceType() == TransactionConfidence.ConfidenceType.BUILDING &&
|
||||
con.getAppearedAtChainHeight() > targetHeight))
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
return getMostRecentConfidence(transactionConfidenceList);
|
||||
}
|
||||
|
||||
private SetMultimap<Address, Transaction> getAddressToMatchingTxSetMultimap() {
|
||||
return addressToMatchingTxSetCache.updateAndGet(map -> map != null ? map : computeAddressToMatchingTxSetMultimap());
|
||||
}
|
||||
|
|
|
@ -32,6 +32,8 @@ import org.bitcoinj.core.TransactionConfidence;
|
|||
import org.fxmisc.easybind.EasyBind;
|
||||
import org.fxmisc.easybind.Subscription;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
|
@ -56,7 +58,9 @@ public abstract class SetupPayoutTxListener extends TradeTask {
|
|||
String id = processModel.getOffer().getId();
|
||||
Address address = walletService.getOrCreateAddressEntry(id, AddressEntry.Context.TRADE_PAYOUT).getAddress();
|
||||
|
||||
TransactionConfidence confidence = walletService.getConfidenceForAddress(address);
|
||||
// check if the payout already happened (ensuring it was > deposit block height, see GH #5725)
|
||||
TransactionConfidence confidence = walletService.getConfidenceForAddressFromBlockHeight(address,
|
||||
Objects.requireNonNull(trade.getDepositTx()).getConfidence().getAppearedAtChainHeight());
|
||||
if (isInNetwork(confidence)) {
|
||||
applyConfidence(confidence);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue