2 import CommonBase from './CommonBase';
3 import * as bindings from '../bindings' // TODO: figure out location
5 export default class HTLCFailChannelUpdate extends CommonBase {
6 protected constructor(_dummy: object, ptr: number) { super(ptr); }
9 if (this.ptr != 0) { bindings.HTLCFailChannelUpdate_free(this.ptr); }
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);
16 if (raw_val instanceof bindings.LDKHTLCFailChannelUpdate.ChannelClosed) {
17 return new ChannelClosed(this.ptr, raw_val);
19 if (raw_val instanceof bindings.LDKHTLCFailChannelUpdate.NodeFailure) {
20 return new NodeFailure(this.ptr, raw_val);
22 throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface
26 export class ChannelUpdateMessage extends HTLCFailChannelUpdate {
27 public msg: ChannelUpdate;
28 private constructor(ptr: number, obj: bindings.LDKHTLCFailChannelUpdate.ChannelUpdateMessage) {
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;
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) {
41 this.short_channel_id = obj.short_channel_id;
42 this.is_permanent = obj.is_permanent;
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) {
50 this.node_id = obj.node_id;
51 this.is_permanent = obj.is_permanent;
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);