From e082eb1c86528a19073da407bee283471db916bc Mon Sep 17 00:00:00 2001 From: jmacxx <47253594+jmacxx@users.noreply.github.com> Date: Fri, 1 Sep 2023 08:41:37 -0500 Subject: [PATCH] Handle NPE when checking isSignWitnessTrade. --- .../witness/AccountAgeWitnessService.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/bisq/core/account/witness/AccountAgeWitnessService.java b/core/src/main/java/bisq/core/account/witness/AccountAgeWitnessService.java index bbd5a38a189..9da1d63b5a1 100644 --- a/core/src/main/java/bisq/core/account/witness/AccountAgeWitnessService.java +++ b/core/src/main/java/bisq/core/account/witness/AccountAgeWitnessService.java @@ -930,17 +930,21 @@ public Set getUnsignedSignerPubKeys() { } public boolean isSignWitnessTrade(Trade trade) { - checkNotNull(trade, "trade must not be null"); - checkNotNull(trade.getOffer(), "offer must not be null"); - Contract contract = checkNotNull(trade.getContract()); - PaymentAccountPayload sellerPaymentAccountPayload = contract.getSellerPaymentAccountPayload(); - AccountAgeWitness myWitness = getMyWitness(sellerPaymentAccountPayload); - - getAccountAgeWitnessUtils().witnessDebugLog(trade, myWitness); - - return accountIsSigner(myWitness) && - !peerHasSignedWitness(trade) && - tradeAmountIsSufficient(trade.getAmount()); + try { + checkNotNull(trade, "trade must not be null"); + checkNotNull(trade.getOffer(), "offer must not be null"); + Contract contract = checkNotNull(trade.getContract()); + PaymentAccountPayload sellerPaymentAccountPayload = checkNotNull( + contract.getSellerPaymentAccountPayload(), "paymentAccountPayload must not be null"); + AccountAgeWitness myWitness = getMyWitness(sellerPaymentAccountPayload); + getAccountAgeWitnessUtils().witnessDebugLog(trade, myWitness); + return accountIsSigner(myWitness) && + !peerHasSignedWitness(trade) && + tradeAmountIsSufficient(trade.getAmount()); + } catch (NullPointerException e) { + e.printStackTrace(); + } + return false; } public String getSignInfoFromAccount(PaymentAccount paymentAccount) {