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]*)\]")
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()
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
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(", ")
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")
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]
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;
+ }
+
}
// 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);
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];
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);
}
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);
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;
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);
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
}
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);
}
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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);
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;
+ }
+
}
}
// 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];
}
}
- 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;
}
}
}
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(); }