X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=ts%2Fstructs%2FChannelHandshakeConfig.mts;h=22b11aad40678270561baffab86e3737ee750a6a;hb=0fcde6be16ac8c2d63bd5398d5396da5890461d7;hp=25ab216c7b6d89156ab23347d3cb1538eae242e3;hpb=bf08029c1ad5244b59902eada723b634dcade62d;p=ldk-java diff --git a/ts/structs/ChannelHandshakeConfig.mts b/ts/structs/ChannelHandshakeConfig.mts index 25ab216c..22b11aad 100644 --- a/ts/structs/ChannelHandshakeConfig.mts +++ b/ts/structs/ChannelHandshakeConfig.mts @@ -279,43 +279,116 @@ import { MultiThreadedLockableScore } from '../structs/MultiThreadedLockableScor import CommonBase from './CommonBase.mjs'; import * as bindings from '../bindings.mjs' -import * as InternalUtils from '../InternalUtils.mjs' +/** + * Configuration we set when applicable. + * + * Default::default() provides sane defaults. + */ export class ChannelHandshakeConfig extends CommonBase { /* @internal */ public constructor(_dummy: object, ptr: number) { super(ptr, bindings.ChannelHandshakeConfig_free); } + /** + * Confirmations we will wait for before considering the channel locked in. + * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the + * equivalent limit applied to outbound channels). + * + * Default value: 6. + */ public get_minimum_depth(): number { const ret: number = bindings.ChannelHandshakeConfig_get_minimum_depth(this.ptr); return ret; } + /** + * Confirmations we will wait for before considering the channel locked in. + * Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the + * equivalent limit applied to outbound channels). + * + * Default value: 6. + */ public set_minimum_depth(val: number): void { bindings.ChannelHandshakeConfig_set_minimum_depth(this.ptr, val); } + /** + * Set to the number of blocks we require our counterparty to wait to claim their money (ie + * the number of blocks we have to punish our counterparty if they broadcast a revoked + * transaction). + * + * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST + * be online to check for revoked transactions on-chain at least once every our_to_self_delay + * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction, + * possibly with time in between to RBF the spending transaction). + * + * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in + * case of an honest unilateral channel close, which implicitly decrease the economic value of + * our channel. + * + * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you + * can tweak config to ask for more security, not less. + */ public get_our_to_self_delay(): number { const ret: number = bindings.ChannelHandshakeConfig_get_our_to_self_delay(this.ptr); return ret; } + /** + * Set to the number of blocks we require our counterparty to wait to claim their money (ie + * the number of blocks we have to punish our counterparty if they broadcast a revoked + * transaction). + * + * This is one of the main parameters of our security model. We (or one of our watchtowers) MUST + * be online to check for revoked transactions on-chain at least once every our_to_self_delay + * blocks (minus some margin to allow us enough time to broadcast and confirm a transaction, + * possibly with time in between to RBF the spending transaction). + * + * Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in + * case of an honest unilateral channel close, which implicitly decrease the economic value of + * our channel. + * + * Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you + * can tweak config to ask for more security, not less. + */ public set_our_to_self_delay(val: number): void { bindings.ChannelHandshakeConfig_set_our_to_self_delay(this.ptr, val); } - public get_our_htlc_minimum_msat(): number { - const ret: number = bindings.ChannelHandshakeConfig_get_our_htlc_minimum_msat(this.ptr); + /** + * Set to the smallest value HTLC we will accept to process. + * + * This value is sent to our counterparty on channel-open and we close the channel any time + * our counterparty misbehaves by sending us an HTLC with a value smaller than this. + * + * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required + * by the protocol. + */ + public get_our_htlc_minimum_msat(): bigint { + const ret: bigint = bindings.ChannelHandshakeConfig_get_our_htlc_minimum_msat(this.ptr); return ret; } - public set_our_htlc_minimum_msat(val: number): void { + /** + * Set to the smallest value HTLC we will accept to process. + * + * This value is sent to our counterparty on channel-open and we close the channel any time + * our counterparty misbehaves by sending us an HTLC with a value smaller than this. + * + * Default value: 1. If the value is less than 1, it is ignored and set to 1, as is required + * by the protocol. + */ + public set_our_htlc_minimum_msat(val: bigint): void { bindings.ChannelHandshakeConfig_set_our_htlc_minimum_msat(this.ptr, val); } - public static constructor_new(minimum_depth_arg: number, our_to_self_delay_arg: number, our_htlc_minimum_msat_arg: number): ChannelHandshakeConfig { + /** + * Constructs a new ChannelHandshakeConfig given each field + */ + public static constructor_new(minimum_depth_arg: number, our_to_self_delay_arg: number, our_htlc_minimum_msat_arg: bigint): ChannelHandshakeConfig { const ret: number = bindings.ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg); const ret_hu_conv: ChannelHandshakeConfig = new ChannelHandshakeConfig(null, ret); CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv); @@ -327,6 +400,9 @@ export class ChannelHandshakeConfig extends CommonBase { return ret; } + /** + * Creates a copy of the ChannelHandshakeConfig + */ public clone(): ChannelHandshakeConfig { const ret: number = bindings.ChannelHandshakeConfig_clone(this.ptr); const ret_hu_conv: ChannelHandshakeConfig = new ChannelHandshakeConfig(null, ret); @@ -334,6 +410,9 @@ export class ChannelHandshakeConfig extends CommonBase { return ret_hu_conv; } + /** + * Creates a "default" ChannelHandshakeConfig. See struct and individual field documentaiton for details on which values are used. + */ public static constructor_default(): ChannelHandshakeConfig { const ret: number = bindings.ChannelHandshakeConfig_default(); const ret_hu_conv: ChannelHandshakeConfig = new ChannelHandshakeConfig(null, ret);