X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FHTLCFailChannelUpdate.java;h=7ce939f9613ca9a5663ae75cc84c0b314e668eed;hb=c3ae2d6897e5a809459c8d9a72a4b3aa0052c8c8;hp=69dccb8e76a2d5e8ceab5b068e74204d41f7e0f9;hpb=371e82300e5de678404f0addc47a20636077df5d;p=ldk-java diff --git a/src/main/java/org/ldk/structs/HTLCFailChannelUpdate.java b/src/main/java/org/ldk/structs/HTLCFailChannelUpdate.java index 69dccb8e..7ce939f9 100644 --- a/src/main/java/org/ldk/structs/HTLCFailChannelUpdate.java +++ b/src/main/java/org/ldk/structs/HTLCFailChannelUpdate.java @@ -5,15 +5,20 @@ import org.ldk.enums.*; import org.ldk.util.*; import java.util.Arrays; + +/** + * The information we received from a peer along the route of a payment we originated. This is + * returned by ChannelMessageHandler::handle_update_fail_htlc to be passed into + * RoutingMessageHandler::handle_htlc_fail_channel_update to update our network map. + */ @SuppressWarnings("unchecked") // We correctly assign various generic arrays public class HTLCFailChannelUpdate extends CommonBase { private HTLCFailChannelUpdate(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { super.finalize(); - bindings.HTLCFailChannelUpdate_free(ptr); + if (ptr != 0) { bindings.HTLCFailChannelUpdate_free(ptr); } } - long conv_to_c() { assert false; return 0; /* Should only be called on subclasses */ } static HTLCFailChannelUpdate constr_from_ptr(long ptr) { bindings.LDKHTLCFailChannelUpdate raw_val = bindings.LDKHTLCFailChannelUpdate_ref_from_ptr(ptr); if (raw_val.getClass() == bindings.LDKHTLCFailChannelUpdate.ChannelUpdateMessage.class) { @@ -29,33 +34,41 @@ public class HTLCFailChannelUpdate extends CommonBase { } public final static class ChannelUpdateMessage extends HTLCFailChannelUpdate { - public ChannelUpdate msg; + public final ChannelUpdate msg; private ChannelUpdateMessage(long ptr, bindings.LDKHTLCFailChannelUpdate.ChannelUpdateMessage obj) { super(null, ptr); long msg = obj.msg; ChannelUpdate msg_hu_conv = new ChannelUpdate(null, msg); + msg_hu_conv.ptrs_to.add(this); this.msg = msg_hu_conv; } - @Override long conv_to_c() { return 0; /*XXX*/ } } public final static class ChannelClosed extends HTLCFailChannelUpdate { - public long short_channel_id; - public boolean is_permanent; + public final long short_channel_id; + public final boolean is_permanent; private ChannelClosed(long ptr, bindings.LDKHTLCFailChannelUpdate.ChannelClosed obj) { super(null, ptr); this.short_channel_id = obj.short_channel_id; this.is_permanent = obj.is_permanent; } - @Override long conv_to_c() { return 0; /*XXX*/ } } public final static class NodeFailure extends HTLCFailChannelUpdate { - public byte[] node_id; - public boolean is_permanent; + public final byte[] node_id; + public final boolean is_permanent; private NodeFailure(long ptr, bindings.LDKHTLCFailChannelUpdate.NodeFailure obj) { super(null, ptr); this.node_id = obj.node_id; this.is_permanent = obj.is_permanent; } - @Override long conv_to_c() { return 0; /*XXX*/ } } + /** + * Creates a copy of the HTLCFailChannelUpdate + */ + public HTLCFailChannelUpdate clone() { + long ret = bindings.HTLCFailChannelUpdate_clone(this.ptr); + HTLCFailChannelUpdate ret_hu_conv = HTLCFailChannelUpdate.constr_from_ptr(ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + }