2 import CommonBase from './CommonBase';
3 import * as bindings from '../bindings' // TODO: figure out location
5 export default class MonitorEvent extends CommonBase {
6 protected constructor(_dummy: object, ptr: number) { super(ptr); }
9 if (this.ptr != 0) { bindings.MonitorEvent_free(this.ptr); }
11 static constr_from_ptr(ptr: number): MonitorEvent {
12 const raw_val: bindings.LDKMonitorEvent = bindings.LDKMonitorEvent_ref_from_ptr(ptr);
13 if (raw_val instanceof bindings.LDKMonitorEvent.HTLCEvent) {
14 return new HTLCEvent(this.ptr, raw_val);
16 if (raw_val instanceof bindings.LDKMonitorEvent.CommitmentTxBroadcasted) {
17 return new CommitmentTxBroadcasted(this.ptr, raw_val);
19 throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface
23 export class HTLCEvent extends MonitorEvent {
24 public htlc_event: HTLCUpdate;
25 private constructor(ptr: number, obj: bindings.LDKMonitorEvent.HTLCEvent) {
27 const htlc_event: number = obj.htlc_event;
28 const htlc_event_hu_conv: HTLCUpdate = new HTLCUpdate(null, htlc_event);
29 htlc_event_hu_conv.ptrs_to.add(this);
30 this.htlc_event = htlc_event_hu_conv;
33 export class CommitmentTxBroadcasted extends MonitorEvent {
34 public commitment_tx_broadcasted: OutPoint;
35 private constructor(ptr: number, obj: bindings.LDKMonitorEvent.CommitmentTxBroadcasted) {
37 const commitment_tx_broadcasted: number = obj.commitment_tx_broadcasted;
38 const commitment_tx_broadcasted_hu_conv: OutPoint = new OutPoint(null, commitment_tx_broadcasted);
39 commitment_tx_broadcasted_hu_conv.ptrs_to.add(this);
40 this.commitment_tx_broadcasted = commitment_tx_broadcasted_hu_conv;
43 public MonitorEvent clone() {
44 number ret = bindings.MonitorEvent_clone(this.ptr);
45 MonitorEvent ret_hu_conv = MonitorEvent.constr_from_ptr(ret);
46 ret_hu_conv.ptrs_to.add(this);