X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=ts%2Fstructs%2FPersist.ts;h=3a4b734464a46d891b2d8405aaceb34a308dadb3;hb=0fee03a8095f5599f8eccd920c1b1af6b3a20260;hp=f55f4cf578a60fbd733761216390fada36e9a01c;hpb=4f914d250ae903770128765403d62ce3d8f54126;p=ldk-java diff --git a/ts/structs/Persist.ts b/ts/structs/Persist.ts index f55f4cf5..3a4b7344 100644 --- a/ts/structs/Persist.ts +++ b/ts/structs/Persist.ts @@ -1,15 +1,85 @@ - public Result_NoneChannelMonitorUpdateErrZ persist_new_channel(OutPoint id, ChannelMonitor data) { - uint32_t ret = bindings.Persist_persist_new_channel(this.ptr, id == null ? 0 : id.ptr & ~1, data == null ? 0 : data.ptr & ~1); + + +import CommonBase from './CommonBase'; +import * as bindings from '../bindings' // TODO: figure out location + + + + export class Persist extends CommonBase { + + bindings_instance?: bindings.LDKPersist; + + constructor(ptr?: number, arg?: bindings.LDKPersist) { + if (Number.isFinite(ptr)) { + super(ptr); + this.bindings_instance = null; + } else { + // TODO: private constructor instantiation + super(bindings.LDKPersist_new(arg)); + this.ptrs_to.push(arg); + + } + } + + protected finalize() { + if (this.ptr != 0) { + bindings.Persist_free(this.ptr); + } + super.finalize(); + } + + static new_impl(arg: PersistInterface): Persist { + const impl_holder: LDKPersistHolder = new LDKPersistHolder(); + let structImplementation = { + // todo: in-line interface filling + persist_new_channel (channel_id: number, data: number, update_id: number): number { + const channel_id_hu_conv: OutPoint = new OutPoint(null, channel_id); + channel_id_hu_conv.ptrs_to.add(this); + const data_hu_conv: ChannelMonitor = new ChannelMonitor(null, data); + const update_id_hu_conv: MonitorUpdateId = new MonitorUpdateId(null, update_id); + update_id_hu_conv.ptrs_to.add(this); + Result_NoneChannelMonitorUpdateErrZ ret = arg.persist_new_channel(channel_id_hu_conv, data_hu_conv, update_id_hu_conv); + result: number = ret == null ? 0 : ret.clone_ptr(); + return result; + }, + + update_persisted_channel (channel_id: number, update: number, data: number, update_id: number): number { + const channel_id_hu_conv: OutPoint = new OutPoint(null, channel_id); + channel_id_hu_conv.ptrs_to.add(this); + const update_hu_conv: ChannelMonitorUpdate = new ChannelMonitorUpdate(null, update); + const data_hu_conv: ChannelMonitor = new ChannelMonitor(null, data); + const update_id_hu_conv: MonitorUpdateId = new MonitorUpdateId(null, update_id); + update_id_hu_conv.ptrs_to.add(this); + Result_NoneChannelMonitorUpdateErrZ ret = arg.update_persisted_channel(channel_id_hu_conv, update_hu_conv, data_hu_conv, update_id_hu_conv); + result: number = ret == null ? 0 : ret.clone_ptr(); + return result; + }, + + + }; + impl_holder.held = new Persist (null, structImplementation); + } + } + + export interface PersistInterface { + persist_new_channel(channel_id: OutPoint, data: ChannelMonitor, update_id: MonitorUpdateId): Result_NoneChannelMonitorUpdateErrZ; + update_persisted_channel(channel_id: OutPoint, update: ChannelMonitorUpdate, data: ChannelMonitor, update_id: MonitorUpdateId): Result_NoneChannelMonitorUpdateErrZ; + + } + + class LDKPersistHolder { + held: Persist; + } + public Result_NoneChannelMonitorUpdateErrZ persist_new_channel(OutPoint channel_id, ChannelMonitor data, MonitorUpdateId update_id) { + number ret = bindings.Persist_persist_new_channel(this.ptr, channel_id == null ? 0 : channel_id.ptr & ~1, data == null ? 0 : data.ptr & ~1, update_id == null ? 0 : update_id.ptr & ~1); Result_NoneChannelMonitorUpdateErrZ ret_hu_conv = Result_NoneChannelMonitorUpdateErrZ.constr_from_ptr(ret); - this.ptrs_to.add(id); this.ptrs_to.add(data); return ret_hu_conv; } - public Result_NoneChannelMonitorUpdateErrZ update_persisted_channel(OutPoint id, ChannelMonitorUpdate update, ChannelMonitor data) { - 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); + public Result_NoneChannelMonitorUpdateErrZ update_persisted_channel(OutPoint channel_id, ChannelMonitorUpdate update, ChannelMonitor data, MonitorUpdateId update_id) { + number ret = bindings.Persist_update_persisted_channel(this.ptr, channel_id == null ? 0 : channel_id.ptr & ~1, update == null ? 0 : update.ptr & ~1, data == null ? 0 : data.ptr & ~1, update_id == null ? 0 : update_id.ptr & ~1); Result_NoneChannelMonitorUpdateErrZ ret_hu_conv = Result_NoneChannelMonitorUpdateErrZ.constr_from_ptr(ret); - this.ptrs_to.add(id); this.ptrs_to.add(update); this.ptrs_to.add(data); return ret_hu_conv;