Skip to content

Commit a7653cf

Browse files
committed
Update auto-generated bindings to 0.0.101
1 parent fcf4198 commit a7653cf

File tree

155 files changed

+18007
-4994
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+18007
-4994
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>org.lightningdevkit</groupId>
88
<artifactId>ldk-java</artifactId>
9-
<version>0.0.100.2</version>
9+
<version>0.0.101.0</version>
1010

1111
<name>LDK Java Bindings and Binaries</name>
1212
<description>LDK Java Bindings and Release Binaries</description>

src/main/java/org/ldk/enums/SemanticError.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ public enum SemanticError {
99
LDKSemanticError_MultiplePaymentHashes,
1010
LDKSemanticError_NoDescription,
1111
LDKSemanticError_MultipleDescriptions,
12+
LDKSemanticError_NoPaymentSecret,
1213
LDKSemanticError_MultiplePaymentSecrets,
1314
LDKSemanticError_InvalidFeatures,
1415
LDKSemanticError_InvalidRecoveryId,
1516
LDKSemanticError_InvalidSignature,
17+
LDKSemanticError_ImpreciseAmount,
1618
; static native void init();
1719
static { init(); }
1820
}

src/main/java/org/ldk/impl/bindings.java

Lines changed: 507 additions & 131 deletions
Large diffs are not rendered by default.

src/main/java/org/ldk/structs/BackgroundProcessor.java

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,28 @@
88

99

