]> git.bitcoin.ninja Git - ldk-java/blob - ts/structs/APIError.ts
Update CI references to LDK 0.0.125
[ldk-java] / ts / structs / APIError.ts
1
2 import CommonBase from './CommonBase';
3 import * as bindings from '../bindings' // TODO: figure out location
4
5 export default class APIError extends CommonBase {
6         protected constructor(_dummy: object, ptr: number) { super(ptr); }
7         protected finalize() {
8                 super.finalize();
9                 if (this.ptr != 0) { bindings.APIError_free(this.ptr); }
10         }
11         static constr_from_ptr(ptr: number): APIError {
12                 const raw_val: bindings.LDKAPIError = bindings.LDKAPIError_ref_from_ptr(ptr);
13                 if (raw_val instanceof bindings.LDKAPIError.APIMisuseError) {
14                         return new APIMisuseError(this.ptr, raw_val);
15                 }
16                 if (raw_val instanceof bindings.LDKAPIError.FeeRateTooHigh) {
17                         return new FeeRateTooHigh(this.ptr, raw_val);
18                 }
19                 if (raw_val instanceof bindings.LDKAPIError.RouteError) {
20                         return new RouteError(this.ptr, raw_val);
21                 }
22                 if (raw_val instanceof bindings.LDKAPIError.ChannelUnavailable) {
23                         return new ChannelUnavailable(this.ptr, raw_val);
24                 }
25                 if (raw_val instanceof bindings.LDKAPIError.MonitorUpdateFailed) {
26                         return new MonitorUpdateFailed(this.ptr, raw_val);
27                 }
28                 throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface
29         }
30
31 }
32 export class APIMisuseError extends APIError {
33         public err: String;
34         private constructor(ptr: number, obj: bindings.LDKAPIError.APIMisuseError) {
35                 super(null, ptr);
36                 this.err = obj.err;
37         }
38 }
39 export class FeeRateTooHigh extends APIError {
40         public err: String;
41         public feerate: number;
42         private constructor(ptr: number, obj: bindings.LDKAPIError.FeeRateTooHigh) {
43                 super(null, ptr);
44                 this.err = obj.err;
45                 this.feerate = obj.feerate;
46         }
47 }
48 export class RouteError extends APIError {
49         public err: String;
50         private constructor(ptr: number, obj: bindings.LDKAPIError.RouteError) {
51                 super(null, ptr);
52                 this.err = obj.err;
53         }
54 }
55 export class ChannelUnavailable extends APIError {
56         public err: String;
57         private constructor(ptr: number, obj: bindings.LDKAPIError.ChannelUnavailable) {
58                 super(null, ptr);
59                 this.err = obj.err;
60         }
61 }
62 export class MonitorUpdateFailed extends APIError {
63         private constructor(ptr: number, obj: bindings.LDKAPIError.MonitorUpdateFailed) {
64                 super(null, ptr);
65         }
66 }
67         public APIError clone() {
68                 number ret = bindings.APIError_clone(this.ptr);
69                 APIError ret_hu_conv = APIError.constr_from_ptr(ret);
70                 ret_hu_conv.ptrs_to.add(this);
71                 return ret_hu_conv;
72         }
73
74 }