Skip to content

Commit 6f84978

Browse files
committed
Update auto-generated bindings
1 parent e3b8d99 commit 6f84978

36 files changed

+60822
-16189
lines changed

liblightningjni_debug.so

3.88 MB
Binary file not shown.

liblightningjni_release.so

557 KB
Binary file not shown.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.ldk.enums;
2+
3+
/**
4+
* Represents an IO Error. Note that some information is lost in the conversion from Rust.
5+
*/
6+
public enum LDKIOError {
7+
LDKIOError_NotFound,
8+
LDKIOError_PermissionDenied,
9+
LDKIOError_ConnectionRefused,
10+
LDKIOError_ConnectionReset,
11+
LDKIOError_ConnectionAborted,
12+
LDKIOError_NotConnected,
13+
LDKIOError_AddrInUse,
14+
LDKIOError_AddrNotAvailable,
15+
LDKIOError_BrokenPipe,
16+
LDKIOError_AlreadyExists,
17+
LDKIOError_WouldBlock,
18+
LDKIOError_InvalidInput,
19+
LDKIOError_InvalidData,
20+
LDKIOError_TimedOut,
21+
LDKIOError_WriteZero,
22+
LDKIOError_Interrupted,
23+
LDKIOError_Other,
24+
LDKIOError_UnexpectedEof,
25+
; static native void init();
26+
static { init(); }
27+
}

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

Lines changed: 709 additions & 645 deletions
Large diffs are not rendered by default.

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

Lines changed: 390 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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+
8+
9+
/**
10+
* The best known block as identified by its hash and height.
11+
*/
12+
@SuppressWarnings("unchecked") // We correctly assign various generic arrays
13+
public class BestBlock extends CommonBase {
14+
BestBlock(Object _dummy, long ptr) { super(ptr); }
15+
@Override @SuppressWarnings("deprecation")
16+
protected void finalize() throws Throwable {
17+
super.finalize();
18+
if (ptr != 0) { bindings.BestBlock_free(ptr); }
19+
}
20+
21+
/**
22+
* Creates a copy of the BestBlock
23+
*/
24+
public BestBlock clone() {
25+
long ret = bindings.BestBlock_clone(this.ptr);
26+
BestBlock ret_hu_conv = new BestBlock(null, ret);
27+
ret_hu_conv.ptrs_to.add(this);
28+
return ret_hu_conv;
29+
}
30+
31+
/**
32+
* Returns the best block from the genesis of the given network.
33+
*/
34+
public static BestBlock constructor_from_genesis(LDKNetwork network) {
35+
long ret = bindings.BestBlock_from_genesis(network);
36+
BestBlock ret_hu_conv = new BestBlock(null, ret);
37+
ret_hu_conv.ptrs_to.add(ret_hu_conv);
38+
return ret_hu_conv;
39+
}
40+
41+
/**
42+
* Returns the best block as identified by the given block hash and height.
43+
*/
44+
public static BestBlock constructor_new(byte[] block_hash, int height) {
45+
long ret = bindings.BestBlock_new(block_hash, height);
46+
BestBlock ret_hu_conv = new BestBlock(null, ret);
47+
ret_hu_conv.ptrs_to.add(ret_hu_conv);
48+
return ret_hu_conv;
49+
}
50+
51+
/**
52+
* Returns the best block hash.
53+
*/
54+
public byte[] block_hash() {
55+
byte[] ret = bindings.BestBlock_block_hash(this.ptr);
56+
return ret;
57+
}
58+
59+
/**
60+
* Returns the best block height.
61+
*/
62+
public int height() {
63+
int ret = bindings.BestBlock_height(this.ptr);
64+
return ret;
65+
}
66+
67+
}

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

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,45 @@ public void block_connected(byte[] header, TwoTuple<Long, byte[]>[] txdata, int
4242
/* TODO 2 TwoTuple<Long, byte[]> */;
4343
}
4444

