From 2b2bc0ce17050c51c274f11438e29924726c2273 Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Tue, 4 Apr 2023 17:59:24 +0200 Subject: [PATCH] TransactionWitness: require non-null pushes --- .../main/java/org/bitcoinj/core/TransactionWitness.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/bitcoinj/core/TransactionWitness.java b/core/src/main/java/org/bitcoinj/core/TransactionWitness.java index 15925b9e3..b3d780e48 100644 --- a/core/src/main/java/org/bitcoinj/core/TransactionWitness.java +++ b/core/src/main/java/org/bitcoinj/core/TransactionWitness.java @@ -100,6 +100,8 @@ public class TransactionWitness { private final List pushes; private TransactionWitness(List pushes) { + for (byte[] push : pushes) + Objects.requireNonNull(push); this.pushes = pushes; } @@ -151,9 +153,7 @@ public class TransactionWitness { public String toString() { List stringPushes = new ArrayList<>(pushes.size()); for (byte[] push : pushes) { - if (push == null) { - stringPushes.add("NULL"); - } else if (push.length == 0) { + if (push.length == 0) { stringPushes.add("EMPTY"); } else { stringPushes.add(ByteUtils.formatHex(push)); @@ -178,7 +178,7 @@ public class TransactionWitness { public int hashCode() { int hashCode = 1; for (byte[] push : pushes) { - hashCode = 31 * hashCode + (push == null ? 0 : Arrays.hashCode(push)); + hashCode = 31 * hashCode + Arrays.hashCode(push); } return hashCode; }