Bindings updates
[ldk-java] / ts / structs / HTLCFailChannelUpdate.ts
1
2 import CommonBase from './CommonBase';
3 import * as bindings from '../bindings' // TODO: figure out location
4
5 export default class HTLCFailChannelUpdate extends CommonBase {
6         protected constructor(_dummy: object, ptr: number) { super(ptr); }
7         protected finalize() {
8                 super.finalize();
9                 if (this.ptr != 0) { bindings.HTLCFailChannelUpdate_free(this.ptr); }
10         }
11         static constr_from_ptr(ptr: number): HTLCFailChannelUpdate {
12                 const raw_val: bindings.LDKHTLCFailChannelUpdate = bindings.LDKHTLCFailChannelUpdate_ref_from_ptr(ptr);
13                 if (raw_val instanceof bindings.LDKHTLCFailChannelUpdate.ChannelUpdateMessage) {
14                         return new ChannelUpdateMessage(this.ptr, raw_val);
15                 }
16                 if (raw_val instanceof bindings.LDKHTLCFailChannelUpdate.ChannelClosed) {
17                         return new ChannelClosed(this.ptr, raw_val);
18                 }
19                 if (raw_val instanceof bindings.LDKHTLCFailChannelUpdate.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 HTLCFailChannelUpdate {
27         public msg: ChannelUpdate;
28         private constructor(ptr: number, obj: bindings.LDKHTLCFailChannelUpdate.ChannelUpdateMessage) {
29                 super(null, ptr);
30                 const msg: number = obj.msg;
31                 const msg_hu_conv: ChannelUpdate = new ChannelUpdate(null, msg);
32                 this.msg = msg_hu_conv;
33         }
34 }
35 export class ChannelClosed extends HTLCFailChannelUpdate {
36         public short_channel_id: number;
37         public is_permanent: boolean;
38         private constructor(ptr: number, obj: bindings.LDKHTLCFailChannelUpdate.ChannelClosed) {
39                 super(null, ptr);
40                 this.short_channel_id = obj.short_channel_id;
41                 this.is_permanent = obj.is_permanent;
42         }
43 }
44 export class NodeFailure extends HTLCFailChannelUpdate {
45         public node_id: Uint8Array;
46         public is_permanent: boolean;
47         private constructor(ptr: number, obj: bindings.LDKHTLCFailChannelUpdate.NodeFailure) {
48                 super(null, ptr);
49                 this.node_id = obj.node_id;
50                 this.is_permanent = obj.is_permanent;
51         }
52 }