5f76a0df4ef156d0a33c33360fa067e27b950776
[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                         msg_hu_conv.ptrs_to.add(this);
33                 this.msg = msg_hu_conv;
34         }
35 }
36 export class ChannelClosed extends HTLCFailChannelUpdate {
37         public short_channel_id: number;
38         public is_permanent: boolean;
39         private constructor(ptr: number, obj: bindings.LDKHTLCFailChannelUpdate.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 HTLCFailChannelUpdate {
46         public node_id: Uint8Array;
47         public is_permanent: boolean;
48         private constructor(ptr: number, obj: bindings.LDKHTLCFailChannelUpdate.NodeFailure) {
49                 super(null, ptr);
50                 this.node_id = obj.node_id;
51                 this.is_permanent = obj.is_permanent;
52         }
53 }