]> git.bitcoin.ninja Git - ldk-java/blob - ts/structs/Balance.ts
Merge pull request #47 from TheBlueMatt/main
[ldk-java] / ts / structs / Balance.ts
1
2 import CommonBase from './CommonBase';
3 import * as bindings from '../bindings' // TODO: figure out location
4
5 export default class Balance extends CommonBase {
6         protected constructor(_dummy: object, ptr: number) { super(ptr); }
7         protected finalize() {
8                 super.finalize();
9                 if (this.ptr != 0) { bindings.Balance_free(this.ptr); }
10         }
11         static constr_from_ptr(ptr: number): Balance {
12                 const raw_val: bindings.LDKBalance = bindings.LDKBalance_ref_from_ptr(ptr);
13                 if (raw_val instanceof bindings.LDKBalance.ClaimableOnChannelClose) {
14                         return new ClaimableOnChannelClose(this.ptr, raw_val);
15                 }
16                 if (raw_val instanceof bindings.LDKBalance.ClaimableAwaitingConfirmations) {
17                         return new ClaimableAwaitingConfirmations(this.ptr, raw_val);
18                 }
19                 if (raw_val instanceof bindings.LDKBalance.ContentiousClaimable) {
20                         return new ContentiousClaimable(this.ptr, raw_val);
21                 }
22                 if (raw_val instanceof bindings.LDKBalance.MaybeClaimableHTLCAwaitingTimeout) {
23                         return new MaybeClaimableHTLCAwaitingTimeout(this.ptr, raw_val);
24                 }
25                 throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface
26         }
27
28 }
29 export class ClaimableOnChannelClose extends Balance {
30         public claimable_amount_satoshis: number;
31         private constructor(ptr: number, obj: bindings.LDKBalance.ClaimableOnChannelClose) {
32                 super(null, ptr);
33                 this.claimable_amount_satoshis = obj.claimable_amount_satoshis;
34         }
35 }
36 export class ClaimableAwaitingConfirmations extends Balance {
37         public claimable_amount_satoshis: number;
38         public confirmation_height: number;
39         private constructor(ptr: number, obj: bindings.LDKBalance.ClaimableAwaitingConfirmations) {
40                 super(null, ptr);
41                 this.claimable_amount_satoshis = obj.claimable_amount_satoshis;
42                 this.confirmation_height = obj.confirmation_height;
43         }
44 }
45 export class ContentiousClaimable extends Balance {
46         public claimable_amount_satoshis: number;
47         public timeout_height: number;
48         private constructor(ptr: number, obj: bindings.LDKBalance.ContentiousClaimable) {
49                 super(null, ptr);
50                 this.claimable_amount_satoshis = obj.claimable_amount_satoshis;
51                 this.timeout_height = obj.timeout_height;
52         }
53 }
54 export class MaybeClaimableHTLCAwaitingTimeout extends Balance {
55         public claimable_amount_satoshis: number;
56         public claimable_height: number;
57         private constructor(ptr: number, obj: bindings.LDKBalance.MaybeClaimableHTLCAwaitingTimeout) {
58                 super(null, ptr);
59                 this.claimable_amount_satoshis = obj.claimable_amount_satoshis;
60                 this.claimable_height = obj.claimable_height;
61         }
62 }
63         public Balance clone() {
64                 number ret = bindings.Balance_clone(this.ptr);
65                 Balance ret_hu_conv = Balance.constr_from_ptr(ret);
66                 ret_hu_conv.ptrs_to.add(this);
67                 return ret_hu_conv;
68         }
69
70         public static Balance constructor_claimable_on_channel_close(number claimable_amount_satoshis) {
71                 number ret = bindings.Balance_claimable_on_channel_close(claimable_amount_satoshis);
72                 Balance ret_hu_conv = Balance.constr_from_ptr(ret);
73                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
74                 return ret_hu_conv;
75         }
76
77         public static Balance constructor_claimable_awaiting_confirmations(number claimable_amount_satoshis, number confirmation_height) {
78                 number ret = bindings.Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
79                 Balance ret_hu_conv = Balance.constr_from_ptr(ret);
80                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
81                 return ret_hu_conv;
82         }
83
84         public static Balance constructor_contentious_claimable(number claimable_amount_satoshis, number timeout_height) {
85                 number ret = bindings.Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
86                 Balance ret_hu_conv = Balance.constr_from_ptr(ret);
87                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
88                 return ret_hu_conv;
89         }
90
91         public static Balance constructor_maybe_claimable_htlcawaiting_timeout(number claimable_amount_satoshis, number claimable_height) {
92                 number ret = bindings.Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
93                 Balance ret_hu_conv = Balance.constr_from_ptr(ret);
94                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
95                 return ret_hu_conv;
96         }
97
98         public boolean eq(Balance b) {
99                 boolean ret = bindings.Balance_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
100                 return ret;
101         }
102
103 }