]> git.bitcoin.ninja Git - ldk-java/blob - src/main/java/org/ldk/structs/ChangeDestinationSource.java
[Java] Update auto-generated bindings to LDK 0.0.123
[ldk-java] / src / main / java / org / ldk / structs / ChangeDestinationSource.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10 /**
11  * A helper trait that describes an on-chain wallet capable of returning a (change) destination
12  * script.
13  */
14 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
15 public class ChangeDestinationSource extends CommonBase {
16         final bindings.LDKChangeDestinationSource bindings_instance;
17         ChangeDestinationSource(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
18         private ChangeDestinationSource(bindings.LDKChangeDestinationSource arg) {
19                 super(bindings.LDKChangeDestinationSource_new(arg));
20                 this.ptrs_to.add(arg);
21                 this.bindings_instance = arg;
22         }
23         @Override @SuppressWarnings("deprecation")
24         protected void finalize() throws Throwable {
25                 if (ptr != 0) { bindings.ChangeDestinationSource_free(ptr); } super.finalize();
26         }
27         /**
28          * Destroys the object, freeing associated resources. After this call, any access
29          * to this object may result in a SEGFAULT or worse.
30          *
31          * You should generally NEVER call this method. You should let the garbage collector
32          * do this for you when it finalizes objects. However, it may be useful for types
33          * which represent locks and should be closed immediately to avoid holding locks
34          * until the GC runs.
35          */
36         public void destroy() {
37                 if (ptr != 0) { bindings.ChangeDestinationSource_free(ptr); }
38                 ptr = 0;
39         }
40         public static interface ChangeDestinationSourceInterface {
41                 /**
42                  * Returns a script pubkey which can be used as a change destination for
43                  * [`OutputSpender::spend_spendable_outputs`].
44                  * 
45                  * This method should return a different value each time it is called, to avoid linking
46                  * on-chain funds controlled to the same user.
47                  */
48                 Result_CVec_u8ZNoneZ get_change_destination_script();
49         }
50         private static class LDKChangeDestinationSourceHolder { ChangeDestinationSource held; }
51         public static ChangeDestinationSource new_impl(ChangeDestinationSourceInterface arg) {
52                 final LDKChangeDestinationSourceHolder impl_holder = new LDKChangeDestinationSourceHolder();
53                 impl_holder.held = new ChangeDestinationSource(new bindings.LDKChangeDestinationSource() {
54                         @Override public long get_change_destination_script() {
55                                 Result_CVec_u8ZNoneZ ret = arg.get_change_destination_script();
56                                 Reference.reachabilityFence(arg);
57                                 long result = ret.clone_ptr();
58                                 return result;
59                         }
60                 });
61                 return impl_holder.held;
62         }
63         /**
64          * Returns a script pubkey which can be used as a change destination for
65          * [`OutputSpender::spend_spendable_outputs`].
66          * 
67          * This method should return a different value each time it is called, to avoid linking
68          * on-chain funds controlled to the same user.
69          */
70         public Result_CVec_u8ZNoneZ get_change_destination_script() {
71                 long ret = bindings.ChangeDestinationSource_get_change_destination_script(this.ptr);
72                 Reference.reachabilityFence(this);
73                 if (ret >= 0 && ret <= 4096) { return null; }
74                 Result_CVec_u8ZNoneZ ret_hu_conv = Result_CVec_u8ZNoneZ.constr_from_ptr(ret);
75                 return ret_hu_conv;
76         }
77
78 }