X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FChainMonitor.java;h=8d68f8f1b0d301d8b951a9a2bd0e12665b4c0550;hb=HEAD;hp=9c83ff243ea5b77c52a8edb8ac0f6c602356133c;hpb=a672396f21c0448656bb400cfe28b9df6e5a842b;p=ldk-java diff --git a/src/main/java/org/ldk/structs/ChainMonitor.java b/src/main/java/org/ldk/structs/ChainMonitor.java index 9c83ff24..8d68f8f1 100644 --- a/src/main/java/org/ldk/structs/ChainMonitor.java +++ b/src/main/java/org/ldk/structs/ChainMonitor.java @@ -45,7 +45,7 @@ public class ChainMonitor extends CommonBase { * transactions relevant to the watched channels. */ public static ChainMonitor of(org.ldk.structs.Option_FilterZ chain_source, org.ldk.structs.BroadcasterInterface broadcaster, org.ldk.structs.Logger logger, org.ldk.structs.FeeEstimator feeest, org.ldk.structs.Persist persister) { - long ret = bindings.ChainMonitor_new(chain_source.ptr, broadcaster == null ? 0 : broadcaster.ptr, logger == null ? 0 : logger.ptr, feeest == null ? 0 : feeest.ptr, persister == null ? 0 : persister.ptr); + long ret = bindings.ChainMonitor_new(chain_source.ptr, broadcaster.ptr, logger.ptr, feeest.ptr, persister.ptr); Reference.reachabilityFence(chain_source); Reference.reachabilityFence(broadcaster); Reference.reachabilityFence(logger); @@ -74,7 +74,7 @@ public class ChainMonitor extends CommonBase { * inclusion in the return value. */ public Balance[] get_claimable_balances(ChannelDetails[] ignored_channels) { - long[] ret = bindings.ChainMonitor_get_claimable_balances(this.ptr, ignored_channels != null ? Arrays.stream(ignored_channels).mapToLong(ignored_channels_conv_16 -> ignored_channels_conv_16 == null ? 0 : ignored_channels_conv_16.ptr).toArray() : null); + long[] ret = bindings.ChainMonitor_get_claimable_balances(this.ptr, ignored_channels != null ? Arrays.stream(ignored_channels).mapToLong(ignored_channels_conv_16 -> ignored_channels_conv_16.ptr).toArray() : null); Reference.reachabilityFence(this); Reference.reachabilityFence(ignored_channels); int ret_conv_9_len = ret.length; @@ -97,7 +97,7 @@ public class ChainMonitor extends CommonBase { * indefinitely. */ public Result_LockedChannelMonitorNoneZ get_monitor(org.ldk.structs.OutPoint funding_txo) { - long ret = bindings.ChainMonitor_get_monitor(this.ptr, funding_txo == null ? 0 : funding_txo.ptr); + long ret = bindings.ChainMonitor_get_monitor(this.ptr, funding_txo.ptr); Reference.reachabilityFence(this); Reference.reachabilityFence(funding_txo); if (ret >= 0 && ret <= 4096) { return null; } @@ -107,23 +107,23 @@ public class ChainMonitor extends CommonBase { } /** - * Lists the funding outpoint of each [`ChannelMonitor`] being monitored. + * Lists the funding outpoint and channel ID of each [`ChannelMonitor`] being monitored. * * Note that [`ChannelMonitor`]s are not removed when a channel is closed as they are always * monitoring for on-chain state resolutions. */ - public OutPoint[] list_monitors() { + public TwoTuple_OutPointChannelIdZ[] list_monitors() { long[] ret = bindings.ChainMonitor_list_monitors(this.ptr); Reference.reachabilityFence(this); - int ret_conv_10_len = ret.length; - OutPoint[] ret_conv_10_arr = new OutPoint[ret_conv_10_len]; - for (int k = 0; k < ret_conv_10_len; k++) { - long ret_conv_10 = ret[k]; - org.ldk.structs.OutPoint ret_conv_10_hu_conv = null; if (ret_conv_10 < 0 || ret_conv_10 > 4096) { ret_conv_10_hu_conv = new org.ldk.structs.OutPoint(null, ret_conv_10); } - if (ret_conv_10_hu_conv != null) { ret_conv_10_hu_conv.ptrs_to.add(this); }; - ret_conv_10_arr[k] = ret_conv_10_hu_conv; + int ret_conv_29_len = ret.length; + TwoTuple_OutPointChannelIdZ[] ret_conv_29_arr = new TwoTuple_OutPointChannelIdZ[ret_conv_29_len]; + for (int d = 0; d < ret_conv_29_len; d++) { + long ret_conv_29 = ret[d]; + TwoTuple_OutPointChannelIdZ ret_conv_29_hu_conv = new TwoTuple_OutPointChannelIdZ(null, ret_conv_29); + if (ret_conv_29_hu_conv != null) { ret_conv_29_hu_conv.ptrs_to.add(this); }; + ret_conv_29_arr[d] = ret_conv_29_hu_conv; } - return ret_conv_10_arr; + return ret_conv_29_arr; } /** @@ -159,7 +159,7 @@ public class ChainMonitor extends CommonBase { * registered [`ChannelMonitor`]s. */ public Result_NoneAPIErrorZ channel_monitor_updated(org.ldk.structs.OutPoint funding_txo, org.ldk.structs.MonitorUpdateId completed_update_id) { - long ret = bindings.ChainMonitor_channel_monitor_updated(this.ptr, funding_txo == null ? 0 : funding_txo.ptr, completed_update_id == null ? 0 : completed_update_id.ptr); + long ret = bindings.ChainMonitor_channel_monitor_updated(this.ptr, funding_txo.ptr, completed_update_id.ptr); Reference.reachabilityFence(this); Reference.reachabilityFence(funding_txo); Reference.reachabilityFence(completed_update_id); @@ -201,6 +201,37 @@ public class ChainMonitor extends CommonBase { Reference.reachabilityFence(this); } + /** + * Triggers rebroadcasts of pending claims from force-closed channels after a transaction + * signature generation failure. + * + * `monitor_opt` can be used as a filter to only trigger them for a specific channel monitor. + * + * Note that monitor_opt (or a relevant inner pointer) may be NULL or all-0s to represent None + */ + public void signer_unblocked(@Nullable org.ldk.structs.OutPoint monitor_opt) { + bindings.ChainMonitor_signer_unblocked(this.ptr, monitor_opt == null ? 0 : monitor_opt.ptr); + Reference.reachabilityFence(this); + Reference.reachabilityFence(monitor_opt); + if (this != null) { this.ptrs_to.add(monitor_opt); }; + } + + /** + * Archives fully resolved channel monitors by calling [`Persist::archive_persisted_channel`]. + * + * This is useful for pruning fully resolved monitors from the monitor set and primary + * storage so they are not kept in memory and reloaded on restart. + * + * Should be called occasionally (once every handful of blocks or on startup). + * + * Depending on the implementation of [`Persist::archive_persisted_channel`] the monitor + * data could be moved to an archive location or removed entirely. + */ + public void archive_fully_resolved_channel_monitors() { + bindings.ChainMonitor_archive_fully_resolved_channel_monitors(this.ptr); + Reference.reachabilityFence(this); + } + /** * Constructs a new Listen which calls the relevant methods on this_arg. * This copies the `inner` pointer in this_arg and thus the returned Listen must be freed before this_arg is