1010
/**
11-
* BackgroundProcessor takes care of tasks that (1) need to happen periodically to keep
11+
* `BackgroundProcessor` takes care of tasks that (1) need to happen periodically to keep
1212
* Rust-Lightning running properly, and (2) either can or should be run in the background. Its
1313
* responsibilities are:
14-
* Monitoring whether the ChannelManager needs to be re-persisted to disk, and if so,
14+
* Processing [`Event`]s with a user-provided [`EventHandler`].
15+
* Monitoring whether the [`ChannelManager`] needs to be re-persisted to disk, and if so,
1516
* writing it to disk/backups by invoking the callback given to it at startup.
16-
* ChannelManager persistence should be done in the background.
17-
* Calling `ChannelManager::timer_tick_occurred()` and
18-
* `PeerManager::timer_tick_occurred()` every minute (can be done in the
19-
* background).
17+
* [`ChannelManager`] persistence should be done in the background.
18+
* Calling [`ChannelManager::timer_tick_occurred`] and [`PeerManager::timer_tick_occurred`]
19+
* at the appropriate intervals.
2020
*
21-
* Note that if ChannelManager persistence fails and the persisted manager becomes out-of-date,
22-
* then there is a risk of channels force-closing on startup when the manager realizes it's
23-
* outdated. However, as long as `ChannelMonitor` backups are sound, no funds besides those used
24-
* for unilateral chain closure fees are at risk.
21+
* It will also call [`PeerManager::process_events`] periodically though this shouldn't be relied
22+
* upon as doing so may result in high latency.
23+
*
24+
* # Note
25+
*
26+
* If [`ChannelManager`] persistence fails and the persisted manager becomes out-of-date, then
27+
* there is a risk of channels force-closing on startup when the manager realizes it's outdated.
28+
* However, as long as [`ChannelMonitor`] backups are sound, no funds besides those used for
29+
* unilateral chain closure fees are at risk.
30+
*
31+
* [`ChannelMonitor`]: lightning::chain::channelmonitor::ChannelMonitor
32+
* [`Event`]: lightning::util::events::Event
2533
* BackgroundProcessor will immediately stop on drop. It should be stored until shutdown.
2634
*/
2735
@SuppressWarnings("unchecked") // We correctly assign various generic arrays
@@ -41,31 +49,44 @@ protected void finalize() throws Throwable {
4149
* `persist_manager` returns an error. In case of an error, the error is retrieved by calling
4250
* either [`join`] or [`stop`].
4351
*
44-
* Typically, users should either implement [`ChannelManagerPersister`] to never return an
45-
* error or call [`join`] and handle any error that may arise. For the latter case, the
46-
* `BackgroundProcessor` must be restarted by calling `start` again after handling the error.
52+
* # Data Persistence
4753
*
4854
* `persist_manager` is responsible for writing out the [`ChannelManager`] to disk, and/or
4955
* uploading to one or more backup services. See [`ChannelManager::write`] for writing out a
5056
* [`ChannelManager`]. See [`FilesystemPersister::persist_manager`] for Rust-Lightning's
5157
* provided implementation.
5258
*
59+
* Typically, users should either implement [`ChannelManagerPersister`] to never return an
60+
* error or call [`join`] and handle any error that may arise. For the latter case,
61+
* `BackgroundProcessor` must be restarted by calling `start` again after handling the error.
62+
*
63+
* # Event Handling
64+
*
65+
* `event_handler` is responsible for handling events that users should be notified of (e.g.,
66+
* payment failed). [`BackgroundProcessor`] may decorate the given [`EventHandler`] with common
67+
* functionality implemented by other handlers.
68+
* [`NetGraphMsgHandler`] if given will update the [`NetworkGraph`] based on payment failures.
69+
*
5370
* [top-level documentation]: Self
5471
* [`join`]: Self::join
5572
* [`stop`]: Self::stop
5673
* [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager
5774
* [`ChannelManager::write`]: lightning::ln::channelmanager::ChannelManager#impl-Writeable
5875
* [`FilesystemPersister::persist_manager`]: lightning_persister::FilesystemPersister::persist_manager
76+
* [`NetworkGraph`]: lightning::routing::network_graph::NetworkGraph
77+
*
78+
* Note that net_graph_msg_handler (or a relevant inner pointer) may be NULL or all-0s to represent None
5979
*/
60-
public static BackgroundProcessor start(ChannelManagerPersister persister, EventHandler event_handler, ChainMonitor chain_monitor, ChannelManager channel_manager, PeerManager peer_manager, Logger logger) {
61-
long ret = bindings.BackgroundProcessor_start(persister == null ? 0 : persister.ptr, event_handler == null ? 0 : event_handler.ptr, chain_monitor == null ? 0 : chain_monitor.ptr & ~1, channel_manager == null ? 0 : channel_manager.ptr & ~1, peer_manager == null ? 0 : peer_manager.ptr & ~1, logger == null ? 0 : logger.ptr);
80+
public static BackgroundProcessor start(ChannelManagerPersister persister, EventHandler event_handler, ChainMonitor chain_monitor, ChannelManager channel_manager, NetGraphMsgHandler net_graph_msg_handler, PeerManager peer_manager, Logger logger) {
81+
long ret = bindings.BackgroundProcessor_start(persister == null ? 0 : persister.ptr, event_handler == null ? 0 : event_handler.ptr, chain_monitor == null ? 0 : chain_monitor.ptr & ~1, channel_manager == null ? 0 : channel_manager.ptr & ~1, net_graph_msg_handler == null ? 0 : net_graph_msg_handler.ptr & ~1, peer_manager == null ? 0 : peer_manager.ptr & ~1, logger == null ? 0 : logger.ptr);
6282
if (ret < 1024) { return null; }
6383
BackgroundProcessor ret_hu_conv = new BackgroundProcessor(null, ret);
6484
ret_hu_conv.ptrs_to.add(ret_hu_conv);
6585
ret_hu_conv.ptrs_to.add(persister);
6686
ret_hu_conv.ptrs_to.add(event_handler);
6787
ret_hu_conv.ptrs_to.add(chain_monitor);
6888
ret_hu_conv.ptrs_to.add(channel_manager);
89+
ret_hu_conv.ptrs_to.add(net_graph_msg_handler);
6990
ret_hu_conv.ptrs_to.add(peer_manager);
7091
ret_hu_conv.ptrs_to.add(logger);
7192
return ret_hu_conv;
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
package org.ldk.structs;
2+
3+
import org.ldk.impl.bindings;
4+
import org.ldk.enums.*;
5+
import org.ldk.util.*;
6+
import java.util.Arrays;
7+
import javax.annotation.Nullable;
8+
9+
10+
/**
11+
* Details about the balance(s) available for spending once the channel appears on chain.
12+
*
13+
* See [`ChannelMonitor::get_claimable_balances`] for more details on when these will or will not
14+
* be provided.
15+
*/
16+
@SuppressWarnings("unchecked") // We correctly assign various generic arrays
17+
public class Balance extends CommonBase {
18+
private Balance(Object _dummy, long ptr) { super(ptr); }
19+
@Override @SuppressWarnings("deprecation")
20+
protected void finalize() throws Throwable {
21+
super.finalize();
22+
if (ptr != 0) { bindings.Balance_free(ptr); }
23+
}
24+
static Balance constr_from_ptr(long ptr) {
25+
bindings.LDKBalance raw_val = bindings.LDKBalance_ref_from_ptr(ptr);
26+
if (raw_val.getClass() == bindings.LDKBalance.ClaimableOnChannelClose.class) {
27+
return new ClaimableOnChannelClose(ptr, (bindings.LDKBalance.ClaimableOnChannelClose)raw_val);
28+
}
29+
if (raw_val.getClass() == bindings.LDKBalance.ClaimableAwaitingConfirmations.class) {
30+
return new ClaimableAwaitingConfirmations(ptr, (bindings.LDKBalance.ClaimableAwaitingConfirmations)raw_val);
31+
}
32+
if (raw_val.getClass() == bindings.LDKBalance.ContentiousClaimable.class) {
33+
return new ContentiousClaimable(ptr, (bindings.LDKBalance.ContentiousClaimable)raw_val);
34+
}
35+
if (raw_val.getClass() == bindings.LDKBalance.MaybeClaimableHTLCAwaitingTimeout.class) {
36+
return new MaybeClaimableHTLCAwaitingTimeout(ptr, (bindings.LDKBalance.MaybeClaimableHTLCAwaitingTimeout)raw_val);
37+
}
38+
assert false; return null; // Unreachable without extending the (internal) bindings interface
39+
}
40+
41+
public final static class ClaimableOnChannelClose extends Balance {
42+
/**
43+
* The amount available to claim, in satoshis, excluding the on-chain fees which will be
44+
* required to do so.
45+
*/
46+
public final long claimable_amount_satoshis;
47+
private ClaimableOnChannelClose(long ptr, bindings.LDKBalance.ClaimableOnChannelClose obj) {
48+
super(null, ptr);
49+
this.claimable_amount_satoshis = obj.claimable_amount_satoshis;
50+
}
51+
}
52+
public final static class ClaimableAwaitingConfirmations extends Balance {
53+
/**
54+
* The amount available to claim, in satoshis, possibly excluding the on-chain fees which
55+
* were spent in broadcasting the transaction.
56+
*/
57+
public final long claimable_amount_satoshis;
58+
/**
59+
* The height at which an [`Event::SpendableOutputs`] event will be generated for this
60+
* amount.
61+
*/
62+
public final int confirmation_height;
63+
private ClaimableAwaitingConfirmations(long ptr, bindings.LDKBalance.ClaimableAwaitingConfirmations obj) {
64+
super(null, ptr);
65+
this.claimable_amount_satoshis = obj.claimable_amount_satoshis;
66+
this.confirmation_height = obj.confirmation_height;
67+
}
68+
}
69+
public final static class ContentiousClaimable extends Balance {
70+
/**
71+
* The amount available to claim, in satoshis, excluding the on-chain fees which will be
72+
* required to do so.
73+
*/
74+
public final long claimable_amount_satoshis;
75+
/**
76+
* The height at which the counterparty may be able to claim the balance if we have not
77+
* done so.
78+
*/
79+
public final int timeout_height;
80+
private ContentiousClaimable(long ptr, bindings.LDKBalance.ContentiousClaimable obj) {
81+
super(null, ptr);
82+
this.claimable_amount_satoshis = obj.claimable_amount_satoshis;
83+
this.timeout_height = obj.timeout_height;
84+
}
85+
}
86+
public final static class MaybeClaimableHTLCAwaitingTimeout extends Balance {
87+
/**
88+
* The amount available to claim, in satoshis, excluding the on-chain fees which will be
89+
* required to do so.
90+
*/
91+
public final long claimable_amount_satoshis;
92+
/**
93+
* The height at which we will be able to claim the balance if our counterparty has not
94+
* done so.
95+
*/
96+
public final int claimable_height;
97+
private MaybeClaimableHTLCAwaitingTimeout(long ptr, bindings.LDKBalance.MaybeClaimableHTLCAwaitingTimeout obj) {
98+
super(null, ptr);
99+
this.claimable_amount_satoshis = obj.claimable_amount_satoshis;
100+
this.claimable_height = obj.claimable_height;
101+
}
102+
}
103+
/**
104+
* Creates a copy of the Balance
105+
*/
106+
public Balance clone() {
107+
long ret = bindings.Balance_clone(this.ptr);
108+
if (ret < 1024) { return null; }
109+
Balance ret_hu_conv = Balance.constr_from_ptr(ret);
110+
ret_hu_conv.ptrs_to.add(this);
111+
return ret_hu_conv;
112+
}
113+
114+
/**
115+
* Utility method to constructs a new ClaimableOnChannelClose-variant Balance
116+
*/
117+
public static Balance claimable_on_channel_close(long claimable_amount_satoshis) {
118+
long ret = bindings.Balance_claimable_on_channel_close(claimable_amount_satoshis);
119+
if (ret < 1024) { return null; }
120+
Balance ret_hu_conv = Balance.constr_from_ptr(ret);
121+
ret_hu_conv.ptrs_to.add(ret_hu_conv);
122+
return ret_hu_conv;
123+
}
124+
125+
/**
126+
* Utility method to constructs a new ClaimableAwaitingConfirmations-variant Balance
127+
*/
128+
public static Balance claimable_awaiting_confirmations(long claimable_amount_satoshis, int confirmation_height) {
129+
long ret = bindings.Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
130+
if (ret < 1024) { return null; }
131+
Balance ret_hu_conv = Balance.constr_from_ptr(ret);
132+
ret_hu_conv.ptrs_to.add(ret_hu_conv);
133+
return ret_hu_conv;
134+
}
135+
136+
/**
137+
* Utility method to constructs a new ContentiousClaimable-variant Balance
138+
*/
139+
public static Balance contentious_claimable(long claimable_amount_satoshis, int timeout_height) {
140+
long ret = bindings.Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
141+
if (ret < 1024) { return null; }
142+
Balance ret_hu_conv = Balance.constr_from_ptr(ret);
143+
ret_hu_conv.ptrs_to.add(ret_hu_conv);
144+
return ret_hu_conv;
145+
}
146+
147+
/**
148+
* Utility method to constructs a new MaybeClaimableHTLCAwaitingTimeout-variant Balance
149+
*/
150+
public static Balance maybe_claimable_htlcawaiting_timeout(long claimable_amount_satoshis, int claimable_height) {
151+
long ret = bindings.Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
152+
if (ret < 1024) { return null; }
153+
Balance ret_hu_conv = Balance.constr_from_ptr(ret);
154+
ret_hu_conv.ptrs_to.add(ret_hu_conv);
155+
return ret_hu_conv;
156+
}
157+
158+
/**
159+
* Checks if two Balances contain equal inner contents.
160+
* This ignores pointers and is_owned flags and looks at the values in fields.
161+
*/
162+
public boolean eq(Balance b) {
163+
boolean ret = bindings.Balance_eq(this.ptr, b == null ? 0 : b.ptr & ~1);
164+
this.ptrs_to.add(b);
165+
return ret;
166+
}
167+
168+
}

0 commit comments

Comments
 (0)