]> git.bitcoin.ninja Git - ldk-java/blob - src/main/java/org/ldk/structs/KeysInterface.java
Fix race in tests
[ldk-java] / src / main / java / org / ldk / structs / KeysInterface.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7
8 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
9 public class KeysInterface extends CommonBase {
10         final bindings.LDKKeysInterface bindings_instance;
11         KeysInterface(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
12         private KeysInterface(bindings.LDKKeysInterface arg) {
13                 super(bindings.LDKKeysInterface_new(arg));
14                 this.ptrs_to.add(arg);
15                 this.bindings_instance = arg;
16         }
17         @Override @SuppressWarnings("deprecation")
18         protected void finalize() throws Throwable {
19                 if (ptr != 0) { bindings.KeysInterface_free(ptr); } super.finalize();
20         }
21
22         public static interface KeysInterfaceInterface {
23                 byte[] get_node_secret();
24                 byte[] get_destination_script();
25                 byte[] get_shutdown_pubkey();
26                 ChannelKeys get_channel_keys(boolean inbound, long channel_value_satoshis);
27                 byte[] get_secure_random_bytes();
28         }
29         private static class LDKKeysInterfaceHolder { KeysInterface held; }
30         public static KeysInterface new_impl(KeysInterfaceInterface arg) {
31                 final LDKKeysInterfaceHolder impl_holder = new LDKKeysInterfaceHolder();
32                 impl_holder.held = new KeysInterface(new bindings.LDKKeysInterface() {
33                         @Override public byte[] get_node_secret() {
34                                 byte[] ret = arg.get_node_secret();
35                                 return ret;
36                         }
37                         @Override public byte[] get_destination_script() {
38                                 byte[] ret = arg.get_destination_script();
39                                 return ret;
40                         }
41                         @Override public byte[] get_shutdown_pubkey() {
42                                 byte[] ret = arg.get_shutdown_pubkey();
43                                 return ret;
44                         }
45                         @Override public long get_channel_keys(boolean inbound, long channel_value_satoshis) {
46                                 ChannelKeys ret = arg.get_channel_keys(inbound, channel_value_satoshis);
47                                 long result = ret == null ? 0 : ret.ptr;
48                                 impl_holder.held.ptrs_to.add(ret);
49                                 return result;
50                         }
51                         @Override public byte[] get_secure_random_bytes() {
52                                 byte[] ret = arg.get_secure_random_bytes();
53                                 return ret;
54                         }
55                 });
56                 return impl_holder.held;
57         }
58         public byte[] get_node_secret() {
59                 byte[] ret = bindings.KeysInterface_get_node_secret(this.ptr);
60                 return ret;
61         }
62
63         public byte[] get_destination_script() {
64                 byte[] ret = bindings.KeysInterface_get_destination_script(this.ptr);
65                 return ret;
66         }
67
68         public byte[] get_shutdown_pubkey() {
69                 byte[] ret = bindings.KeysInterface_get_shutdown_pubkey(this.ptr);
70                 return ret;
71         }
72
73         public ChannelKeys get_channel_keys(boolean inbound, long channel_value_satoshis) {
74                 long ret = bindings.KeysInterface_get_channel_keys(this.ptr, inbound, channel_value_satoshis);
75                 ChannelKeys ret_hu_conv = new ChannelKeys(null, ret);
76                 ret_hu_conv.ptrs_to.add(this);
77                 return ret_hu_conv;
78         }
79
80         public byte[] get_secure_random_bytes() {
81                 byte[] ret = bindings.KeysInterface_get_secure_random_bytes(this.ptr);
82                 return ret;
83         }
84
85 }