[TS] Update auto-generated TypeScript Bindings
[ldk-java] / ts / structs / Balance.mts
index 1d0771d30d8c63474c8c1aca613c0680f24ebc09..32e7f02bd158dbe96e614b4ca533098ab5b0b292 100644 (file)
@@ -279,26 +279,26 @@ import { MultiThreadedLockableScore } from '../structs/MultiThreadedLockableScor
 
 import CommonBase from './CommonBase.mjs';
 import * as bindings from '../bindings.mjs'
-import * as InternalUtils from '../InternalUtils.mjs'
 
+/**
+ * Details about the balance(s) available for spending once the channel appears on chain.
+ * 
+ * See [`ChannelMonitor::get_claimable_balances`] for more details on when these will or will not
+ * be provided.
+ */
 export class Balance extends CommonBase {
        protected constructor(_dummy: object, ptr: number) { super(ptr, bindings.Balance_free); }
        /* @internal */
        public static constr_from_ptr(ptr: number): Balance {
-               const raw_val: bindings.LDKBalance = bindings.LDKBalance_ref_from_ptr(ptr);
-               if (raw_val instanceof bindings.LDKBalance_ClaimableOnChannelClose) {
-                       return new Balance_ClaimableOnChannelClose(ptr, raw_val);
+               const raw_ty: number = bindings.LDKBalance_ty_from_ptr(ptr);
+               switch (raw_ty) {
+                       case 0: return new Balance_ClaimableOnChannelClose(ptr);
+                       case 1: return new Balance_ClaimableAwaitingConfirmations(ptr);
+                       case 2: return new Balance_ContentiousClaimable(ptr);
+                       case 3: return new Balance_MaybeClaimableHTLCAwaitingTimeout(ptr);
+                       default:
+                               throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface
                }
-               if (raw_val instanceof bindings.LDKBalance_ClaimableAwaitingConfirmations) {
-                       return new Balance_ClaimableAwaitingConfirmations(ptr, raw_val);
-               }
-               if (raw_val instanceof bindings.LDKBalance_ContentiousClaimable) {
-                       return new Balance_ContentiousClaimable(ptr, raw_val);
-               }
-               if (raw_val instanceof bindings.LDKBalance_MaybeClaimableHTLCAwaitingTimeout) {
-                       return new Balance_MaybeClaimableHTLCAwaitingTimeout(ptr, raw_val);
-               }
-               throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface
        }
 
        public clone_ptr(): number {
@@ -306,6 +306,9 @@ export class Balance extends CommonBase {
                return ret;
        }
 
+       /**
+        * Creates a copy of the Balance
+        */
        public clone(): Balance {
                const ret: number = bindings.Balance_clone(this.ptr);
                const ret_hu_conv: Balance = Balance.constr_from_ptr(ret);
@@ -313,75 +316,123 @@ export class Balance extends CommonBase {
                return ret_hu_conv;
        }
 
-       public static constructor_claimable_on_channel_close(claimable_amount_satoshis: number): Balance {
+       /**
+        * Utility method to constructs a new ClaimableOnChannelClose-variant Balance
+        */
+       public static constructor_claimable_on_channel_close(claimable_amount_satoshis: bigint): Balance {
                const ret: number = bindings.Balance_claimable_on_channel_close(claimable_amount_satoshis);
                const ret_hu_conv: Balance = Balance.constr_from_ptr(ret);
                CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
                return ret_hu_conv;
        }
 
-       public static constructor_claimable_awaiting_confirmations(claimable_amount_satoshis: number, confirmation_height: number): Balance {
+       /**
+        * Utility method to constructs a new ClaimableAwaitingConfirmations-variant Balance
+        */
+       public static constructor_claimable_awaiting_confirmations(claimable_amount_satoshis: bigint, confirmation_height: number): Balance {
                const ret: number = bindings.Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
                const ret_hu_conv: Balance = Balance.constr_from_ptr(ret);
                CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
                return ret_hu_conv;
        }
 
-       public static constructor_contentious_claimable(claimable_amount_satoshis: number, timeout_height: number): Balance {
+       /**
+        * Utility method to constructs a new ContentiousClaimable-variant Balance
+        */
+       public static constructor_contentious_claimable(claimable_amount_satoshis: bigint, timeout_height: number): Balance {
                const ret: number = bindings.Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
                const ret_hu_conv: Balance = Balance.constr_from_ptr(ret);
                CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
                return ret_hu_conv;
        }
 
-       public static constructor_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis: number, claimable_height: number): Balance {
+       /**
+        * Utility method to constructs a new MaybeClaimableHTLCAwaitingTimeout-variant Balance
+        */
+       public static constructor_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis: bigint, claimable_height: number): Balance {
                const ret: number = bindings.Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
                const ret_hu_conv: Balance = Balance.constr_from_ptr(ret);
                CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
                return ret_hu_conv;
        }
 
+       /**
+        * Checks if two Balances contain equal inner contents.
+        * This ignores pointers and is_owned flags and looks at the values in fields.
+        */
        public eq(b: Balance): boolean {
                const ret: boolean = bindings.Balance_eq(this.ptr, b == null ? 0 : CommonBase.get_ptr_of(b) & ~1);
                return ret;
        }
 
 }
+/** A Balance of type ClaimableOnChannelClose */
 export class Balance_ClaimableOnChannelClose extends Balance {
-       public claimable_amount_satoshis: number;
+       /**
+        * The amount available to claim, in satoshis, excluding the on-chain fees which will be
+        * required to do so.
+        */
+       public claimable_amount_satoshis: bigint;
        /* @internal */
-       public constructor(ptr: number, obj: bindings.LDKBalance_ClaimableOnChannelClose) {
+       public constructor(ptr: number) {
                super(null, ptr);
-               this.claimable_amount_satoshis = obj.claimable_amount_satoshis;
+               this.claimable_amount_satoshis = bindings.LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis(ptr);
        }
 }
+/** A Balance of type ClaimableAwaitingConfirmations */
 export class Balance_ClaimableAwaitingConfirmations extends Balance {
-       public claimable_amount_satoshis: number;
+       /**
+        * The amount available to claim, in satoshis, possibly excluding the on-chain fees which
+        * were spent in broadcasting the transaction.
+        */
+       public claimable_amount_satoshis: bigint;
+       /**
+        * The height at which an [`Event::SpendableOutputs`] event will be generated for this
+        * amount.
+        */
        public confirmation_height: number;
        /* @internal */
-       public constructor(ptr: number, obj: bindings.LDKBalance_ClaimableAwaitingConfirmations) {
+       public constructor(ptr: number) {
                super(null, ptr);
-               this.claimable_amount_satoshis = obj.claimable_amount_satoshis;
-               this.confirmation_height = obj.confirmation_height;
+               this.claimable_amount_satoshis = bindings.LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis(ptr);
+               this.confirmation_height = bindings.LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height(ptr);
        }
 }
+/** A Balance of type ContentiousClaimable */
 export class Balance_ContentiousClaimable extends Balance {
-       public claimable_amount_satoshis: number;
+       /**
+        * The amount available to claim, in satoshis, excluding the on-chain fees which will be
+        * required to do so.
+        */
+       public claimable_amount_satoshis: bigint;
+       /**
+        * The height at which the counterparty may be able to claim the balance if we have not
+        * done so.
+        */
        public timeout_height: number;
        /* @internal */
-       public constructor(ptr: number, obj: bindings.LDKBalance_ContentiousClaimable) {
+       public constructor(ptr: number) {
                super(null, ptr);
-               this.claimable_amount_satoshis = obj.claimable_amount_satoshis;
-               this.timeout_height = obj.timeout_height;
+               this.claimable_amount_satoshis = bindings.LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis(ptr);
+               this.timeout_height = bindings.LDKBalance_ContentiousClaimable_get_timeout_height(ptr);
        }
 }
+/** A Balance of type MaybeClaimableHTLCAwaitingTimeout */
 export class Balance_MaybeClaimableHTLCAwaitingTimeout extends Balance {
-       public claimable_amount_satoshis: number;
+       /**
+        * The amount available to claim, in satoshis, excluding the on-chain fees which will be
+        * required to do so.
+        */
+       public claimable_amount_satoshis: bigint;
+       /**
+        * The height at which we will be able to claim the balance if our counterparty has not
+        * done so.
+        */
        public claimable_height: number;
        /* @internal */
-       public constructor(ptr: number, obj: bindings.LDKBalance_MaybeClaimableHTLCAwaitingTimeout) {
+       public constructor(ptr: number) {
                super(null, ptr);
-               this.claimable_amount_satoshis = obj.claimable_amount_satoshis;
-               this.claimable_height = obj.claimable_height;
+               this.claimable_amount_satoshis = bindings.LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis(ptr);
+               this.claimable_height = bindings.LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height(ptr);
        }
 }