45+
/**
46+
* Dispatches to per-channel monitors, which are responsible for updating their on-chain view
47+
* of a channel and reacting accordingly to newly confirmed transactions. For details, see
48+
* [`ChannelMonitor::transactions_confirmed`].
49+
*
50+
* Used instead of [`block_connected`] by clients that are notified of transactions rather than
51+
* blocks. May be called before or after [`update_best_block`] for transactions in the
52+
* corresponding block. See [`update_best_block`] for further calling expectations.
53+
*
54+
* [`block_connected`]: Self::block_connected
55+
* [`update_best_block`]: Self::update_best_block
56+
*/
57+
public void transactions_confirmed(byte[] header, TwoTuple<Long, byte[]>[] txdata, int height) {
58+
bindings.ChainMonitor_transactions_confirmed(this.ptr, header, Arrays.stream(txdata).mapToLong(txdata_conv_24 -> bindings.C2Tuple_usizeTransactionZ_new(txdata_conv_24.a, txdata_conv_24.b)).toArray(), height);
59+
/* TODO 2 TwoTuple<Long, byte[]> */;
60+
}
61+
62+
/**
63+
* Dispatches to per-channel monitors, which are responsible for updating their on-chain view
64+
* of a channel and reacting accordingly based on the new chain tip. For details, see
65+
* [`ChannelMonitor::update_best_block`].
66+
*
67+
* Used instead of [`block_connected`] by clients that are notified of transactions rather than
68+
* blocks. May be called before or after [`transactions_confirmed`] for the corresponding
69+
* block.
70+
*
71+
* Must be called after new blocks become available for the most recent block. Intermediary
72+
* blocks, however, may be safely skipped. In the event of a chain re-organization, this only
73+
* needs to be called for the most recent block assuming `transaction_unconfirmed` is called
74+
* for any affected transactions.
75+
*
76+
* [`block_connected`]: Self::block_connected
77+
* [`transactions_confirmed`]: Self::transactions_confirmed
78+
* [`transaction_unconfirmed`]: Self::transaction_unconfirmed
79+
*/
80+
public void update_best_block(byte[] header, int height) {
81+
bindings.ChainMonitor_update_best_block(this.ptr, header, height);
82+
}
83+
4584
/**
4685
* Dispatches to per-channel monitors, which are responsible for updating their on-chain view
4786
* of a channel based on the disconnected block. See [`ChannelMonitor::block_disconnected`] for
@@ -51,6 +90,30 @@ public void block_disconnected(byte[] header, int disconnected_height) {
5190
bindings.ChainMonitor_block_disconnected(this.ptr, header, disconnected_height);
5291
}
5392

93+
/**
94+
* Dispatches to per-channel monitors, which are responsible for updating their on-chain view
95+
* of a channel based on transactions unconfirmed as a result of a chain reorganization. See
96+
* [`ChannelMonitor::transaction_unconfirmed`] for details.
97+
*
98+
* Used instead of [`block_disconnected`] by clients that are notified of transactions rather
99+
* than blocks. May be called before or after [`update_best_block`] for transactions in the
100+
* corresponding block. See [`update_best_block`] for further calling expectations.
101+
*
102+
* [`block_disconnected`]: Self::block_disconnected
103+
* [`update_best_block`]: Self::update_best_block
104+
*/
105+
public void transaction_unconfirmed(byte[] txid) {
106+
bindings.ChainMonitor_transaction_unconfirmed(this.ptr, txid);
107+
}
108+
109+
/**
110+
* Returns the set of txids that should be monitored for re-organization out of the chain.
111+
*/
112+
public byte[][] get_relevant_txids() {
113+
byte[][] ret = bindings.ChainMonitor_get_relevant_txids(this.ptr);
114+
return ret;
115+
}
116+
54117
/**
55118
* Creates a new `ChainMonitor` used to watch on-chain activity pertaining to channels.
56119
*

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

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -38,46 +38,35 @@ public void set_network(LDKNetwork val) {
3838
}
3939

4040
/**
41-
* The hash of the latest block successfully connected.
42-
*/
43-
public byte[] get_latest_hash() {
44-
byte[] ret = bindings.ChainParameters_get_latest_hash(this.ptr);
45-
return ret;
46-
}
47-
48-
/**
49-
* The hash of the latest block successfully connected.
50-
*/
51-
public void set_latest_hash(byte[] val) {
52-
bindings.ChainParameters_set_latest_hash(this.ptr, val);
53-
}
54-
55-
/**
56-
* The height of the latest block successfully connected.
41+
* The hash and height of the latest block successfully connected.
5742
*
5843
* Used to track on-chain channel funding outputs and send payments with reliable timelocks.
5944
*/
60-
public long get_latest_height() {
61-
long ret = bindings.ChainParameters_get_latest_height(this.ptr);
62-
return ret;
45+
public BestBlock get_best_block() {
46+
long ret = bindings.ChainParameters_get_best_block(this.ptr);
47+
BestBlock ret_hu_conv = new BestBlock(null, ret);
48+
ret_hu_conv.ptrs_to.add(this);
49+
return ret_hu_conv;
6350
}
6451

6552
/**
66-
* The height of the latest block successfully connected.
53+
* The hash and height of the latest block successfully connected.
6754
*
6855
* Used to track on-chain channel funding outputs and send payments with reliable timelocks.
6956
*/
70-
public void set_latest_height(long val) {
71-
bindings.ChainParameters_set_latest_height(this.ptr, val);
57+
public void set_best_block(BestBlock val) {
58+
bindings.ChainParameters_set_best_block(this.ptr, val == null ? 0 : val.ptr & ~1);
59+
this.ptrs_to.add(val);
7260
}
7361

7462
/**
7563
* Constructs a new ChainParameters given each field
7664
*/
77-
public static ChainParameters constructor_new(LDKNetwork network_arg, byte[] latest_hash_arg, long latest_height_arg) {
78-
long ret = bindings.ChainParameters_new(network_arg, latest_hash_arg, latest_height_arg);
65+
public static ChainParameters constructor_new(LDKNetwork network_arg, BestBlock best_block_arg) {
66+
long ret = bindings.ChainParameters_new(network_arg, best_block_arg == null ? 0 : best_block_arg.ptr & ~1);
7967
ChainParameters ret_hu_conv = new ChainParameters(null, ret);
8068
ret_hu_conv.ptrs_to.add(ret_hu_conv);
69+
ret_hu_conv.ptrs_to.add(best_block_arg);
8170
return ret_hu_conv;
8271
}
8372

0 commit comments

Comments
 (0)