From 92c57d276c934d43d981b461479585d0afd1eb3e Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 4 Aug 2025 13:37:41 +0200 Subject: [PATCH] fix serialization issue affecting single byte witness elements with a value of zero --- .../drongo/protocol/TransactionWitness.java | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/sparrowwallet/drongo/protocol/TransactionWitness.java b/src/main/java/com/sparrowwallet/drongo/protocol/TransactionWitness.java index f5cad4d..6bf2d5e 100644 --- a/src/main/java/com/sparrowwallet/drongo/protocol/TransactionWitness.java +++ b/src/main/java/com/sparrowwallet/drongo/protocol/TransactionWitness.java @@ -89,12 +89,8 @@ public class TransactionWitness extends ChildMessage { int length = new VarInt(pushes.size()).getSizeInBytes(); for (int i = 0; i < pushes.size(); i++) { byte[] push = pushes.get(i); - if(push.length == 1 && push[0] == 0) { - length++; - } else { - length += new VarInt(push.length).getSizeInBytes(); - length += push.length; - } + length += new VarInt(push.length).getSizeInBytes(); + length += push.length; } return length; @@ -104,12 +100,8 @@ public class TransactionWitness extends ChildMessage { stream.write(new VarInt(pushes.size()).encode()); for(int i = 0; i < pushes.size(); i++) { byte[] push = pushes.get(i); - if(push.length == 1 && push[0] == 0) { - stream.write(push); - } else { - stream.write(new VarInt(push.length).encode()); - stream.write(push); - } + stream.write(new VarInt(push.length).encode()); + stream.write(push); } }