import javax.annotation.Nullable;
import org.ldk.enums.Network;
+import org.ldk.enums.Recipient;
import org.ldk.structs.*;
-import org.ldk.util.TwoTuple;
import java.io.IOException;
import java.util.HashSet;
this.logger = logger;
byte[] random_data = keys_interface.get_secure_random_bytes();
this.net_graph = net_graph;
+ Result_SecretKeyNoneZ node_secret = keys_interface.get_node_secret(Recipient.LDKRecipient_Node);
+ assert node_secret.is_ok();
if (net_graph != null) {
//TODO: We really need to expose the Access here to let users prevent DoS issues
this.graph_msg_handler = NetGraphMsgHandler.of(net_graph, Option_AccessZ.none(), logger);
this.peer_manager = PeerManager.of(channel_manager.as_ChannelMessageHandler(),
graph_msg_handler.as_RoutingMessageHandler(),
- keys_interface.get_node_secret(), random_data, logger, no_custom_messages.as_CustomMessageHandler());
+ ((Result_SecretKeyNoneZ.Result_SecretKeyNoneZ_OK)node_secret).res,
+ random_data, logger, no_custom_messages.as_CustomMessageHandler());
} else {
this.graph_msg_handler = null;
this.peer_manager = PeerManager.of(channel_manager.as_ChannelMessageHandler(), no_custom_messages.as_RoutingMessageHandler(),
- keys_interface.get_node_secret(), random_data, logger, no_custom_messages.as_CustomMessageHandler());
+ ((Result_SecretKeyNoneZ.Result_SecretKeyNoneZ_OK)node_secret).res,
+ random_data, logger, no_custom_messages.as_CustomMessageHandler());
}
NioPeerHandler nio_peer_handler = null;
try {
this.logger = logger;
byte[] random_data = keys_interface.get_secure_random_bytes();
this.net_graph = net_graph;
+ Result_SecretKeyNoneZ node_secret = keys_interface.get_node_secret(Recipient.LDKRecipient_Node);
+ assert node_secret.is_ok();
if (net_graph != null) {
//TODO: We really need to expose the Access here to let users prevent DoS issues
this.graph_msg_handler = NetGraphMsgHandler.of(net_graph, Option_AccessZ.none(), logger);
this.peer_manager = PeerManager.of(channel_manager.as_ChannelMessageHandler(),
graph_msg_handler.as_RoutingMessageHandler(),
- keys_interface.get_node_secret(), random_data, logger, no_custom_messages.as_CustomMessageHandler());
+ ((Result_SecretKeyNoneZ.Result_SecretKeyNoneZ_OK)node_secret).res,
+ random_data, logger, no_custom_messages.as_CustomMessageHandler());
} else {
this.graph_msg_handler = null;
this.peer_manager = PeerManager.of(channel_manager.as_ChannelMessageHandler(), no_custom_messages.as_RoutingMessageHandler(),
- keys_interface.get_node_secret(), random_data, logger, no_custom_messages.as_CustomMessageHandler());
+ ((Result_SecretKeyNoneZ.Result_SecretKeyNoneZ_OK)node_secret).res,
+ random_data, logger, no_custom_messages.as_CustomMessageHandler());
}
NioPeerHandler nio_peer_handler = null;
try {
import org.junit.jupiter.api.Test;
import org.ldk.batteries.ChannelManagerConstructor;
import org.ldk.batteries.NioPeerHandler;
-import org.ldk.enums.AccessError;
+import org.ldk.enums.*;
import org.ldk.enums.Currency;
-import org.ldk.enums.Level;
-import org.ldk.enums.Network;
import org.ldk.structs.*;
-import org.ldk.util.TwoTuple;
+import org.ldk.util.UInt5;
import java.io.IOException;
import java.lang.ref.WeakReference;
class Peer {
KeysInterface manual_keysif(KeysInterface underlying_if) {
return KeysInterface.new_impl(new KeysInterface.KeysInterfaceInterface() {
- @Override public byte[] get_node_secret() { return underlying_if.get_node_secret(); }
+ @Override public Result_SecretKeyNoneZ get_node_secret(Recipient recipient) { return underlying_if.get_node_secret(recipient); }
@Override public byte[] get_destination_script() { return underlying_if.get_destination_script(); }
@Override public ShutdownScript get_shutdown_scriptpubkey() { return underlying_if.get_shutdown_scriptpubkey(); }
@Override public byte[] release_commitment_secret(long idx) {
return underlying_base.release_commitment_secret(idx);
}
- @Override public Result_NoneNoneZ validate_holder_commitment(HolderCommitmentTransaction holder_tx) {
- return underlying_base.validate_holder_commitment(holder_tx);
+ @Override public Result_NoneNoneZ validate_holder_commitment(HolderCommitmentTransaction holder_tx, byte[][] preimages) {
+ return underlying_base.validate_holder_commitment(holder_tx, preimages);
}
@Override public byte[] channel_keys_id() {
return new byte[32];
}
- @Override public Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment(CommitmentTransaction commitment_tx) {
- return underlying_base.sign_counterparty_commitment(commitment_tx);
+ @Override public Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment(CommitmentTransaction commitment_tx, byte[][] preimages) {
+ return underlying_base.sign_counterparty_commitment(commitment_tx, preimages);
}
@Override public Result_NoneNoneZ validate_counterparty_revocation(long idx, byte[] secret) {
return underlying_base.validate_counterparty_revocation(idx, secret);
@Override public Result_SignatureNoneZ sign_closing_transaction(ClosingTransaction closing_tx) {
return underlying_base.sign_closing_transaction(closing_tx);
}
- @Override public Result_SignatureNoneZ sign_channel_announcement(UnsignedChannelAnnouncement msg) {
+ @Override public Result_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement(UnsignedChannelAnnouncement msg) {
return underlying_base.sign_channel_announcement(msg);
}
@Override public void ready_channel(ChannelTransactionParameters params) {
}
@Override
- public Result_RecoverableSignatureNoneZ sign_invoice(byte[] invoice_preimage) {
- return underlying_if.sign_invoice(invoice_preimage);
+ public Result_RecoverableSignatureNoneZ sign_invoice(byte[] hrp_bytes, UInt5[] invoice_data, Recipient receipient) {
+ return underlying_if.sign_invoice(hrp_bytes, invoice_data, receipient);
}
@Override
ChainParameters params = ChainParameters.of(Network.LDKNetwork_Bitcoin, BestBlock.of(new byte[32], 0));
this.chan_manager = ChannelManager.of(this.fee_estimator, chain_watch, tx_broadcaster, logger, this.keys_interface, UserConfig.with_default(), params);
byte[] random_data = keys_interface.get_secure_random_bytes();
- this.peer_manager = PeerManager.of(chan_manager.as_ChannelMessageHandler(), route_handler.as_RoutingMessageHandler(), keys_interface.get_node_secret(), random_data, logger, this.custom_message_handler);
+ Result_SecretKeyNoneZ node_secret = keys_interface.get_node_secret(Recipient.LDKRecipient_Node);
+ assert node_secret.is_ok();
+ this.peer_manager = PeerManager.of(chan_manager.as_ChannelMessageHandler(), route_handler.as_RoutingMessageHandler(),
+ ((Result_SecretKeyNoneZ.Result_SecretKeyNoneZ_OK)node_secret).res, random_data, logger, this.custom_message_handler);
if (use_invoice_payer) {
this.payer = InvoicePayer.of(this.chan_manager.as_Payer(), Router.new_impl(new Router.RouterInterface() {
@Override
}
}), MultiThreadedLockableScore.of(Score.new_impl(new Score.ScoreInterface() {
@Override public void payment_path_failed(RouteHop[] path, long scid) {}
- @Override public long channel_penalty_msat(long short_channel_id, long send_amt_msat, Option_u64Z channel_capacity_msat, NodeId source, NodeId target) { return 0; }
+ @Override public long channel_penalty_msat(long short_channel_id, long send_amt_msat, long channel_capacity_msat, NodeId source, NodeId target) { return 0; }
@Override public void payment_path_successful(RouteHop[] path) {}
@Override public byte[] write() { assert false; return null; }
})), logger, EventHandler.new_impl(new EventHandler.EventHandlerInterface() {
this.chan_manager = ((Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_OK) read_res).res.get_b();
this.chain_watch.watch_channel(monitors[0].get_funding_txo().get_a(), monitors[0]);
byte[] random_data = keys_interface.get_secure_random_bytes();
- this.peer_manager = PeerManager.of(chan_manager.as_ChannelMessageHandler(), route_handler.as_RoutingMessageHandler(), keys_interface.get_node_secret(), random_data, logger, this.custom_message_handler);
+ Result_SecretKeyNoneZ node_secret = keys_interface.get_node_secret(Recipient.LDKRecipient_Node);
+ assert node_secret.is_ok();
+ this.peer_manager = PeerManager.of(chan_manager.as_ChannelMessageHandler(), route_handler.as_RoutingMessageHandler(),
+ ((Result_SecretKeyNoneZ.Result_SecretKeyNoneZ_OK)node_secret).res,
+ random_data, logger, this.custom_message_handler);
if (!break_cross_peer_refs && (use_manual_watch || use_km_wrapper)) {
// When we pass monitors[0] into chain_watch.watch_channel we create a reference from the new Peer to a
// field in the old peer, preventing freeing of the original Peer until the new Peer is freed. Thus, we
return UtilMethods.find_route(payer, params, router, first_hops, logger, scorer);
}
}), MultiThreadedLockableScore.of(Score.new_impl(new Score.ScoreInterface() {
- @Override public long channel_penalty_msat(long short_channel_id, long send_amt_msat, Option_u64Z channel_capacity_msat, NodeId source, NodeId target) { return 0; }
+ @Override public long channel_penalty_msat(long short_channel_id, long send_amt_msat, long channel_capacity_msat, NodeId source, NodeId target) { return 0; }
@Override public void payment_path_failed(RouteHop[] path, long scid) {}
@Override public void payment_path_successful(RouteHop[] path) {}
@Override public byte[] write() { assert false; return null; }
InvoiceFeatures invoice_features = ((Result_InvoiceSignOrCreationErrorZ.Result_InvoiceSignOrCreationErrorZ_OK) invoice).res.features();
RouteHint[] route_hints = ((Result_InvoiceSignOrCreationErrorZ.Result_InvoiceSignOrCreationErrorZ_OK) invoice).res.route_hints();
- Payee payee = Payee.of(peer2.node_id, invoice_features, route_hints, Option_u64Z.none());
+ PaymentParameters payee = PaymentParameters.of(peer2.node_id, invoice_features, route_hints, Option_u64Z.none(), 6*24*14);
RouteParameters route_params = RouteParameters.of(payee, 10000000, 42);
Result_RouteLightningErrorZ route_res = UtilMethods.find_route(
peer1.chan_manager.get_our_node_id(), route_params, peer1.router,
import org.bitcoinj.script.Script;
import org.junit.jupiter.api.Test;
import org.ldk.enums.Network;
+import org.ldk.enums.Recipient;
import org.ldk.impl.bindings;
import java.util.ArrayList;
byte[] random_data = new byte[32];
for (byte i = 0; i < 32; i++) { random_data[i] = (byte) ((i ^ seed) ^ 0xf0); }
- this.peer_manager = bindings.PeerManager_new(message_handler, bindings.KeysInterface_get_node_secret(keys_interface), random_data,
- logger, bindings.IgnoringMessageHandler_as_CustomMessageHandler(this.custom_message_handler));
+
+ long node_id_result = bindings.KeysInterface_get_node_secret(keys_interface, Recipient.LDKRecipient_Node);
+ assert bindings.CResult_SecretKeyNoneZ_is_ok(node_id_result);
+ this.peer_manager = bindings.PeerManager_new(message_handler, bindings.CResult_SecretKeyNoneZ_get_ok(node_id_result),
+ random_data, logger, bindings.IgnoringMessageHandler_as_CustomMessageHandler(this.custom_message_handler));
+ bindings.CResult_SecretKeyNoneZ_free(node_id_result);
}
void connect_block(Block b, Transaction t, int height) {
long no_u64 = bindings.COption_u64Z_none();
long invoice_features = bindings.InvoiceFeatures_known();
- long payee = bindings.Payee_new(peer2.node_id, invoice_features, new long[0], no_u64);
+ long payee = bindings.PaymentParameters_new(peer2.node_id, invoice_features, new long[0], no_u64, 6*24*14);
bindings.InvoiceFeatures_free(invoice_features);
bindings.COption_u64Z_free(no_u64);
long route_params = bindings.RouteParameters_new(payee, 1000, 42);
long route = bindings.find_route(peer1.node_id, route_params, peer1.router, peer1_chans,
peer1.logger, scorer_interface);
bindings.RouteParameters_free(route_params);
- bindings.Payee_free(payee);
+ bindings.PaymentParameters_free(payee);
bindings.Score_free(scorer_interface);
bindings.Scorer_free(scorer);