mirror of
https://github.com/sparrowwallet/drongo.git
synced 2025-11-05 11:56:38 +00:00
fix serialization issue affecting single byte witness elements with a value of zero
This commit is contained in:
parent
0ce32e4314
commit
92c57d276c
1 changed files with 4 additions and 12 deletions
|
|
@ -89,13 +89,9 @@ public class TransactionWitness extends ChildMessage {
|
||||||
int length = new VarInt(pushes.size()).getSizeInBytes();
|
int length = new VarInt(pushes.size()).getSizeInBytes();
|
||||||
for (int i = 0; i < pushes.size(); i++) {
|
for (int i = 0; i < pushes.size(); i++) {
|
||||||
byte[] push = pushes.get(i);
|
byte[] push = pushes.get(i);
|
||||||
if(push.length == 1 && push[0] == 0) {
|
|
||||||
length++;
|
|
||||||
} else {
|
|
||||||
length += new VarInt(push.length).getSizeInBytes();
|
length += new VarInt(push.length).getSizeInBytes();
|
||||||
length += push.length;
|
length += push.length;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
@ -104,14 +100,10 @@ public class TransactionWitness extends ChildMessage {
|
||||||
stream.write(new VarInt(pushes.size()).encode());
|
stream.write(new VarInt(pushes.size()).encode());
|
||||||
for(int i = 0; i < pushes.size(); i++) {
|
for(int i = 0; i < pushes.size(); i++) {
|
||||||
byte[] push = pushes.get(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(new VarInt(push.length).encode());
|
||||||
stream.write(push);
|
stream.write(push);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] toByteArray() {
|
public byte[] toByteArray() {
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue