From 9feccb6b46fec598f4df8ee88203012b23d55452 Mon Sep 17 00:00:00 2001 From: jmacxx <47253594+jmacxx@users.noreply.github.com> Date: Thu, 23 Mar 2023 12:19:12 -0500 Subject: [PATCH] BSQ trade fee validation NACK if tx unconfirmed for a long time. --- .../bisq/core/provider/mempool/TxValidator.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/bisq/core/provider/mempool/TxValidator.java b/core/src/main/java/bisq/core/provider/mempool/TxValidator.java index 0d71fd55f1b..f948eab6220 100644 --- a/core/src/main/java/bisq/core/provider/mempool/TxValidator.java +++ b/core/src/main/java/bisq/core/provider/mempool/TxValidator.java @@ -63,7 +63,6 @@ public class TxValidator { private Coin amount; @Nullable private Boolean isFeeCurrencyBtc; - @Nullable private Long chainHeight; @Setter private String jsonTxt; @@ -79,6 +78,7 @@ public TxValidator(DaoStateService daoStateService, this.amount = amount; this.isFeeCurrencyBtc = isFeeCurrencyBtc; this.feePaymentBlockHeight = feePaymentBlockHeight; + this.chainHeight = (long) daoStateService.getChainHeight(); this.filterManager = filterManager; this.errorList = new ArrayList<>(); this.jsonTxt = ""; @@ -119,10 +119,19 @@ public TxValidator parseJsonValidateMakerFeeTx(String jsonTxt, List btcF public TxValidator validateBsqFeeTx(boolean isMaker) { Optional tx = daoStateService.getTx(txId); - String statusStr = isMaker ? "Maker" : "Taker" + " tx validation"; + String statusStr = (isMaker ? "Maker" : "Taker") + " tx validation"; if (tx.isEmpty()) { - log.info("DAO does not yet have the tx {}, bypassing check of burnt BSQ amount.", txId); - return endResult(statusStr, true); + long txAge = this.chainHeight - this.feePaymentBlockHeight; + if (txAge > 48) { + // still unconfirmed after 8 hours grace period we assume there may be SPV wallet issue. + // see github.com/bisq-network/bisq/issues/6603 + statusStr = String.format("BSQ tx %s not found, age=%d: FAIL.", txId, txAge); + log.warn(statusStr); + return endResult(statusStr, false); + } else { + log.info("DAO does not yet have the tx {} (age={}), bypassing check of burnt BSQ amount.", txId, txAge); + return endResult(statusStr, true); + } } else { return endResult(statusStr, checkFeeAmountBSQ(tx.get(), amount, isMaker, feePaymentBlockHeight)); }