Handle NPE when checking isSignWitnessTrade.

This commit is contained in:
jmacxx 2023-09-01 08:41:37 -05:00
parent 9813ae7574
commit e082eb1c86
No known key found for this signature in database
GPG Key ID: 155297BABFE94A1B

View File

@ -930,17 +930,21 @@ public class AccountAgeWitnessService {
} }
public boolean isSignWitnessTrade(Trade trade) { public boolean isSignWitnessTrade(Trade trade) {
checkNotNull(trade, "trade must not be null"); try {
checkNotNull(trade.getOffer(), "offer must not be null"); checkNotNull(trade, "trade must not be null");
Contract contract = checkNotNull(trade.getContract()); checkNotNull(trade.getOffer(), "offer must not be null");
PaymentAccountPayload sellerPaymentAccountPayload = contract.getSellerPaymentAccountPayload(); Contract contract = checkNotNull(trade.getContract());
AccountAgeWitness myWitness = getMyWitness(sellerPaymentAccountPayload); PaymentAccountPayload sellerPaymentAccountPayload = checkNotNull(
contract.getSellerPaymentAccountPayload(), "paymentAccountPayload must not be null");
getAccountAgeWitnessUtils().witnessDebugLog(trade, myWitness); AccountAgeWitness myWitness = getMyWitness(sellerPaymentAccountPayload);
getAccountAgeWitnessUtils().witnessDebugLog(trade, myWitness);
return accountIsSigner(myWitness) && return accountIsSigner(myWitness) &&
!peerHasSignedWitness(trade) && !peerHasSignedWitness(trade) &&
tradeAmountIsSufficient(trade.getAmount()); tradeAmountIsSufficient(trade.getAmount());
} catch (NullPointerException e) {
e.printStackTrace();
}
return false;
} }
public String getSignInfoFromAccount(PaymentAccount paymentAccount) { public String getSignInfoFromAccount(PaymentAccount paymentAccount) {