fix commit

This commit is contained in:
Zach
2026-02-01 16:57:17 -07:00
parent 0374f4f5da
commit 79ffc21bd6
23 changed files with 2211 additions and 1831 deletions
+11 -2
View File
@@ -104,9 +104,18 @@ class BufferWriter {
}
void writeHex(String hex) {
// Validate hex string length is even and not empty
if (hex.isEmpty || hex.length % 2 != 0) {
throw FormatException('Invalid hex string length: ${hex.length}');
}
List<int> result = [];
for (int i = 0; i < hex.length ~/ 2; i++) {
result.add(int.parse(hex.substring(i * 2, i * 2 + 2), radix: 16));
final hexByte = hex.substring(i * 2, i * 2 + 2);
final byte = int.tryParse(hexByte, radix: 16);
if (byte == null) {
throw FormatException('Invalid hex characters at position $i: $hexByte');
}
result.add(byte);
}
writeBytes(Uint8List.fromList(result));
}
@@ -764,4 +773,4 @@ Uint8List buildZeroHopContact(Uint8List pubKey) {
writer.writeByte(cmdShareContact);
writer.writeBytes(pubKey);
return writer.toBytes();
}
}