X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=c_sharp%2Fsrc%2Forg%2Fldk%2Fstructs%2FBalance.cs;h=18313917f72c0f86b1b44b6b66edd23331d5b02a;hb=152d721883552dd92925833d15687d7d64d01c35;hp=3214edf09671f9756435ccd34f40fe2245c05c29;hpb=810f7404202e04f70db946ced7363b64ddaf4ce4;p=ldk-java diff --git a/c_sharp/src/org/ldk/structs/Balance.cs b/c_sharp/src/org/ldk/structs/Balance.cs index 3214edf0..18313917 100644 --- a/c_sharp/src/org/ldk/structs/Balance.cs +++ b/c_sharp/src/org/ldk/structs/Balance.cs @@ -37,9 +37,9 @@ public class Balance : CommonBase { * The amount available to claim, in satoshis, excluding the on-chain fees which will be * required to do so. */ - public long claimable_amount_satoshis; + public long amount_satoshis; internal Balance_ClaimableOnChannelClose(long ptr) : base(null, ptr) { - this.claimable_amount_satoshis = bindings.LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis(ptr); + this.amount_satoshis = bindings.LDKBalance_ClaimableOnChannelClose_get_amount_satoshis(ptr); } } /** A Balance of type ClaimableAwaitingConfirmations */ @@ -48,14 +48,14 @@ public class Balance : CommonBase { * The amount available to claim, in satoshis, possibly excluding the on-chain fees which * were spent in broadcasting the transaction. */ - public long claimable_amount_satoshis; + public long amount_satoshis; /** * The height at which an [`Event::SpendableOutputs`] event will be generated for this * amount. */ public int confirmation_height; internal Balance_ClaimableAwaitingConfirmations(long ptr) : base(null, ptr) { - this.claimable_amount_satoshis = bindings.LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis(ptr); + this.amount_satoshis = bindings.LDKBalance_ClaimableAwaitingConfirmations_get_amount_satoshis(ptr); this.confirmation_height = bindings.LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height(ptr); } } @@ -65,15 +65,29 @@ public class Balance : CommonBase { * The amount available to claim, in satoshis, excluding the on-chain fees which will be * required to do so. */ - public long claimable_amount_satoshis; + public long amount_satoshis; /** * The height at which the counterparty may be able to claim the balance if we have not * done so. */ public int timeout_height; + /** + * The payment hash that locks this HTLC. + */ + public byte[] payment_hash; + /** + * The preimage that can be used to claim this HTLC. + */ + public byte[] payment_preimage; internal Balance_ContentiousClaimable(long ptr) : base(null, ptr) { - this.claimable_amount_satoshis = bindings.LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis(ptr); + this.amount_satoshis = bindings.LDKBalance_ContentiousClaimable_get_amount_satoshis(ptr); this.timeout_height = bindings.LDKBalance_ContentiousClaimable_get_timeout_height(ptr); + long payment_hash = bindings.LDKBalance_ContentiousClaimable_get_payment_hash(ptr); + byte[] payment_hash_conv = InternalUtils.decodeUint8Array(payment_hash); + this.payment_hash = payment_hash_conv; + long payment_preimage = bindings.LDKBalance_ContentiousClaimable_get_payment_preimage(ptr); + byte[] payment_preimage_conv = InternalUtils.decodeUint8Array(payment_preimage); + this.payment_preimage = payment_preimage_conv; } } /** A Balance of type MaybeTimeoutClaimableHTLC */ @@ -82,15 +96,22 @@ public class Balance : CommonBase { * The amount potentially available to claim, in satoshis, excluding the on-chain fees * which will be required to do so. */ - public long claimable_amount_satoshis; + public long amount_satoshis; /** * The height at which we will be able to claim the balance if our counterparty has not * done so. */ public int claimable_height; + /** + * The payment hash whose preimage our counterparty needs to claim this HTLC. + */ + public byte[] payment_hash; internal Balance_MaybeTimeoutClaimableHTLC(long ptr) : base(null, ptr) { - this.claimable_amount_satoshis = bindings.LDKBalance_MaybeTimeoutClaimableHTLC_get_claimable_amount_satoshis(ptr); + this.amount_satoshis = bindings.LDKBalance_MaybeTimeoutClaimableHTLC_get_amount_satoshis(ptr); this.claimable_height = bindings.LDKBalance_MaybeTimeoutClaimableHTLC_get_claimable_height(ptr); + long payment_hash = bindings.LDKBalance_MaybeTimeoutClaimableHTLC_get_payment_hash(ptr); + byte[] payment_hash_conv = InternalUtils.decodeUint8Array(payment_hash); + this.payment_hash = payment_hash_conv; } } /** A Balance of type MaybePreimageClaimableHTLC */ @@ -99,15 +120,22 @@ public class Balance : CommonBase { * The amount potentially available to claim, in satoshis, excluding the on-chain fees * which will be required to do so. */ - public long claimable_amount_satoshis; + public long amount_satoshis; /** * The height at which our counterparty will be able to claim the balance if we have not * yet received the preimage and claimed it ourselves. */ public int expiry_height; + /** + * The payment hash whose preimage we need to claim this HTLC. + */ + public byte[] payment_hash; internal Balance_MaybePreimageClaimableHTLC(long ptr) : base(null, ptr) { - this.claimable_amount_satoshis = bindings.LDKBalance_MaybePreimageClaimableHTLC_get_claimable_amount_satoshis(ptr); + this.amount_satoshis = bindings.LDKBalance_MaybePreimageClaimableHTLC_get_amount_satoshis(ptr); this.expiry_height = bindings.LDKBalance_MaybePreimageClaimableHTLC_get_expiry_height(ptr); + long payment_hash = bindings.LDKBalance_MaybePreimageClaimableHTLC_get_payment_hash(ptr); + byte[] payment_hash_conv = InternalUtils.decodeUint8Array(payment_hash); + this.payment_hash = payment_hash_conv; } } /** A Balance of type CounterpartyRevokedOutputClaimable */ @@ -118,9 +146,9 @@ public class Balance : CommonBase { * Note that for outputs from HTLC balances this may be excluding some on-chain fees that * were already spent. */ - public long claimable_amount_satoshis; + public long amount_satoshis; internal Balance_CounterpartyRevokedOutputClaimable(long ptr) : base(null, ptr) { - this.claimable_amount_satoshis = bindings.LDKBalance_CounterpartyRevokedOutputClaimable_get_claimable_amount_satoshis(ptr); + this.amount_satoshis = bindings.LDKBalance_CounterpartyRevokedOutputClaimable_get_amount_satoshis(ptr); } } internal long clone_ptr() { @@ -144,9 +172,9 @@ public class Balance : CommonBase { /** * Utility method to constructs a new ClaimableOnChannelClose-variant Balance */ - public static Balance claimable_on_channel_close(long claimable_amount_satoshis) { - long ret = bindings.Balance_claimable_on_channel_close(claimable_amount_satoshis); - GC.KeepAlive(claimable_amount_satoshis); + public static Balance claimable_on_channel_close(long amount_satoshis) { + long ret = bindings.Balance_claimable_on_channel_close(amount_satoshis); + GC.KeepAlive(amount_satoshis); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.Balance ret_hu_conv = org.ldk.structs.Balance.constr_from_ptr(ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); }; @@ -156,9 +184,9 @@ public class Balance : CommonBase { /** * Utility method to constructs a new ClaimableAwaitingConfirmations-variant Balance */ - public static Balance claimable_awaiting_confirmations(long claimable_amount_satoshis, int confirmation_height) { - long ret = bindings.Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height); - GC.KeepAlive(claimable_amount_satoshis); + public static Balance claimable_awaiting_confirmations(long amount_satoshis, int confirmation_height) { + long ret = bindings.Balance_claimable_awaiting_confirmations(amount_satoshis, confirmation_height); + GC.KeepAlive(amount_satoshis); GC.KeepAlive(confirmation_height); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.Balance ret_hu_conv = org.ldk.structs.Balance.constr_from_ptr(ret); @@ -169,10 +197,12 @@ public class Balance : CommonBase { /** * Utility method to constructs a new ContentiousClaimable-variant Balance */ - public static Balance contentious_claimable(long claimable_amount_satoshis, int timeout_height) { - long ret = bindings.Balance_contentious_claimable(claimable_amount_satoshis, timeout_height); - GC.KeepAlive(claimable_amount_satoshis); + public static Balance contentious_claimable(long amount_satoshis, int timeout_height, byte[] payment_hash, byte[] payment_preimage) { + long ret = bindings.Balance_contentious_claimable(amount_satoshis, timeout_height, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32)), InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_preimage, 32))); + GC.KeepAlive(amount_satoshis); GC.KeepAlive(timeout_height); + GC.KeepAlive(payment_hash); + GC.KeepAlive(payment_preimage); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.Balance ret_hu_conv = org.ldk.structs.Balance.constr_from_ptr(ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); }; @@ -182,10 +212,11 @@ public class Balance : CommonBase { /** * Utility method to constructs a new MaybeTimeoutClaimableHTLC-variant Balance */ - public static Balance maybe_timeout_claimable_htlc(long claimable_amount_satoshis, int claimable_height) { - long ret = bindings.Balance_maybe_timeout_claimable_htlc(claimable_amount_satoshis, claimable_height); - GC.KeepAlive(claimable_amount_satoshis); + public static Balance maybe_timeout_claimable_htlc(long amount_satoshis, int claimable_height, byte[] payment_hash) { + long ret = bindings.Balance_maybe_timeout_claimable_htlc(amount_satoshis, claimable_height, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32))); + GC.KeepAlive(amount_satoshis); GC.KeepAlive(claimable_height); + GC.KeepAlive(payment_hash); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.Balance ret_hu_conv = org.ldk.structs.Balance.constr_from_ptr(ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); }; @@ -195,10 +226,11 @@ public class Balance : CommonBase { /** * Utility method to constructs a new MaybePreimageClaimableHTLC-variant Balance */ - public static Balance maybe_preimage_claimable_htlc(long claimable_amount_satoshis, int expiry_height) { - long ret = bindings.Balance_maybe_preimage_claimable_htlc(claimable_amount_satoshis, expiry_height); - GC.KeepAlive(claimable_amount_satoshis); + public static Balance maybe_preimage_claimable_htlc(long amount_satoshis, int expiry_height, byte[] payment_hash) { + long ret = bindings.Balance_maybe_preimage_claimable_htlc(amount_satoshis, expiry_height, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(payment_hash, 32))); + GC.KeepAlive(amount_satoshis); GC.KeepAlive(expiry_height); + GC.KeepAlive(payment_hash); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.Balance ret_hu_conv = org.ldk.structs.Balance.constr_from_ptr(ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); }; @@ -208,9 +240,9 @@ public class Balance : CommonBase { /** * Utility method to constructs a new CounterpartyRevokedOutputClaimable-variant Balance */ - public static Balance counterparty_revoked_output_claimable(long claimable_amount_satoshis) { - long ret = bindings.Balance_counterparty_revoked_output_claimable(claimable_amount_satoshis); - GC.KeepAlive(claimable_amount_satoshis); + public static Balance counterparty_revoked_output_claimable(long amount_satoshis) { + long ret = bindings.Balance_counterparty_revoked_output_claimable(amount_satoshis); + GC.KeepAlive(amount_satoshis); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.Balance ret_hu_conv = org.ldk.structs.Balance.constr_from_ptr(ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); }; @@ -222,7 +254,7 @@ public class Balance : CommonBase { * This ignores pointers and is_owned flags and looks at the values in fields. */ public bool eq(org.ldk.structs.Balance b) { - bool ret = bindings.Balance_eq(this.ptr, b == null ? 0 : b.ptr); + bool ret = bindings.Balance_eq(this.ptr, b.ptr); GC.KeepAlive(this); GC.KeepAlive(b); return ret; @@ -232,5 +264,19 @@ public class Balance : CommonBase { if (!(o is Balance)) return false; return this.eq((Balance)o); } + /** + * The amount claimable, in satoshis. This excludes balances that we are unsure if we are able + * to claim, this is because we are waiting for a preimage or for a timeout to expire. For more + * information on these balances see [`Balance::MaybeTimeoutClaimableHTLC`] and + * [`Balance::MaybePreimageClaimableHTLC`]. + * + * On-chain fees required to claim the balance are not included in this amount. + */ + public long claimable_amount_satoshis() { + long ret = bindings.Balance_claimable_amount_satoshis(this.ptr); + GC.KeepAlive(this); + return ret; + } + } } } }