Fixed NPE in isMetadataEqual()

This commit is contained in:
CalDescent 2023-03-31 18:41:58 +01:00
parent f6914821d3
commit d831972005

View File

@ -305,6 +305,9 @@ public class ArbitraryDataTransactionBuilder {
} }
private boolean isMetadataEqual(ArbitraryDataTransactionMetadata existingMetadata) { private boolean isMetadataEqual(ArbitraryDataTransactionMetadata existingMetadata) {
if (existingMetadata == null) {
return !this.hasMetadata();
}
if (!Objects.equals(existingMetadata.getTitle(), this.title)) { if (!Objects.equals(existingMetadata.getTitle(), this.title)) {
return false; return false;
} }
@ -320,6 +323,10 @@ public class ArbitraryDataTransactionBuilder {
return true; return true;
} }
private boolean hasMetadata() {
return (this.title != null || this.description != null || this.category != null || this.tags != null);
}
public void computeNonce() throws DataException { public void computeNonce() throws DataException {
if (this.arbitraryTransactionData == null) { if (this.arbitraryTransactionData == null) {
throw new DataException("Arbitrary transaction data is required to compute nonce"); throw new DataException("Arbitrary transaction data is required to compute nonce");