7 namespace org { namespace ldk { namespace structs {
11 /** An implementation of ChangeDestinationSource */
12 public interface ChangeDestinationSourceInterface {
13 /**Returns a script pubkey which can be used as a change destination for
14 * [`OutputSpender::spend_spendable_outputs`].
16 * This method should return a different value each time it is called, to avoid linking
17 * on-chain funds controlled to the same user.
19 Result_CVec_u8ZNoneZ get_change_destination_script();
23 * A helper trait that describes an on-chain wallet capable of returning a (change) destination
26 public class ChangeDestinationSource : CommonBase {
27 internal bindings.LDKChangeDestinationSource bindings_instance;
28 internal long instance_idx;
30 internal ChangeDestinationSource(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
31 ~ChangeDestinationSource() {
32 if (ptr != 0) { bindings.ChangeDestinationSource_free(ptr); }
35 private class LDKChangeDestinationSourceHolder { internal ChangeDestinationSource held; }
36 private class LDKChangeDestinationSourceImpl : bindings.LDKChangeDestinationSource {
37 internal LDKChangeDestinationSourceImpl(ChangeDestinationSourceInterface arg, LDKChangeDestinationSourceHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
38 private ChangeDestinationSourceInterface arg;
39 private LDKChangeDestinationSourceHolder impl_holder;
40 public long get_change_destination_script() {
41 Result_CVec_u8ZNoneZ ret = arg.get_change_destination_script();
43 long result = ret.clone_ptr();
48 /** Creates a new instance of ChangeDestinationSource from a given implementation */
49 public static ChangeDestinationSource new_impl(ChangeDestinationSourceInterface arg) {
50 LDKChangeDestinationSourceHolder impl_holder = new LDKChangeDestinationSourceHolder();
51 LDKChangeDestinationSourceImpl impl = new LDKChangeDestinationSourceImpl(arg, impl_holder);
52 long[] ptr_idx = bindings.LDKChangeDestinationSource_new(impl);
54 impl_holder.held = new ChangeDestinationSource(null, ptr_idx[0]);
55 impl_holder.held.instance_idx = ptr_idx[1];
56 impl_holder.held.bindings_instance = impl;
57 return impl_holder.held;
61 * Returns a script pubkey which can be used as a change destination for
62 * [`OutputSpender::spend_spendable_outputs`].
64 * This method should return a different value each time it is called, to avoid linking
65 * on-chain funds controlled to the same user.
67 public Result_CVec_u8ZNoneZ get_change_destination_script() {
68 long ret = bindings.ChangeDestinationSource_get_change_destination_script(this.ptr);
70 if (ret >= 0 && ret <= 4096) { return null; }
71 Result_CVec_u8ZNoneZ ret_hu_conv = Result_CVec_u8ZNoneZ.constr_from_ptr(ret);