1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * Result of successfully [sending an onion message].
14 * [sending an onion message]: OnionMessenger::send_onion_message
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class SendSuccess extends CommonBase {
18 private SendSuccess(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.SendSuccess_free(ptr); }
24 static SendSuccess constr_from_ptr(long ptr) {
25 bindings.LDKSendSuccess raw_val = bindings.LDKSendSuccess_ref_from_ptr(ptr);
26 if (raw_val.getClass() == bindings.LDKSendSuccess.Buffered.class) {
27 return new Buffered(ptr, (bindings.LDKSendSuccess.Buffered)raw_val);
29 if (raw_val.getClass() == bindings.LDKSendSuccess.BufferedAwaitingConnection.class) {
30 return new BufferedAwaitingConnection(ptr, (bindings.LDKSendSuccess.BufferedAwaitingConnection)raw_val);
32 assert false; return null; // Unreachable without extending the (internal) bindings interface
36 * The message was buffered and will be sent once it is processed by
37 * [`OnionMessageHandler::next_onion_message_for_peer`].
39 public final static class Buffered extends SendSuccess {
40 private Buffered(long ptr, bindings.LDKSendSuccess.Buffered obj) {
45 * The message was buffered and will be sent once the node is connected as a peer and it is
46 * processed by [`OnionMessageHandler::next_onion_message_for_peer`].
48 public final static class BufferedAwaitingConnection extends SendSuccess {
49 public final byte[] buffered_awaiting_connection;
50 private BufferedAwaitingConnection(long ptr, bindings.LDKSendSuccess.BufferedAwaitingConnection obj) {
52 this.buffered_awaiting_connection = obj.buffered_awaiting_connection;
56 long ret = bindings.SendSuccess_clone_ptr(this.ptr);
57 Reference.reachabilityFence(this);
62 * Creates a copy of the SendSuccess
64 public SendSuccess clone() {
65 long ret = bindings.SendSuccess_clone(this.ptr);
66 Reference.reachabilityFence(this);
67 if (ret >= 0 && ret <= 4096) { return null; }
68 org.ldk.structs.SendSuccess ret_hu_conv = org.ldk.structs.SendSuccess.constr_from_ptr(ret);
69 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
74 * Utility method to constructs a new Buffered-variant SendSuccess
76 public static SendSuccess buffered() {
77 long ret = bindings.SendSuccess_buffered();
78 if (ret >= 0 && ret <= 4096) { return null; }
79 org.ldk.structs.SendSuccess ret_hu_conv = org.ldk.structs.SendSuccess.constr_from_ptr(ret);
80 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
85 * Utility method to constructs a new BufferedAwaitingConnection-variant SendSuccess
87 public static SendSuccess buffered_awaiting_connection(byte[] a) {
88 long ret = bindings.SendSuccess_buffered_awaiting_connection(InternalUtils.check_arr_len(a, 33));
89 Reference.reachabilityFence(a);
90 if (ret >= 0 && ret <= 4096) { return null; }
91 org.ldk.structs.SendSuccess ret_hu_conv = org.ldk.structs.SendSuccess.constr_from_ptr(ret);
92 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
97 * Checks if two SendSuccesss contain equal inner contents.
98 * This ignores pointers and is_owned flags and looks at the values in fields.
100 public boolean eq(org.ldk.structs.SendSuccess b) {
101 boolean ret = bindings.SendSuccess_eq(this.ptr, b == null ? 0 : b.ptr);
102 Reference.reachabilityFence(this);
103 Reference.reachabilityFence(b);
107 @Override public boolean equals(Object o) {
108 if (!(o instanceof SendSuccess)) return false;
109 return this.eq((SendSuccess)o);