Skip to content

Commit 8c0814b

Browse files
authored
Merge pull request #47 from TheBlueMatt/main
v0.0.101.2
2 parents 7aa095f + 98e602f commit 8c0814b

File tree

295 files changed

+60
-634
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

295 files changed

+60
-634
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ src/main/java/org/ldk/impl/version.java
77
src/main/jni/version.c
88
ts/version.ts
99
ts/version.c
10+
**/*.class

android-build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ ls ldk-java-classes.jar
5757
rm -rf aar
5858
mkdir aar
5959
cp -r "$3/"* ./aar/
60-
mkdir -p ./aar/jni/{arm64,armeabi,x86,x86_64}
60+
mkdir -p ./aar/jni/{armeabi-v7a,arm64-v8a,x86,x86_64}
6161

62-
cp liblightningjni_release_aarch64-linux-android.so ./aar/jni/arm64/liblightningjni.so
63-
cp liblightningjni_release_armv7-linux-androideabi.so ./aar/jni/armeabi/liblightningjni.so
62+
cp liblightningjni_release_aarch64-linux-android.so ./aar/jni/arm64-v8a/liblightningjni.so
63+
cp liblightningjni_release_armv7-linux-androideabi.so ./aar/jni/armeabi-v7a/liblightningjni.so
6464
cp liblightningjni_release_i686-linux-android.so ./aar/jni/x86/liblightningjni.so
6565
cp liblightningjni_release_x86_64-linux-android.so ./aar/jni/x86_64/liblightningjni.so
6666
cp ldk-java-classes.jar ./aar/classes.jar

gen_type_mapping.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ def map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, holds_re
240240
if (ty_info.rust_obj.replace("LDK", "") + "_clone") in self.clone_fns:
241241
# TODO: This is a bit too naive, even with the checks above, we really need to know if rust wants a ref or not, not just if its pass as a ptr.
242242
opaque_arg_conv = opaque_arg_conv + "\n" + ty_info.var_name + "_conv = " + ty_info.rust_obj.replace("LDK", "") + "_clone(&" + ty_info.var_name + "_conv);"
243+
from_hu_conv = (from_hu_conv[0], "")
243244
elif ty_info.passed_as_ptr:
244245
opaque_arg_conv = opaque_arg_conv + "\n// Warning: we need a move here but no clone is available for " + ty_info.rust_obj
245246
# TODO: Once we support features cloning (which just isn't in C yet), we can make this a compile error instead!
@@ -422,17 +423,19 @@ def map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, holds_re
422423
assert(not is_free)
423424
if ty_info.rust_obj in self.complex_enums:
424425
ret_conv = ("uint64_t ret_" + ty_info.var_name + " = (uint64_t)", " | 1; // Warning: We should clone here!")
426+
from_hu_sfx = "this.ptrs_to.add(" + ty_info.var_name + ")"
425427
if ty_info.rust_obj.replace("LDK", "") + "_clone" in self.clone_fns:
426428
ret_conv_pfx = ty_info.rust_obj + " *ret_" + ty_info.var_name + " = MALLOC(sizeof(" + ty_info.rust_obj + "), \"" + ty_info.rust_obj + " ret conversion\");\n"
427429
ret_conv_pfx += "*ret_" + ty_info.var_name + " = " + ty_info.rust_obj.replace("LDK", "") + "_clone("
428430
ret_conv = (ret_conv_pfx, ");")
431+
from_hu_sfx = ""
429432
return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
430433
arg_conv = ty_info.rust_obj + "* " + ty_info.var_name + "_conv = (" + ty_info.rust_obj + "*)" + ty_info.var_name + ";",
431434
arg_conv_name = ty_info.var_name + "_conv", arg_conv_cleanup = None,
432435
ret_conv = ret_conv, ret_conv_name = "(uint64_t)ret_" + ty_info.var_name,
433436
to_hu_conv = ty_info.java_hu_ty + " " + ty_info.var_name + "_hu_conv = " + ty_info.java_hu_ty + ".constr_from_ptr(" + ty_info.var_name + ");",
434437
to_hu_conv_name = ty_info.var_name + "_hu_conv",
435-
from_hu_conv = (ty_info.var_name + " == null ? 0 : " + ty_info.var_name + ".ptr & ~1", "this.ptrs_to.add(" + ty_info.var_name + ")"))
438+
from_hu_conv = (ty_info.var_name + " == null ? 0 : " + ty_info.var_name + ".ptr & ~1", from_hu_sfx))
436439
elif ty_info.rust_obj in self.trait_structs:
437440
if ty_info.nonnull_ptr:
438441
arg_conv = ty_info.rust_obj + "* " + ty_info.var_name + "_conv = (" + ty_info.rust_obj + "*)(((uint64_t)" + ty_info.var_name + ") & ~1);"
@@ -457,7 +460,7 @@ def map_type_with_info(self, ty_info, print_void, ret_arr_len, is_free, holds_re
457460
ret_conv_name = "(uint64_t)" + ty_info.var_name + "_clone",
458461
to_hu_conv = ty_info.java_hu_ty + " ret_hu_conv = new " + ty_info.java_hu_ty + "(null, " + ty_info.var_name + ");\nret_hu_conv.ptrs_to.add(this);",
459462
to_hu_conv_name = "ret_hu_conv",
460-
from_hu_conv = (ty_info.var_name + " == null ? 0 : " + ty_info.var_name + ".ptr", "this.ptrs_to.add(" + ty_info.var_name + ")"))
463+
from_hu_conv = (ty_info.var_name + " == null ? 0 : " + ty_info.var_name + ".ptr", ""))
461464
else:
462465
return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
463466
arg_conv = arg_conv, arg_conv_name = arg_conv_name, arg_conv_cleanup = None,

src/main/java/org/ldk/batteries/NioPeerHandler.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import org.ldk.structs.*;
44

55
import java.io.IOException;
6+
import java.util.LinkedList;
67
import java.net.SocketAddress;
78
import java.net.StandardSocketOptions;
89
import java.nio.Buffer;
@@ -239,6 +240,11 @@ public void disconnect(byte[] their_node_id) {
239240
this.peer_manager.disconnect_by_node_id(their_node_id, false);
240241
}
241242

243+
/**
244+
* Before shutdown, we have to ensure all of our listening sockets are closed manually, as they appear
245+
* to otherwise remain open and lying around on OSX (though no other platform).
246+
*/
247+
private LinkedList<ServerSocketChannel> listening_sockets = new LinkedList();
242248
/**
243249
* Binds a listening socket to the given address, accepting incoming connections and handling them on the background
244250
* thread.
@@ -248,9 +254,13 @@ public void disconnect(byte[] their_node_id) {
248254
*/
249255
public void bind_listener(SocketAddress socket_address) throws IOException {
250256
ServerSocketChannel listen_channel = ServerSocketChannel.open();
257+
listen_channel.setOption(StandardSocketOptions.SO_REUSEADDR, true);
251258
listen_channel.bind(socket_address);
252259
listen_channel.configureBlocking(false);
253260
do_selector_action(() -> listen_channel.register(this.selector, SelectionKey.OP_ACCEPT));
261+
synchronized(listening_sockets) {
262+
listening_sockets.add(listen_channel);
263+
}
254264
}
255265

