9b1dde6e3c73e7bb38254181b1ab5230850eed76
[ldk-java] / ts / structs / Persist.ts
1
2 import CommonBase from './CommonBase';
3 import * as bindings from '../bindings' // TODO: figure out location
4
5 public class Persist extends CommonBase {
6         final bindings.LDKPersist bindings_instance;
7         Persist(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
8         private Persist(bindings.LDKPersist arg) {
9                 super(bindings.LDKPersist_new(arg));
10                 this.ptrs_to.add(arg);
11                 this.bindings_instance = arg;
12         }
13         @Override @SuppressWarnings("deprecation")
14         protected void finalize() throws Throwable {
15                 if (ptr != 0) { bindings.Persist_free(ptr); } super.finalize();
16         }
17
18         public static interface PersistInterface {
19                 Result_NoneChannelMonitorUpdateErrZ persist_new_channel(OutPoint id, ChannelMonitor data);
20                 Result_NoneChannelMonitorUpdateErrZ update_persisted_channel(OutPoint id, ChannelMonitorUpdate update, ChannelMonitor data);
21         }
22         private static class LDKPersistHolder { Persist held; }
23         public static Persist new_impl(PersistInterface arg) {
24                 final LDKPersistHolder impl_holder = new LDKPersistHolder();
25                 impl_holder.held = new Persist(new bindings.LDKPersist() {
26                         @Override public uint32_t persist_new_channel(uint32_t id, uint32_t data) {
27                                 OutPoint id_hu_conv = new OutPoint(null, id);
28                                 ChannelMonitor data_hu_conv = new ChannelMonitor(null, data);
29                                 Result_NoneChannelMonitorUpdateErrZ ret = arg.persist_new_channel(id_hu_conv, data_hu_conv);
30                                 uint32_t result = ret != null ? ret.ptr : 0;
31                                 ret.ptr = 0;
32                                 return result;
33                         }
34                         @Override public uint32_t update_persisted_channel(uint32_t id, uint32_t update, uint32_t data) {
35                                 OutPoint id_hu_conv = new OutPoint(null, id);
36                                 ChannelMonitorUpdate update_hu_conv = new ChannelMonitorUpdate(null, update);
37                                 ChannelMonitor data_hu_conv = new ChannelMonitor(null, data);
38                                 Result_NoneChannelMonitorUpdateErrZ ret = arg.update_persisted_channel(id_hu_conv, update_hu_conv, data_hu_conv);
39                                 uint32_t result = ret != null ? ret.ptr : 0;
40                                 ret.ptr = 0;
41                                 return result;
42                         }
43                 });
44                 return impl_holder.held;
45         }
46         public Result_NoneChannelMonitorUpdateErrZ persist_new_channel(OutPoint id, ChannelMonitor data) {
47                 uint32_t ret = bindings.Persist_persist_new_channel(this.ptr, id == null ? 0 : id.ptr & ~1, data == null ? 0 : data.ptr & ~1);
48                 Result_NoneChannelMonitorUpdateErrZ ret_hu_conv = Result_NoneChannelMonitorUpdateErrZ.constr_from_ptr(ret);
49                 this.ptrs_to.add(id);
50                 this.ptrs_to.add(data);
51                 return ret_hu_conv;
52         }
53
54         public Result_NoneChannelMonitorUpdateErrZ update_persisted_channel(OutPoint id, ChannelMonitorUpdate update, ChannelMonitor data) {
55                 uint32_t ret = bindings.Persist_update_persisted_channel(this.ptr, id == null ? 0 : id.ptr & ~1, update == null ? 0 : update.ptr & ~1, data == null ? 0 : data.ptr & ~1);
56                 Result_NoneChannelMonitorUpdateErrZ ret_hu_conv = Result_NoneChannelMonitorUpdateErrZ.constr_from_ptr(ret);
57                 this.ptrs_to.add(id);
58                 this.ptrs_to.add(update);
59                 this.ptrs_to.add(data);
60                 return ret_hu_conv;
61         }
62
63 }