]> git.bitcoin.ninja Git - ldk-java/blob - ts/structs/HTLCFailChannelUpdate.ts
Merge pull request #20 from TheBlueMatt/main
[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 }
54         public HTLCFailChannelUpdate clone() {
55                 number ret = bindings.HTLCFailChannelUpdate_clone(this.ptr);
56                 HTLCFailChannelUpdate ret_hu_conv = HTLCFailChannelUpdate.constr_from_ptr(ret);
57                 ret_hu_conv.ptrs_to.add(this);
58                 return ret_hu_conv;
59         }
60
61 }