2 import CommonBase from './CommonBase';
3 import * as bindings from '../bindings' // TODO: figure out location
5 export default class Balance extends CommonBase {
6 protected constructor(_dummy: object, ptr: number) { super(ptr); }
9 if (this.ptr != 0) { bindings.Balance_free(this.ptr); }
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);
16 if (raw_val instanceof bindings.LDKBalance.ClaimableAwaitingConfirmations) {
17 return new ClaimableAwaitingConfirmations(this.ptr, raw_val);
19 if (raw_val instanceof bindings.LDKBalance.ContentiousClaimable) {
20 return new ContentiousClaimable(this.ptr, raw_val);
22 if (raw_val instanceof bindings.LDKBalance.MaybeClaimableHTLCAwaitingTimeout) {
23 return new MaybeClaimableHTLCAwaitingTimeout(this.ptr, raw_val);
25 throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface
29 export class ClaimableOnChannelClose extends Balance {
30 public claimable_amount_satoshis: number;
31 private constructor(ptr: number, obj: bindings.LDKBalance.ClaimableOnChannelClose) {
33 this.claimable_amount_satoshis = obj.claimable_amount_satoshis;
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) {
41 this.claimable_amount_satoshis = obj.claimable_amount_satoshis;
42 this.confirmation_height = obj.confirmation_height;
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) {
50 this.claimable_amount_satoshis = obj.claimable_amount_satoshis;
51 this.timeout_height = obj.timeout_height;
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) {
59 this.claimable_amount_satoshis = obj.claimable_amount_satoshis;
60 this.claimable_height = obj.claimable_height;
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);
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);
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);
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);
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);
98 public boolean eq(Balance b) {
99 boolean ret = bindings.Balance_eq(this.ptr, b == null ? 0 : b.ptr & ~1);