From: Matt Corallo Date: Thu, 3 Mar 2022 02:29:17 +0000 (+0000) Subject: [Java] Handle UInt5 array conversion X-Git-Tag: v0.0.105.0~1^2~8 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=a79aeab27e2bb2bcca0f262e6c02b4528d9ac5de;p=ldk-java [Java] Handle UInt5 array conversion --- diff --git a/java_strings.py b/java_strings.py index 2fcf836d..cc1a3617 100644 --- a/java_strings.py +++ b/java_strings.py @@ -630,6 +630,8 @@ import javax.annotation.Nullable; return arr_name + " != null ? Arrays.stream(" + arr_name + ").mapToLong(" + conv_name + " -> " + elem_ty.from_hu_conv[0] + ").toArray() : null" elif elem_ty.java_ty == "long": return arr_name + " != null ? Arrays.stream(" + arr_name + ").map(" + conv_name + " -> " + elem_ty.from_hu_conv[0] + ").toArray() : null" + elif elem_ty.java_hu_ty == "UInt5": + return arr_name + " != null ? InternalUtils.convUInt5Array(" + arr_name + ") : null" else: return arr_name + " != null ? Arrays.stream(" + arr_name + ").map(" + conv_name + " -> " + elem_ty.from_hu_conv[0] + ").toArray(" + arr_ty.java_ty + "::new) : null" diff --git a/src/main/java/org/ldk/util/InternalUtils.java b/src/main/java/org/ldk/util/InternalUtils.java index 692639d4..f26c2ae0 100644 --- a/src/main/java/org/ldk/util/InternalUtils.java +++ b/src/main/java/org/ldk/util/InternalUtils.java @@ -7,4 +7,12 @@ public class InternalUtils { } return arr; } + + public static byte[] convUInt5Array(UInt5[] u5s) { + byte[] res = new byte[u5s.length]; + for (int i = 0; i < u5s.length; i++) { + res[i] = u5s[i].getVal(); + } + return res; + } }