]> git.bitcoin.ninja Git - ldk-java/commitdiff
Expose human functions that use Result objects
authorMatt Corallo <git@bluematt.me>
Wed, 21 Oct 2020 18:09:56 +0000 (14:09 -0400)
committerMatt Corallo <git@bluematt.me>
Wed, 21 Oct 2020 18:16:37 +0000 (14:16 -0400)
28 files changed:
genbindings.py
src/main/java/org/ldk/structs/Access.java
src/main/java/org/ldk/structs/ChannelKeys.java
src/main/java/org/ldk/structs/ChannelManager.java
src/main/java/org/ldk/structs/ChannelMonitor.java
src/main/java/org/ldk/structs/HolderCommitmentTransaction.java
src/main/java/org/ldk/structs/LightningError.java
src/main/java/org/ldk/structs/PeerManager.java
src/main/java/org/ldk/structs/Result_C2Tuple_SignatureCVec_SignatureZZNoneZ.java
src/main/java/org/ldk/structs/Result_CVec_SignatureZNoneZ.java
src/main/java/org/ldk/structs/Result_CVec_u8ZPeerHandleErrorZ.java
src/main/java/org/ldk/structs/Result_NoneAPIErrorZ.java
src/main/java/org/ldk/structs/Result_NoneChannelMonitorUpdateErrZ.java
src/main/java/org/ldk/structs/Result_NoneMonitorUpdateErrorZ.java
src/main/java/org/ldk/structs/Result_NonePaymentSendFailureZ.java
src/main/java/org/ldk/structs/Result_NonePeerHandleErrorZ.java
src/main/java/org/ldk/structs/Result_PublicKeySecpErrorZ.java
src/main/java/org/ldk/structs/Result_RouteLightningErrorZ.java
src/main/java/org/ldk/structs/Result_SecretKeySecpErrorZ.java
src/main/java/org/ldk/structs/Result_SignatureNoneZ.java
src/main/java/org/ldk/structs/Result_TxCreationKeysSecpErrorZ.java
src/main/java/org/ldk/structs/Result_TxOutAccessErrorZ.java
src/main/java/org/ldk/structs/Result_boolLightningErrorZ.java
src/main/java/org/ldk/structs/Result_boolPeerHandleErrorZ.java
src/main/java/org/ldk/structs/RoutingMessageHandler.java
src/main/java/org/ldk/structs/TxCreationKeys.java
src/main/java/org/ldk/structs/Watch.java
src/test/java/org/ldk/HumanObjectPeerTest.java

index f18b3b2e903fd4fa16c297e66cacafd48fa7b236..b70b0e4839d2ad11ffbb5b1c4d4597be14940c4e 100755 (executable)
@@ -95,6 +95,7 @@ unitary_enums = set()
 complex_enums = set()
 opaque_structs = set()
 trait_structs = set()
+result_types = set()
 tuple_types = {}
 
 var_is_arr_regex = re.compile("\(\*([A-za-z0-9_]*)\)\[([a-z0-9]*)\]")
@@ -303,7 +304,7 @@ def java_c_types(fn_arg, ret_arr_len):
             take_by_ptr = True
         else:
             java_ty = "long"
-            java_hu_ty = ma.group(1).strip().replace("LDK", "")
+            java_hu_ty = ma.group(1).strip().replace("LDKCResult", "Result").replace("LDK", "")
             c_ty = "jlong"
             fn_ty_arg = "J"
             fn_arg = ma.group(2).strip()
@@ -649,6 +650,13 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.arg
                             arg_conv_name = "ret_conv", arg_conv_cleanup = None,
                             ret_conv = ("jclass ret = " + ty_info.rust_obj + "_to_java(_env, ", ");"), ret_conv_name = "ret",
                             to_hu_conv = None, to_hu_conv_name = None, from_hu_conv = None)
+                    if ty_info.rust_obj in complex_enums or ty_info.rust_obj in result_types:
+                        return ConvInfo(ty_info = ty_info, arg_name = ty_info.var_name,
+                            ret_conv = (ty_info.rust_obj + "* ret = MALLOC(sizeof(" + ty_info.rust_obj + "), \"" + ty_info.rust_obj + "\");\n*ret = ", ";"),
+                            ret_conv_name = "(long)ret",
+                            arg_conv = None, arg_conv_name = None, arg_conv_cleanup = None,
+                            to_hu_conv = ty_info.java_hu_ty + " ret_hu_conv = " + ty_info.java_hu_ty + ".constr_from_ptr(ret);\nret_hu_conv.ptrs_to.add(this);",
+                            to_hu_conv_name = "ret_hu_conv", from_hu_conv = (ty_info.var_name + ".conv_to_c()", ""))
                     if ty_info.rust_obj in opaque_structs:
                         # If we're returning a newly-allocated struct, we don't want Rust to ever
                         # free, instead relying on the Java GC to lose the ref. We undo this in