256266
/**
@@ -263,6 +273,14 @@ public void interrupt() {
263273
try {
264274
io_thread.join();
265275
} catch (InterruptedException ignored) { }
276+
synchronized(listening_sockets) {
277+
try {
278+
selector.close();
279+
for (ServerSocketChannel chan : listening_sockets) {
280+
chan.close();
281+
}
282+
} catch (IOException ignored) {}
283+
}
266284
}
267285

268286
/**
-313 Bytes
Binary file not shown.

src/main/java/org/ldk/structs/APIError.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ public static APIError incompatible_shutdown_script(ShutdownScript script) {
179179
if (ret < 1024) { return null; }
180180
APIError ret_hu_conv = APIError.constr_from_ptr(ret);
181181
ret_hu_conv.ptrs_to.add(ret_hu_conv);
182-
ret_hu_conv.ptrs_to.add(script);
183182
return ret_hu_conv;
184183
}
185184

src/main/java/org/ldk/structs/Balance.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ public static Balance maybe_claimable_htlcawaiting_timeout(long claimable_amount
161161
*/
162162
public boolean eq(Balance b) {
163163
boolean ret = bindings.Balance_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
164-
this.ptrs_to.add(b);
165164
return ret;
166165
}
167166

src/main/java/org/ldk/structs/BaseSign.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public class BaseSign extends CommonBase {
3232
private BaseSign(bindings.LDKBaseSign arg, ChannelPublicKeys pubkeys) {
3333
super(bindings.LDKBaseSign_new(arg, pubkeys == null ? 0 : pubkeys.ptr & ~1));
3434
this.ptrs_to.add(arg);
35-
this.ptrs_to.add(pubkeys);
3635
this.bindings_instance = arg;
3736
}
3837
@Override @SuppressWarnings("deprecation")

src/main/java/org/ldk/structs/ChainMonitor.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ public Balance[] get_claimable_balances(ChannelDetails[] ignored_channels) {
6868
ret_conv_9_hu_conv.ptrs_to.add(this);
6969
ret_conv_9_arr[j] = ret_conv_9_hu_conv;
7070
}
71-
for (ChannelDetails ignored_channels_conv_16: ignored_channels) { this.ptrs_to.add(ignored_channels_conv_16); };
7271
return ret_conv_9_arr;
7372
}
7473

src/main/java/org/ldk/structs/ChainParameters.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public BestBlock get_best_block() {
5858
*/
5959
public void set_best_block(BestBlock val) {
6060
bindings.ChainParameters_set_best_block(this.ptr, val == null ? 0 : val.ptr & ~1);
61-
this.ptrs_to.add(val);
6261
}
6362

6463
/**
@@ -69,7 +68,6 @@ public static ChainParameters of(org.ldk.enums.Network network_arg, BestBlock be
6968
if (ret < 1024) { return null; }
7069
ChainParameters ret_hu_conv = new ChainParameters(null, ret);
7170
ret_hu_conv.ptrs_to.add(ret_hu_conv);
72-
ret_hu_conv.ptrs_to.add(best_block_arg);
7371
return ret_hu_conv;
7472
}
7573

0 commit comments

Comments
 (0)