X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=c_sharp%2Fsrc%2Forg%2Fldk%2Fstructs%2FChannelMonitor.cs;fp=c_sharp%2Fsrc%2Forg%2Fldk%2Fstructs%2FChannelMonitor.cs;h=3476e527ad3e177cbfc7676896dc6708c40b200b;hb=592c64eb658d92e314a2b983cea16cecf3882474;hp=f16d4fd3f07589935f5a16c40a183f0f97b63f1d;hpb=12fdbefaac81d5b4be6bb67addd6dcd7c46a182b;p=ldk-java diff --git a/c_sharp/src/org/ldk/structs/ChannelMonitor.cs b/c_sharp/src/org/ldk/structs/ChannelMonitor.cs index f16d4fd3..3476e527 100644 --- a/c_sharp/src/org/ldk/structs/ChannelMonitor.cs +++ b/c_sharp/src/org/ldk/structs/ChannelMonitor.cs @@ -61,7 +61,7 @@ public class ChannelMonitor : CommonBase { * panics if the given update is not the next update by update_id. */ public Result_NoneNoneZ update_monitor(org.ldk.structs.ChannelMonitorUpdate updates, org.ldk.structs.BroadcasterInterface broadcaster, org.ldk.structs.FeeEstimator fee_estimator, org.ldk.structs.Logger logger) { - long ret = bindings.ChannelMonitor_update_monitor(this.ptr, updates == null ? 0 : updates.ptr, broadcaster.ptr, fee_estimator.ptr, logger.ptr); + long ret = bindings.ChannelMonitor_update_monitor(this.ptr, updates.ptr, broadcaster.ptr, fee_estimator.ptr, logger.ptr); GC.KeepAlive(this); GC.KeepAlive(updates); GC.KeepAlive(broadcaster); @@ -98,6 +98,18 @@ public class ChannelMonitor : CommonBase { return ret_hu_conv; } + /** + * Gets the channel_id of the channel this ChannelMonitor is monitoring for. + */ + public ChannelId channel_id() { + long ret = bindings.ChannelMonitor_channel_id(this.ptr); + GC.KeepAlive(this); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.ChannelId ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.ChannelId(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); }; + return ret_hu_conv; + } + /** * Gets a list of txids, with their output scripts (in the order they appear in the * transaction), which we must learn about spends of via block_connected(). @@ -222,7 +234,7 @@ public class ChannelMonitor : CommonBase { * [`Persist::update_persisted_channel`]: crate::chain::chainmonitor::Persist::update_persisted_channel */ public CommitmentTransaction[] counterparty_commitment_txs_from_update(org.ldk.structs.ChannelMonitorUpdate update) { - long ret = bindings.ChannelMonitor_counterparty_commitment_txs_from_update(this.ptr, update == null ? 0 : update.ptr); + long ret = bindings.ChannelMonitor_counterparty_commitment_txs_from_update(this.ptr, update.ptr); GC.KeepAlive(this); GC.KeepAlive(update); if (ret >= 0 && ret <= 4096) { return null; } @@ -287,36 +299,25 @@ public class ChannelMonitor : CommonBase { } /** - * Used by [`ChannelManager`] deserialization to broadcast the latest holder state if its copy - * of the channel state was out-of-date. - * - * You may also use this to broadcast the latest local commitment transaction, either because + * You may use this to broadcast the latest local commitment transaction, either because * a monitor update failed or because we've fallen behind (i.e. we've received proof that our * counterparty side knows a revocation secret we gave them that they shouldn't know). * - * Broadcasting these transactions in the second case is UNSAFE, as they allow counterparty + * Broadcasting these transactions in this manner is UNSAFE, as they allow counterparty * side to punish you. Nevertheless you may want to broadcast them if counterparty doesn't * close channel with their commitment transaction after a substantial amount of time. Best * may be to contact the other node operator out-of-band to coordinate other options available * to you. - * - * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager */ - public byte[][] get_latest_holder_commitment_txn(org.ldk.structs.Logger logger) { - long ret = bindings.ChannelMonitor_get_latest_holder_commitment_txn(this.ptr, logger.ptr); + public void broadcast_latest_holder_commitment_txn(org.ldk.structs.BroadcasterInterface broadcaster, org.ldk.structs.FeeEstimator fee_estimator, org.ldk.structs.Logger logger) { + bindings.ChannelMonitor_broadcast_latest_holder_commitment_txn(this.ptr, broadcaster.ptr, fee_estimator.ptr, logger.ptr); GC.KeepAlive(this); + GC.KeepAlive(broadcaster); + GC.KeepAlive(fee_estimator); GC.KeepAlive(logger); - if (ret >= 0 && ret <= 4096) { return null; } - int ret_conv_8_len = InternalUtils.getArrayLength(ret); - byte[][] ret_conv_8_arr = new byte[ret_conv_8_len][]; - for (int i = 0; i < ret_conv_8_len; i++) { - long ret_conv_8 = InternalUtils.getU64ArrayElem(ret, i); - byte[] ret_conv_8_conv = InternalUtils.decodeUint8Array(ret_conv_8); - ret_conv_8_arr[i] = ret_conv_8_conv; - } - bindings.free_buffer(ret); + if (this != null) { this.ptrs_to.AddLast(broadcaster); }; + if (this != null) { this.ptrs_to.AddLast(fee_estimator); }; if (this != null) { this.ptrs_to.AddLast(logger); }; - return ret_conv_8_arr; } /** @@ -333,7 +334,7 @@ public class ChannelMonitor : CommonBase { * [`get_outputs_to_watch`]: #method.get_outputs_to_watch */ public TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ[] block_connected(byte[] header, TwoTuple_usizeTransactionZ[] txdata, int height, org.ldk.structs.BroadcasterInterface broadcaster, org.ldk.structs.FeeEstimator fee_estimator, org.ldk.structs.Logger logger) { - long ret = bindings.ChannelMonitor_block_connected(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(header, 80)), InternalUtils.encodeUint64Array(InternalUtils.mapArray(txdata, txdata_conv_28 => txdata_conv_28 != null ? txdata_conv_28.ptr : 0)), height, broadcaster.ptr, fee_estimator.ptr, logger.ptr); + long ret = bindings.ChannelMonitor_block_connected(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(header, 80)), InternalUtils.encodeUint64Array(InternalUtils.mapArray(txdata, txdata_conv_28 => txdata_conv_28.ptr)), height, broadcaster.ptr, fee_estimator.ptr, logger.ptr); GC.KeepAlive(this); GC.KeepAlive(header); GC.KeepAlive(txdata); @@ -384,7 +385,7 @@ public class ChannelMonitor : CommonBase { * [`block_connected`]: Self::block_connected */ public TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ[] transactions_confirmed(byte[] header, TwoTuple_usizeTransactionZ[] txdata, int height, org.ldk.structs.BroadcasterInterface broadcaster, org.ldk.structs.FeeEstimator fee_estimator, org.ldk.structs.Logger logger) { - long ret = bindings.ChannelMonitor_transactions_confirmed(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(header, 80)), InternalUtils.encodeUint64Array(InternalUtils.mapArray(txdata, txdata_conv_28 => txdata_conv_28 != null ? txdata_conv_28.ptr : 0)), height, broadcaster.ptr, fee_estimator.ptr, logger.ptr); + long ret = bindings.ChannelMonitor_transactions_confirmed(this.ptr, InternalUtils.encodeUint8Array(InternalUtils.check_arr_len(header, 80)), InternalUtils.encodeUint64Array(InternalUtils.mapArray(txdata, txdata_conv_28 => txdata_conv_28.ptr)), height, broadcaster.ptr, fee_estimator.ptr, logger.ptr); GC.KeepAlive(this); GC.KeepAlive(header); GC.KeepAlive(txdata); @@ -511,6 +512,21 @@ public class ChannelMonitor : CommonBase { if (this != null) { this.ptrs_to.AddLast(logger); }; } + /** + * Triggers rebroadcasts of pending claims from a force-closed channel after a transaction + * signature generation failure. + */ + public void signer_unblocked(org.ldk.structs.BroadcasterInterface broadcaster, org.ldk.structs.FeeEstimator fee_estimator, org.ldk.structs.Logger logger) { + bindings.ChannelMonitor_signer_unblocked(this.ptr, broadcaster.ptr, fee_estimator.ptr, logger.ptr); + GC.KeepAlive(this); + GC.KeepAlive(broadcaster); + GC.KeepAlive(fee_estimator); + GC.KeepAlive(logger); + if (this != null) { this.ptrs_to.AddLast(broadcaster); }; + if (this != null) { this.ptrs_to.AddLast(fee_estimator); }; + if (this != null) { this.ptrs_to.AddLast(logger); }; + } + /** * Returns the descriptors for relevant outputs (i.e., those that we can spend) within the * transaction if they exist and the transaction has at least [`ANTI_REORG_DELAY`] @@ -549,6 +565,21 @@ public class ChannelMonitor : CommonBase { return ret_conv_27_arr; } + /** + * Checks if the monitor is fully resolved. Resolved monitor is one that has claimed all of + * its outputs and balances (i.e. [`Self::get_claimable_balances`] returns an empty set). + * + * This function returns true only if [`Self::get_claimable_balances`] has been empty for at least + * 4032 blocks as an additional protection against any bugs resulting in spuriously empty balance sets. + */ + public bool is_fully_resolved(org.ldk.structs.Logger logger) { + bool ret = bindings.ChannelMonitor_is_fully_resolved(this.ptr, logger.ptr); + GC.KeepAlive(this); + GC.KeepAlive(logger); + if (this != null) { this.ptrs_to.AddLast(logger); }; + return ret; + } + /** * Gets the balances in this channel which are either claimable by us if we were to * force-close the channel now or which are claimable on-chain (possibly awaiting