@@ -711,7 +719,7 @@ with open(sys.argv[1]) as in_h, open(sys.argv[2], "w") as out_java, open(sys.arg
         arg_names = []
         default_constructor_args = {}
         takes_self = False
-        args_known = not ret_info.passed_as_ptr or ret_info.rust_obj in opaque_structs or ret_info.rust_obj in trait_structs
+        args_known = not ret_info.passed_as_ptr or ret_info.rust_obj in opaque_structs or ret_info.rust_obj in trait_structs or ret_info.rust_obj in complex_enums or ret_info.rust_obj in result_types
         for idx, arg in enumerate(re_match.group(3).split(',')):
             if idx != 0:
                 out_java.write(", ")
@@ -1706,7 +1714,8 @@ class CommonBase {
                         out_java.write("\tpublic static native " + ty_info.java_ty + " " + alias_match.group(2) + "_get_" + e + "(long ptr);\n")
                         # XXX: Write C method!
                 elif alias_match.group(1) in result_templ_structs:
-                    human_ty = alias_match.group(2).replace("LDKCResult", "Result_").replace("__", "_").replace("Templ", "")
+                    result_types.add(alias_match.group(2))
+                    human_ty = alias_match.group(2).replace("LDKCResult", "Result")
                     with open(sys.argv[3] + "/structs/" + human_ty + ".java", "w") as out_java_struct:
                         out_java_struct.write(hu_struct_file_prefix)
                         out_java_struct.write("public class " + human_ty + " extends CommonBase {\n")
@@ -1714,6 +1723,13 @@ class CommonBase {
                         out_java_struct.write("\tprotected void finalize() throws Throwable {\n")
                         out_java_struct.write("\t\tbindings." + alias_match.group(2).replace("LDK","") + "_free(ptr); super.finalize();\n")
                         out_java_struct.write("\t}\n\n")
+                        out_java_struct.write("\tstatic " + human_ty + " constr_from_ptr(long ptr) {\n")
+                        out_java_struct.write("\t\tif (bindings." + alias_match.group(2) + "_result_ok(ptr)) {\n")
+                        out_java_struct.write("\t\t\treturn new " + human_ty + "_OK(null, ptr);\n")
+                        out_java_struct.write("\t\t} else {\n")
+                        out_java_struct.write("\t\t\treturn new " + human_ty + "_Err(null, ptr);\n")
+                        out_java_struct.write("\t\t}\n")
+                        out_java_struct.write("\t}\n")
 
                         contents_ty = alias_match.group(1).replace("LDKCResultTempl", "LDKCResultPtr")
                         res_ty, err_ty = result_ptr_struct_items[contents_ty]
index febbd35e6b8100156424defbdd9c2ee006dc738c..375dca92159062dd63a1b3a524a322fc97ad3073 100644 (file)
@@ -17,5 +17,11 @@ public class Access extends CommonBase {
                bindings.Access_free(ptr); super.finalize();
        }
 
-       // Skipped Access_get_utxo
+       public Result_TxOutAccessErrorZ get_utxo(byte[] genesis_hash, long short_channel_id) {
+               long ret = bindings.Access_get_utxo(this.ptr, genesis_hash, short_channel_id);
+               Result_TxOutAccessErrorZ ret_hu_conv = Result_TxOutAccessErrorZ.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
 }
index 5b952032aaa5853693684bcc49f5696c9ef0a7fc..9dfce22c111698d86f48c796996e0a1bbc9cc94d 100644 (file)
@@ -29,12 +29,33 @@ public class ChannelKeys extends CommonBase {
 
        // Skipped ChannelKeys_key_derivation_params
        // Skipped ChannelKeys_sign_counterparty_commitment
-       // Skipped ChannelKeys_sign_holder_commitment
-       // Skipped ChannelKeys_sign_holder_commitment_htlc_transactions
+       public Result_SignatureNoneZ sign_holder_commitment(HolderCommitmentTransaction holder_commitment_tx) {
+               long ret = bindings.ChannelKeys_sign_holder_commitment(this.ptr, holder_commitment_tx == null ? 0 : holder_commitment_tx.ptr & ~1);
+               Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(this);
+               this.ptrs_to.add(holder_commitment_tx);
+               return ret_hu_conv;
+       }
+
+       public Result_CVec_SignatureZNoneZ sign_holder_commitment_htlc_transactions(HolderCommitmentTransaction holder_commitment_tx) {
+               long ret = bindings.ChannelKeys_sign_holder_commitment_htlc_transactions(this.ptr, holder_commitment_tx == null ? 0 : holder_commitment_tx.ptr & ~1);
+               Result_CVec_SignatureZNoneZ ret_hu_conv = Result_CVec_SignatureZNoneZ.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(this);
+               this.ptrs_to.add(holder_commitment_tx);
+               return ret_hu_conv;
+       }
+
        // Skipped ChannelKeys_sign_justice_transaction
        // Skipped ChannelKeys_sign_counterparty_htlc_transaction
        // Skipped ChannelKeys_sign_closing_transaction
-       // Skipped ChannelKeys_sign_channel_announcement
+       public Result_SignatureNoneZ sign_channel_announcement(UnsignedChannelAnnouncement msg) {
+               long ret = bindings.ChannelKeys_sign_channel_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1);
+               Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(this);
+               this.ptrs_to.add(msg);
+               return ret_hu_conv;
+       }
+
        public void on_accept(ChannelPublicKeys channel_points, short counterparty_selected_contest_delay, short holder_selected_contest_delay) {
                bindings.ChannelKeys_on_accept(this.ptr, channel_points == null ? 0 : channel_points.ptr & ~1, counterparty_selected_contest_delay, holder_selected_contest_delay);
                this.ptrs_to.add(channel_points);
index beadcad71efe2317f9fa22a72af23e3fb81c1d16..56198363c4804ac1551d6db38989dcceed41b3e3 100644 (file)
@@ -26,7 +26,14 @@ public class ChannelManager extends CommonBase {
                return ret_hu_conv;
        }
 
-       // Skipped ChannelManager_create_channel
+       public Result_NoneAPIErrorZ create_channel(byte[] their_network_key, long channel_value_satoshis, long push_msat, long user_id, UserConfig override_config) {
+               long ret = bindings.ChannelManager_create_channel(this.ptr, their_network_key, channel_value_satoshis, push_msat, user_id, override_config == null ? 0 : override_config.ptr & ~1);
+               Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(this);
+               this.ptrs_to.add(override_config);
+               return ret_hu_conv;
+       }
+
        public ChannelDetails[] list_channels() {
                long[] ret = bindings.ChannelManager_list_channels(this.ptr);
                ChannelDetails[] arr_conv_16_arr = new ChannelDetails[ret.length];
@@ -49,7 +56,13 @@ public class ChannelManager extends CommonBase {
                return arr_conv_16_arr;
        }
 
-       // Skipped ChannelManager_close_channel
+       public Result_NoneAPIErrorZ close_channel(byte[] channel_id) {
+               long ret = bindings.ChannelManager_close_channel(this.ptr, channel_id);
+               Result_NoneAPIErrorZ ret_hu_conv = Result_NoneAPIErrorZ.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
        public void force_close_channel(byte[] channel_id) {
                bindings.ChannelManager_force_close_channel(this.ptr, channel_id);
        }
@@ -58,7 +71,14 @@ public class ChannelManager extends CommonBase {
                bindings.ChannelManager_force_close_all_channels(this.ptr);
        }
 
-       // Skipped ChannelManager_send_payment
+       public Result_NonePaymentSendFailureZ send_payment(Route route, byte[] payment_hash, byte[] payment_secret) {
+               long ret = bindings.ChannelManager_send_payment(this.ptr, route == null ? 0 : route.ptr & ~1, payment_hash, payment_secret);
+               Result_NonePaymentSendFailureZ ret_hu_conv = Result_NonePaymentSendFailureZ.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(this);
+               this.ptrs_to.add(route);
+               return ret_hu_conv;
+       }
+
        public void funding_transaction_generated(byte[] temporary_channel_id, OutPoint funding_txo) {
                bindings.ChannelManager_funding_transaction_generated(this.ptr, temporary_channel_id, funding_txo == null ? 0 : funding_txo.ptr & ~1);
                this.ptrs_to.add(funding_txo);
index ce25311fdb32bdb7aae7c8bd0adbafb91e5a012d..1e95a1b56818f5489adac1eacaab0b17dbed1155 100644 (file)
@@ -14,7 +14,16 @@ public class ChannelMonitor extends CommonBase {
                bindings.ChannelMonitor_free(ptr);
        }
 
-       // Skipped ChannelMonitor_update_monitor
+       public Result_NoneMonitorUpdateErrorZ update_monitor(ChannelMonitorUpdate updates, BroadcasterInterface broadcaster, Logger logger) {
+               long ret = bindings.ChannelMonitor_update_monitor(this.ptr, updates == null ? 0 : updates.ptr & ~1, broadcaster == null ? 0 : broadcaster.ptr, logger == null ? 0 : logger.ptr);
+               Result_NoneMonitorUpdateErrorZ ret_hu_conv = Result_NoneMonitorUpdateErrorZ.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(this);
+               this.ptrs_to.add(updates);
+               this.ptrs_to.add(broadcaster);
+               this.ptrs_to.add(logger);
+               return ret_hu_conv;
+       }
+
        public long get_latest_update_id() {
                long ret = bindings.ChannelMonitor_get_latest_update_id(this.ptr);
                return ret;
index 4dd599a51dfabbba3446e5750dc6e479a61eb7c8..5b26ba423b712674c5e33a1ff4b374a030aa629a 100644 (file)
@@ -63,7 +63,13 @@ public class HolderCommitmentTransaction extends CommonBase {
                return ret;
        }
 
-       // Skipped HolderCommitmentTransaction_get_htlc_sigs
+       public Result_CVec_SignatureZNoneZ get_htlc_sigs(byte[] htlc_base_key, short counterparty_selected_contest_delay) {
+               long ret = bindings.HolderCommitmentTransaction_get_htlc_sigs(this.ptr, htlc_base_key, counterparty_selected_contest_delay);
+               Result_CVec_SignatureZNoneZ ret_hu_conv = Result_CVec_SignatureZNoneZ.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
        public byte[] write(HolderCommitmentTransaction obj) {
                byte[] ret = bindings.HolderCommitmentTransaction_write(obj == null ? 0 : obj.ptr & ~1);
                this.ptrs_to.add(obj);
index be3d75933fe41dab5171dc2ca043854298a3525b..b82c5711c3f26cdbfb55bdad0fc7e60483f41343 100644 (file)
@@ -23,7 +23,13 @@ public class LightningError extends CommonBase {
                bindings.LightningError_set_err(this.ptr, val);
        }
 
-       // Skipped LightningError_get_action
+       public ErrorAction get_action() {
+               long ret = bindings.LightningError_get_action(this.ptr);
+               ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
        // Skipped LightningError_set_action
        // Skipped LightningError_new
 }
index 0a542cd3b2b00dd9ab0a5ed7ef1f4d4359449445..93837b5e26378f1ecf14a24784c86187eb7924f3 100644 (file)
@@ -28,10 +28,38 @@ public class PeerManager extends CommonBase {
                return ret;
        }
 
-       // Skipped PeerManager_new_outbound_connection
-       // Skipped PeerManager_new_inbound_connection
-       // Skipped PeerManager_write_buffer_space_avail
-       // Skipped PeerManager_read_event
+       public Result_CVec_u8ZPeerHandleErrorZ new_outbound_connection(byte[] their_node_id, SocketDescriptor descriptor) {
+               long ret = bindings.PeerManager_new_outbound_connection(this.ptr, their_node_id, descriptor == null ? 0 : descriptor.ptr);
+               Result_CVec_u8ZPeerHandleErrorZ ret_hu_conv = Result_CVec_u8ZPeerHandleErrorZ.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(this);
+               this.ptrs_to.add(descriptor);
+               return ret_hu_conv;
+       }
+
+       public Result_NonePeerHandleErrorZ new_inbound_connection(SocketDescriptor descriptor) {
+               long ret = bindings.PeerManager_new_inbound_connection(this.ptr, descriptor == null ? 0 : descriptor.ptr);
+               Result_NonePeerHandleErrorZ ret_hu_conv = Result_NonePeerHandleErrorZ.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(this);
+               this.ptrs_to.add(descriptor);
+               return ret_hu_conv;
+       }
+
+       public Result_NonePeerHandleErrorZ write_buffer_space_avail(SocketDescriptor descriptor) {
+               long ret = bindings.PeerManager_write_buffer_space_avail(this.ptr, descriptor == null ? 0 : descriptor.ptr);
+               Result_NonePeerHandleErrorZ ret_hu_conv = Result_NonePeerHandleErrorZ.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(this);
+               this.ptrs_to.add(descriptor);
+               return ret_hu_conv;
+       }
+
+       public Result_boolPeerHandleErrorZ read_event(SocketDescriptor peer_descriptor, byte[] data) {
+               long ret = bindings.PeerManager_read_event(this.ptr, peer_descriptor == null ? 0 : peer_descriptor.ptr, data);
+               Result_boolPeerHandleErrorZ ret_hu_conv = Result_boolPeerHandleErrorZ.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(this);
+               this.ptrs_to.add(peer_descriptor);
+               return ret_hu_conv;
+       }
+
        public void process_events() {
                bindings.PeerManager_process_events(this.ptr);
        }
index 328451c49e6685616d1f134726b930c6d6d4edf2..8fbfa3861c0450243171ccbcbf25caeb8ca5c147 100644 (file)
@@ -12,6 +12,13 @@ public class Result_C2Tuple_SignatureCVec_SignatureZZNoneZ extends CommonBase {
                bindings.CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(ptr); super.finalize();
        }
 
+       static Result_C2Tuple_SignatureCVec_SignatureZZNoneZ constr_from_ptr(long ptr) {
+               if (bindings.LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_result_ok(ptr)) {
+                       return new Result_C2Tuple_SignatureCVec_SignatureZZNoneZ_OK(null, ptr);
+               } else {
+                       return new Result_C2Tuple_SignatureCVec_SignatureZZNoneZ_Err(null, ptr);
+               }
+       }
        public static final class Result_C2Tuple_SignatureCVec_SignatureZZNoneZ_OK extends Result_C2Tuple_SignatureCVec_SignatureZZNoneZ {
                public TwoTuple<byte[], byte[][]> res;
                private Result_C2Tuple_SignatureCVec_SignatureZZNoneZ_OK(Object _dummy, long ptr) {
index 3f9e4918e20e05de6784b2c92b238e1a4258ec1a..1d709cf165a7d0d84a5f69a4cfba936efd0474ab 100644 (file)
@@ -12,6 +12,13 @@ public class Result_CVec_SignatureZNoneZ extends CommonBase {
                bindings.CResult_CVec_SignatureZNoneZ_free(ptr); super.finalize();
        }
 
+       static Result_CVec_SignatureZNoneZ constr_from_ptr(long ptr) {
+               if (bindings.LDKCResult_CVec_SignatureZNoneZ_result_ok(ptr)) {
+                       return new Result_CVec_SignatureZNoneZ_OK(null, ptr);
+               } else {
+                       return new Result_CVec_SignatureZNoneZ_Err(null, ptr);
+               }
+       }
        public static final class Result_CVec_SignatureZNoneZ_OK extends Result_CVec_SignatureZNoneZ {
                public byte[][] res;
                private Result_CVec_SignatureZNoneZ_OK(Object _dummy, long ptr) {
index e9df1bc4fd26817108ba58230ae297819a23c692..490b7afc8dc7378b9724c70e393fe86f80f6c9cb 100644 (file)
@@ -12,6 +12,13 @@ public class Result_CVec_u8ZPeerHandleErrorZ extends CommonBase {
                bindings.CResult_CVec_u8ZPeerHandleErrorZ_free(ptr); super.finalize();
        }
 
+       static Result_CVec_u8ZPeerHandleErrorZ constr_from_ptr(long ptr) {
+               if (bindings.LDKCResult_CVec_u8ZPeerHandleErrorZ_result_ok(ptr)) {
+                       return new Result_CVec_u8ZPeerHandleErrorZ_OK(null, ptr);
+               } else {
+                       return new Result_CVec_u8ZPeerHandleErrorZ_Err(null, ptr);
+               }
+       }
        public static final class Result_CVec_u8ZPeerHandleErrorZ_OK extends Result_CVec_u8ZPeerHandleErrorZ {
                public byte[] res;
                private Result_CVec_u8ZPeerHandleErrorZ_OK(Object _dummy, long ptr) {
index 21f66dd4fd903f5e3317e71b87424df4ae6610f6..5935b6477c56519e38e274101c97eec39311410e 100644 (file)
@@ -12,6 +12,13 @@ public class Result_NoneAPIErrorZ extends CommonBase {
                bindings.CResult_NoneAPIErrorZ_free(ptr); super.finalize();
        }
 
+       static Result_NoneAPIErrorZ constr_from_ptr(long ptr) {
+               if (bindings.LDKCResult_NoneAPIErrorZ_result_ok(ptr)) {
+                       return new Result_NoneAPIErrorZ_OK(null, ptr);
+               } else {
+                       return new Result_NoneAPIErrorZ_Err(null, ptr);
+               }
+       }
        public static final class Result_NoneAPIErrorZ_OK extends Result_NoneAPIErrorZ {
                public byte res;
                private Result_NoneAPIErrorZ_OK(Object _dummy, long ptr) {
index d1f26e93af699a55b10920893c069013d9ea6abe..3c18a0bfc381d61f92cb831f4ebb54c45dd9284a 100644 (file)
@@ -12,6 +12,13 @@ public class Result_NoneChannelMonitorUpdateErrZ extends CommonBase {
                bindings.CResult_NoneChannelMonitorUpdateErrZ_free(ptr); super.finalize();
        }
 
+       static Result_NoneChannelMonitorUpdateErrZ constr_from_ptr(long ptr) {
+               if (bindings.LDKCResult_NoneChannelMonitorUpdateErrZ_result_ok(ptr)) {
+                       return new Result_NoneChannelMonitorUpdateErrZ_OK(null, ptr);
+               } else {
+                       return new Result_NoneChannelMonitorUpdateErrZ_Err(null, ptr);
+               }
+       }
        public static final class Result_NoneChannelMonitorUpdateErrZ_OK extends Result_NoneChannelMonitorUpdateErrZ {
                public byte res;
                private Result_NoneChannelMonitorUpdateErrZ_OK(Object _dummy, long ptr) {
index 2e063dc781fe1ef554f7467376a7e61925e31d4d..c071d7b08a7d73fe09f064ebcafd40abaa0000fd 100644 (file)
@@ -12,6 +12,13 @@ public class Result_NoneMonitorUpdateErrorZ extends CommonBase {
                bindings.CResult_NoneMonitorUpdateErrorZ_free(ptr); super.finalize();
        }
 
+       static Result_NoneMonitorUpdateErrorZ constr_from_ptr(long ptr) {
+               if (bindings.LDKCResult_NoneMonitorUpdateErrorZ_result_ok(ptr)) {
+                       return new Result_NoneMonitorUpdateErrorZ_OK(null, ptr);
+               } else {
+                       return new Result_NoneMonitorUpdateErrorZ_Err(null, ptr);
+               }
+       }
        public static final class Result_NoneMonitorUpdateErrorZ_OK extends Result_NoneMonitorUpdateErrorZ {
                public byte res;
                private Result_NoneMonitorUpdateErrorZ_OK(Object _dummy, long ptr) {
index 9b011510feb36e81e3916a8e4c68855b9171fd8f..b9496fd023a0080fc751cfe60e819af217ab2233 100644 (file)
@@ -12,6 +12,13 @@ public class Result_NonePaymentSendFailureZ extends CommonBase {
                bindings.CResult_NonePaymentSendFailureZ_free(ptr); super.finalize();
        }
 
+       static Result_NonePaymentSendFailureZ constr_from_ptr(long ptr) {
+               if (bindings.LDKCResult_NonePaymentSendFailureZ_result_ok(ptr)) {
+                       return new Result_NonePaymentSendFailureZ_OK(null, ptr);
+               } else {
+                       return new Result_NonePaymentSendFailureZ_Err(null, ptr);
+               }
+       }
        public static final class Result_NonePaymentSendFailureZ_OK extends Result_NonePaymentSendFailureZ {
                public byte res;
                private Result_NonePaymentSendFailureZ_OK(Object _dummy, long ptr) {
index 6bbcd9692f3b138dc411932405f9544738770b90..385e571b5dd03c83fc6b250d9688953f85b36e61 100644 (file)
@@ -12,6 +12,13 @@ public class Result_NonePeerHandleErrorZ extends CommonBase {
                bindings.CResult_NonePeerHandleErrorZ_free(ptr); super.finalize();
        }
 
+       static Result_NonePeerHandleErrorZ constr_from_ptr(long ptr) {
+               if (bindings.LDKCResult_NonePeerHandleErrorZ_result_ok(ptr)) {
+                       return new Result_NonePeerHandleErrorZ_OK(null, ptr);
+               } else {
+                       return new Result_NonePeerHandleErrorZ_Err(null, ptr);
+               }
+       }
        public static final class Result_NonePeerHandleErrorZ_OK extends Result_NonePeerHandleErrorZ {
                public byte res;
                private Result_NonePeerHandleErrorZ_OK(Object _dummy, long ptr) {
index 39dd8247d74defbf4e743130268d967de4e80806..0f0bcc31f318d9623485b9249c1538fd82275663 100644 (file)
@@ -12,6 +12,13 @@ public class Result_PublicKeySecpErrorZ extends CommonBase {
                bindings.CResult_PublicKeySecpErrorZ_free(ptr); super.finalize();
        }
 
+       static Result_PublicKeySecpErrorZ constr_from_ptr(long ptr) {
+               if (bindings.LDKCResult_PublicKeySecpErrorZ_result_ok(ptr)) {
+                       return new Result_PublicKeySecpErrorZ_OK(null, ptr);
+               } else {
+                       return new Result_PublicKeySecpErrorZ_Err(null, ptr);
+               }
+       }
        public static final class Result_PublicKeySecpErrorZ_OK extends Result_PublicKeySecpErrorZ {
                public byte[] res;
                private Result_PublicKeySecpErrorZ_OK(Object _dummy, long ptr) {
index 865b4c9fbb75992fc800dd38fc9c482a297bd5de..b4d436640c16906024d01383531ed874b79eb559 100644 (file)
@@ -12,6 +12,13 @@ public class Result_RouteLightningErrorZ extends CommonBase {
                bindings.CResult_RouteLightningErrorZ_free(ptr); super.finalize();
        }
 
+       static Result_RouteLightningErrorZ constr_from_ptr(long ptr) {
+               if (bindings.LDKCResult_RouteLightningErrorZ_result_ok(ptr)) {
+                       return new Result_RouteLightningErrorZ_OK(null, ptr);
+               } else {
+                       return new Result_RouteLightningErrorZ_Err(null, ptr);
+               }
+       }
        public static final class Result_RouteLightningErrorZ_OK extends Result_RouteLightningErrorZ {
                public Route res;
                private Result_RouteLightningErrorZ_OK(Object _dummy, long ptr) {
index 7df06e5dc46f18ae28894f8d79d13f55d9bc2d9e..04bb874a9ffd740336722226a733932de96aa992 100644 (file)
@@ -12,6 +12,13 @@ public class Result_SecretKeySecpErrorZ extends CommonBase {
                bindings.CResult_SecretKeySecpErrorZ_free(ptr); super.finalize();
        }
 
+       static Result_SecretKeySecpErrorZ constr_from_ptr(long ptr) {
+               if (bindings.LDKCResult_SecretKeySecpErrorZ_result_ok(ptr)) {
+                       return new Result_SecretKeySecpErrorZ_OK(null, ptr);
+               } else {
+                       return new Result_SecretKeySecpErrorZ_Err(null, ptr);
+               }
+       }
        public static final class Result_SecretKeySecpErrorZ_OK extends Result_SecretKeySecpErrorZ {
                public byte[] res;
                private Result_SecretKeySecpErrorZ_OK(Object _dummy, long ptr) {
index 18bf16900144b3e12a54b94c377e7ca78d988914..877a9b30bc6462db0d2a4c1eea180afdef5ea4dc 100644 (file)
@@ -12,6 +12,13 @@ public class Result_SignatureNoneZ extends CommonBase {
                bindings.CResult_SignatureNoneZ_free(ptr); super.finalize();
        }
 
+       static Result_SignatureNoneZ constr_from_ptr(long ptr) {
+               if (bindings.LDKCResult_SignatureNoneZ_result_ok(ptr)) {
+                       return new Result_SignatureNoneZ_OK(null, ptr);
+               } else {
+                       return new Result_SignatureNoneZ_Err(null, ptr);
+               }
+       }
        public static final class Result_SignatureNoneZ_OK extends Result_SignatureNoneZ {
                public byte[] res;
                private Result_SignatureNoneZ_OK(Object _dummy, long ptr) {
index f0f0a67a0c5b4c0a22b3ebaffbdb7207d64cf004..dfe085cd97037801723c940a8a70183137d889b2 100644 (file)
@@ -12,6 +12,13 @@ public class Result_TxCreationKeysSecpErrorZ extends CommonBase {
                bindings.CResult_TxCreationKeysSecpErrorZ_free(ptr); super.finalize();
        }
 
+       static Result_TxCreationKeysSecpErrorZ constr_from_ptr(long ptr) {
+               if (bindings.LDKCResult_TxCreationKeysSecpErrorZ_result_ok(ptr)) {
+                       return new Result_TxCreationKeysSecpErrorZ_OK(null, ptr);
+               } else {
+                       return new Result_TxCreationKeysSecpErrorZ_Err(null, ptr);
+               }
+       }
        public static final class Result_TxCreationKeysSecpErrorZ_OK extends Result_TxCreationKeysSecpErrorZ {
                public TxCreationKeys res;
                private Result_TxCreationKeysSecpErrorZ_OK(Object _dummy, long ptr) {
index 3c2c3a2d0dab15dbdf9d12b766e8b11d17437b25..1c1f7e9018692d1264f809d480e49054143341e4 100644 (file)
@@ -12,6 +12,13 @@ public class Result_TxOutAccessErrorZ extends CommonBase {
                bindings.CResult_TxOutAccessErrorZ_free(ptr); super.finalize();
        }
 
+       static Result_TxOutAccessErrorZ constr_from_ptr(long ptr) {
+               if (bindings.LDKCResult_TxOutAccessErrorZ_result_ok(ptr)) {
+                       return new Result_TxOutAccessErrorZ_OK(null, ptr);
+               } else {
+                       return new Result_TxOutAccessErrorZ_Err(null, ptr);
+               }
+       }
        public static final class Result_TxOutAccessErrorZ_OK extends Result_TxOutAccessErrorZ {
                public TxOut res;
                private Result_TxOutAccessErrorZ_OK(Object _dummy, long ptr) {
index 67f766e4a705a9b2868cb08e22025c6e0851b065..bb9597f7e45a5349b7330753351e75e7f6db2be0 100644 (file)
@@ -12,6 +12,13 @@ public class Result_boolLightningErrorZ extends CommonBase {
                bindings.CResult_boolLightningErrorZ_free(ptr); super.finalize();
        }
 
+       static Result_boolLightningErrorZ constr_from_ptr(long ptr) {
+               if (bindings.LDKCResult_boolLightningErrorZ_result_ok(ptr)) {
+                       return new Result_boolLightningErrorZ_OK(null, ptr);
+               } else {
+                       return new Result_boolLightningErrorZ_Err(null, ptr);
+               }
+       }
        public static final class Result_boolLightningErrorZ_OK extends Result_boolLightningErrorZ {
                public boolean res;
                private Result_boolLightningErrorZ_OK(Object _dummy, long ptr) {
index 1adf34913dc7bd4c3e8bfab2f0e6dff6bfa6ef7a..ac33e40c5c112fa24103e5f136040f5cccdf5d7c 100644 (file)
@@ -12,6 +12,13 @@ public class Result_boolPeerHandleErrorZ extends CommonBase {
                bindings.CResult_boolPeerHandleErrorZ_free(ptr); super.finalize();
        }
 
+       static Result_boolPeerHandleErrorZ constr_from_ptr(long ptr) {
+               if (bindings.LDKCResult_boolPeerHandleErrorZ_result_ok(ptr)) {
+                       return new Result_boolPeerHandleErrorZ_OK(null, ptr);
+               } else {
+                       return new Result_boolPeerHandleErrorZ_Err(null, ptr);
+               }
+       }
        public static final class Result_boolPeerHandleErrorZ_OK extends Result_boolPeerHandleErrorZ {
                public boolean res;
                private Result_boolPeerHandleErrorZ_OK(Object _dummy, long ptr) {
index a4b61b977bfae2cbd2417cd20e441d70b5dbb61f..e547b766ee22788aa900b949ec43afb13ad441ac 100644 (file)
@@ -17,9 +17,30 @@ public class RoutingMessageHandler extends CommonBase {
                bindings.RoutingMessageHandler_free(ptr); super.finalize();
        }
 
-       // Skipped RoutingMessageHandler_handle_node_announcement
-       // Skipped RoutingMessageHandler_handle_channel_announcement
-       // Skipped RoutingMessageHandler_handle_channel_update
+       public Result_boolLightningErrorZ handle_node_announcement(NodeAnnouncement msg) {
+               long ret = bindings.RoutingMessageHandler_handle_node_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1);
+               Result_boolLightningErrorZ ret_hu_conv = Result_boolLightningErrorZ.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(this);
+               this.ptrs_to.add(msg);
+               return ret_hu_conv;
+       }
+
+       public Result_boolLightningErrorZ handle_channel_announcement(ChannelAnnouncement msg) {
+               long ret = bindings.RoutingMessageHandler_handle_channel_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1);
+               Result_boolLightningErrorZ ret_hu_conv = Result_boolLightningErrorZ.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(this);
+               this.ptrs_to.add(msg);
+               return ret_hu_conv;
+       }
+
+       public Result_boolLightningErrorZ handle_channel_update(ChannelUpdate msg) {
+               long ret = bindings.RoutingMessageHandler_handle_channel_update(this.ptr, msg == null ? 0 : msg.ptr & ~1);
+               Result_boolLightningErrorZ ret_hu_conv = Result_boolLightningErrorZ.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(this);
+               this.ptrs_to.add(msg);
+               return ret_hu_conv;
+       }
+
        // Skipped RoutingMessageHandler_handle_htlc_fail_channel_update
        public ThreeTuple<ChannelAnnouncement, ChannelUpdate, ChannelUpdate>[] get_next_channel_announcements(long starting_point, byte batch_amount) {
                long[] ret = bindings.RoutingMessageHandler_get_next_channel_announcements(this.ptr, starting_point, batch_amount);
index cb025587703ae9de64b036ef8d528c2f0d575980..9cc92e5b521dbc6b71ca0a01e44a1c50026fef8d 100644 (file)
@@ -84,5 +84,11 @@ public class TxCreationKeys extends CommonBase {
                return ret_hu_conv;
        }
 
-       // Skipped TxCreationKeys_derive_new
+       public Result_TxCreationKeysSecpErrorZ derive_new(byte[] per_commitment_point, byte[] broadcaster_delayed_payment_base, byte[] broadcaster_htlc_base, byte[] countersignatory_revocation_base, byte[] countersignatory_htlc_base) {
+               long ret = bindings.TxCreationKeys_derive_new(per_commitment_point, broadcaster_delayed_payment_base, broadcaster_htlc_base, countersignatory_revocation_base, countersignatory_htlc_base);
+               Result_TxCreationKeysSecpErrorZ ret_hu_conv = Result_TxCreationKeysSecpErrorZ.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(this);
+               return ret_hu_conv;
+       }
+
 }
index c237ed3ea1356940045595216ddadbbe3977b585..7ed2211f8bedc3429b531570bf3aed9aebbfa2bf 100644 (file)
@@ -18,7 +18,15 @@ public class Watch extends CommonBase {
        }
 
        // Skipped Watch_watch_channel
-       // Skipped Watch_update_channel
+       public Result_NoneChannelMonitorUpdateErrZ update_channel(OutPoint funding_txo, ChannelMonitorUpdate update) {
+               long ret = bindings.Watch_update_channel(this.ptr, funding_txo == null ? 0 : funding_txo.ptr & ~1, update == null ? 0 : update.ptr & ~1);
+               Result_NoneChannelMonitorUpdateErrZ ret_hu_conv = Result_NoneChannelMonitorUpdateErrZ.constr_from_ptr(ret);
+               ret_hu_conv.ptrs_to.add(this);
+               this.ptrs_to.add(funding_txo);
+               this.ptrs_to.add(update);
+               return ret_hu_conv;
+       }
+
        public MonitorEvent[] release_pending_monitor_events() {
                long[] ret = bindings.Watch_release_pending_monitor_events(this.ptr);
                MonitorEvent[] arr_conv_14_arr = new MonitorEvent[ret.length];
index 18e36c891a4145d46db7e03861eb31d3b0a58a66..6f477d02d3aec5623a5379bd9685f93aea57ce1c 100644 (file)
@@ -124,11 +124,15 @@ public class HumanObjectPeerTest {
             }
         }
 
-        long get_route(byte[] dest_node, ChannelDetails[] our_chans) {
+        Route get_route(byte[] dest_node, ChannelDetails[] our_chans) {
             try (LockedNetworkGraph netgraph = this.router.read_locked_graph()) {
                 NetworkGraph graph = netgraph.graph();
-                return bindings.get_route(this.node_id, graph._test_only_get_ptr(), dest_node, new long[] {our_chans[0]._test_only_get_ptr()},
+                long res = bindings.get_route(this.node_id, graph._test_only_get_ptr(), dest_node, new long[] {our_chans[0]._test_only_get_ptr()},
                         new long[0], 1000, 42, this.logger);
+                assert bindings.LDKCResult_RouteLightningErrorZ_result_ok(res);
+                Route copy = Route.constructor_read(bindings.Route_write(bindings.LDKCResult_RouteLightningErrorZ_get_ok(res)));
+                bindings.CResult_RouteLightningErrorZ_free(res);
+                return copy;
             }
         }
     }
@@ -263,12 +267,9 @@ public class HumanObjectPeerTest {
         byte[] payment_preimage = new byte[32];
         for (int i = 0; i < 32; i++) payment_preimage[i] = (byte) (i ^ 0x0f);
         byte[] payment_hash = Sha256Hash.hash(payment_preimage);
-        long route = peer1.get_route(peer2.node_id, peer1_chans);
-        assert bindings.LDKCResult_RouteLightningErrorZ_result_ok(route);
-        long payment_res = bindings.ChannelManager_send_payment(peer1.chan_manager._test_only_get_ptr(), bindings.LDKCResult_RouteLightningErrorZ_get_ok(route), payment_hash, new byte[32]);
-        bindings.CResult_RouteLightningErrorZ_free(route);
-        assert bindings.LDKCResult_NonePaymentSendFailureZ_result_ok(payment_res);
-        bindings.CResult_NonePaymentSendFailureZ_free(payment_res);
+        Route route = peer1.get_route(peer2.node_id, peer1_chans);
+        Result_NonePaymentSendFailureZ payment_res = peer1.chan_manager.send_payment(route, payment_hash, new byte[32]);
+        assert payment_res instanceof Result_NonePaymentSendFailureZ.Result_NonePaymentSendFailureZ_OK;
 
         peer1.peer_manager.process_events();
         while (!list.isEmpty()) { list.poll().join(); }