1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
10 * The information we received from a peer along the route of a payment we originated. This is
11 * returned by ChannelMessageHandler::handle_update_fail_htlc to be passed into
12 * RoutingMessageHandler::handle_htlc_fail_channel_update to update our network map.
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class HTLCFailChannelUpdate extends CommonBase {
16 private HTLCFailChannelUpdate(Object _dummy, long ptr) { super(ptr); }
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
20 if (ptr != 0) { bindings.HTLCFailChannelUpdate_free(ptr); }
22 static HTLCFailChannelUpdate constr_from_ptr(long ptr) {
23 bindings.LDKHTLCFailChannelUpdate raw_val = bindings.LDKHTLCFailChannelUpdate_ref_from_ptr(ptr);
24 if (raw_val.getClass() == bindings.LDKHTLCFailChannelUpdate.ChannelUpdateMessage.class) {
25 return new ChannelUpdateMessage(ptr, (bindings.LDKHTLCFailChannelUpdate.ChannelUpdateMessage)raw_val);
27 if (raw_val.getClass() == bindings.LDKHTLCFailChannelUpdate.ChannelClosed.class) {
28 return new ChannelClosed(ptr, (bindings.LDKHTLCFailChannelUpdate.ChannelClosed)raw_val);
30 if (raw_val.getClass() == bindings.LDKHTLCFailChannelUpdate.NodeFailure.class) {
31 return new NodeFailure(ptr, (bindings.LDKHTLCFailChannelUpdate.NodeFailure)raw_val);
33 assert false; return null; // Unreachable without extending the (internal) bindings interface
36 public final static class ChannelUpdateMessage extends HTLCFailChannelUpdate {
37 public final ChannelUpdate msg;
38 private ChannelUpdateMessage(long ptr, bindings.LDKHTLCFailChannelUpdate.ChannelUpdateMessage obj) {
41 ChannelUpdate msg_hu_conv = new ChannelUpdate(null, msg);
42 msg_hu_conv.ptrs_to.add(this);
43 this.msg = msg_hu_conv;
46 public final static class ChannelClosed extends HTLCFailChannelUpdate {
47 public final long short_channel_id;
48 public final boolean is_permanent;
49 private ChannelClosed(long ptr, bindings.LDKHTLCFailChannelUpdate.ChannelClosed obj) {
51 this.short_channel_id = obj.short_channel_id;
52 this.is_permanent = obj.is_permanent;
55 public final static class NodeFailure extends HTLCFailChannelUpdate {
56 public final byte[] node_id;
57 public final boolean is_permanent;
58 private NodeFailure(long ptr, bindings.LDKHTLCFailChannelUpdate.NodeFailure obj) {
60 this.node_id = obj.node_id;
61 this.is_permanent = obj.is_permanent;
65 * Creates a copy of the HTLCFailChannelUpdate
67 public HTLCFailChannelUpdate clone() {
68 long ret = bindings.HTLCFailChannelUpdate_clone(this.ptr);
69 HTLCFailChannelUpdate ret_hu_conv = HTLCFailChannelUpdate.constr_from_ptr(ret);
70 ret_hu_conv.ptrs_to.add(this);