Update auto-generated bindings
[ldk-java] / ts / structs / NetworkUpdate.ts
1
2 import CommonBase from './CommonBase';
3 import * as bindings from '../bindings' // TODO: figure out location
4
5 export default class NetworkUpdate extends CommonBase {
6         protected constructor(_dummy: object, ptr: number) { super(ptr); }
7         protected finalize() {
8                 super.finalize();
9                 if (this.ptr != 0) { bindings.NetworkUpdate_free(this.ptr); }
10         }
11         static constr_from_ptr(ptr: number): NetworkUpdate {
12                 const raw_val: bindings.LDKNetworkUpdate = bindings.LDKNetworkUpdate_ref_from_ptr(ptr);
13                 if (raw_val instanceof bindings.LDKNetworkUpdate.ChannelUpdateMessage) {
14                         return new ChannelUpdateMessage(this.ptr, raw_val);
15                 }
16                 if (raw_val instanceof bindings.LDKNetworkUpdate.ChannelClosed) {
17                         return new ChannelClosed(this.ptr, raw_val);
18                 }
19                 if (raw_val instanceof bindings.LDKNetworkUpdate.NodeFailure) {
20                         return new NodeFailure(this.ptr, raw_val);
21                 }
22                 throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface
23         }
24
25 }
26 export class ChannelUpdateMessage extends NetworkUpdate {
27         public msg: ChannelUpdate;
28         private constructor(ptr: number, obj: bindings.LDKNetworkUpdate.ChannelUpdateMessage) {
29                 super(null, ptr);
30                 const msg: number = obj.msg;
31                 const msg_hu_conv: ChannelUpdate = new ChannelUpdate(null, msg);
32                         msg_hu_conv.ptrs_to.add(this);
33                 this.msg = msg_hu_conv;
34         }
35 }
36 export class ChannelClosed extends NetworkUpdate {
37         public short_channel_id: number;
38         public is_permanent: boolean;
39         private constructor(ptr: number, obj: bindings.LDKNetworkUpdate.ChannelClosed) {
40                 super(null, ptr);
41                 this.short_channel_id = obj.short_channel_id;
42                 this.is_permanent = obj.is_permanent;
43         }
44 }
45 export class NodeFailure extends NetworkUpdate {
46         public node_id: Uint8Array;
47         public is_permanent: boolean;
48         private constructor(ptr: number, obj: bindings.LDKNetworkUpdate.NodeFailure) {
49                 super(null, ptr);
50                 this.node_id = obj.node_id;
51                 this.is_permanent = obj.is_permanent;
52         }
53 }
54         public number clone_ptr() {
55                 number ret = bindings.NetworkUpdate_clone_ptr(this.ptr);
56                 return ret;
57         }
58
59         public NetworkUpdate clone() {
60                 number ret = bindings.NetworkUpdate_clone(this.ptr);
61                 NetworkUpdate ret_hu_conv = NetworkUpdate.constr_from_ptr(ret);
62                 ret_hu_conv.ptrs_to.add(this);
63                 return ret_hu_conv;
64         }
65
66         public static NetworkUpdate constructor_channel_update_message(ChannelUpdate msg) {
67                 number ret = bindings.NetworkUpdate_channel_update_message(msg == null ? 0 : msg.ptr & ~1);
68                 NetworkUpdate ret_hu_conv = NetworkUpdate.constr_from_ptr(ret);
69                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
70                 return ret_hu_conv;
71         }
72
73         public static NetworkUpdate constructor_channel_closed(number short_channel_id, boolean is_permanent) {
74                 number ret = bindings.NetworkUpdate_channel_closed(short_channel_id, is_permanent);
75                 NetworkUpdate ret_hu_conv = NetworkUpdate.constr_from_ptr(ret);
76                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
77                 return ret_hu_conv;
78         }
79
80         public static NetworkUpdate constructor_node_failure(Uint8Array node_id, boolean is_permanent) {
81                 number ret = bindings.NetworkUpdate_node_failure(InternalUtils.check_arr_len(node_id, 33), is_permanent);
82                 NetworkUpdate ret_hu_conv = NetworkUpdate.constr_from_ptr(ret);
83                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
84                 return ret_hu_conv;
85         }
86
87         public Uint8Array write() {
88                 Uint8Array ret = bindings.NetworkUpdate_write(this.ptr);
89                 return ret;
90         }
91
92 }