public Result_RecoverableSignatureNoneZ sign_invoice(byte[] invoice_preimage) {
return underlying_if.sign_invoice(invoice_preimage);
}
+
+ @Override
+ public byte[] get_inbound_payment_key_material() {
+ return underlying_if.get_inbound_payment_key_material();
+ }
});
}
synchronized (monitors) {
String txid = Arrays.toString(funding_txo.get_txid());
assert monitors.containsKey(txid);
- Result_NoneMonitorUpdateErrorZ update_res = monitors.get(txid).update_monitor(update, tx_broadcaster, fee_estimator, logger);
- assert update_res instanceof Result_NoneMonitorUpdateErrorZ.Result_NoneMonitorUpdateErrorZ_OK;
+ Result_NoneNoneZ update_res = monitors.get(txid).update_monitor(update, tx_broadcaster, fee_estimator, logger);
+ assert update_res instanceof Result_NoneNoneZ.Result_NoneNoneZ_OK;
}
return Result_NoneChannelMonitorUpdateErrZ.ok();
}
}
private Peer(Object _dummy, byte seed) {
- logger = Logger.new_impl((Record arg)->{
+ logger = Logger.new_impl((org.ldk.structs.Record arg)->{
if (arg.get_level() == Level.LDKLevel_Error)
System.err.println(seed + ": " + arg.get_module_path() + " - " + arg.get_args());
else
this.constructor = new ChannelManagerConstructor(Network.LDKNetwork_Bitcoin, UserConfig.with_default(), new byte[32], 0,
this.keys_interface, this.fee_estimator, this.chain_monitor, this.router, this.tx_broadcaster, this.logger);
}
- LockableScore scorer = null;
- if (use_invoice_payer) { scorer = LockableScore.of(Scorer.with_default().as_Score()); }
+ MultiThreadedLockableScore scorer = null;
+ if (use_invoice_payer) { scorer = MultiThreadedLockableScore.of(Scorer.with_default().as_Score()); }
constructor.chain_sync_completed(new ChannelManagerConstructor.EventHandler() {
@Override public void handle_event(Event event) {
synchronized (pending_manager_events) {
if (use_invoice_payer) {
this.payer = InvoicePayer.of(this.chan_manager.as_Payer(), Router.new_impl(new Router.RouterInterface() {
@Override
- public Result_RouteLightningErrorZ find_route(byte[] payer, RouteParameters params, ChannelDetails[] first_hops, Score scorer) {
+ public Result_RouteLightningErrorZ find_route(byte[] payer, RouteParameters params, byte[] payment_hash, ChannelDetails[] first_hops, Score scorer) {
return UtilMethods.find_route(payer, params, router, first_hops, logger, scorer);
}
- }), LockableScore.of(Score.new_impl(new Score.ScoreInterface() {
+ }), 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 scid, NodeId src, NodeId dst) { return 0; }
+ @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 void payment_path_successful(RouteHop[] path) {}
@Override public byte[] write() { assert false; return null; }
})), logger, EventHandler.new_impl(new EventHandler.EventHandlerInterface() {
@Override public void handle_event(Event event) {
assert false;
} catch (ChannelManagerConstructor.InvalidSerializedDataException e) {}
}
- LockableScore scorer = null;
- if (use_invoice_payer) { scorer = LockableScore.of(Scorer.with_default().as_Score()); }
+ MultiThreadedLockableScore scorer = null;
+ if (use_invoice_payer) { scorer = MultiThreadedLockableScore.of(Scorer.with_default().as_Score()); }
constructor.chain_sync_completed(new ChannelManagerConstructor.EventHandler() {
@Override public void handle_event(Event event) {
synchronized (pending_manager_events) {
if (use_invoice_payer) {
this.payer = InvoicePayer.of(this.chan_manager.as_Payer(), Router.new_impl(new Router.RouterInterface() {
@Override
- public Result_RouteLightningErrorZ find_route(byte[] payer, RouteParameters params, ChannelDetails[] first_hops, Score scorer) {
+ public Result_RouteLightningErrorZ find_route(byte[] payer, RouteParameters params, byte[] _payment_hash, ChannelDetails[] first_hops, Score scorer) {
return UtilMethods.find_route(payer, params, router, first_hops, logger, scorer);
}
- }), LockableScore.of(Score.new_impl(new Score.ScoreInterface() {
+ }), 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 void payment_path_failed(RouteHop[] path, long scid) {}
- @Override public long channel_penalty_msat(long scid, NodeId src, NodeId dst) { 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() {
@Override public void handle_event(Event event) {
if (use_chan_manager_constructor) {
while (res.length < expected_len) {
synchronized (this.pending_manager_events) {
- res = this.pending_manager_events.toArray(res);
- assert res.length == expected_len || res.length == 0; // We don't handle partial results
- this.pending_manager_events.clear();
+ if (this.pending_manager_events.size() >= expected_len) {
+ res = this.pending_manager_events.toArray(res);
+ assert res.length == expected_len;
+ this.pending_manager_events.clear();
+ }
if (res.length < expected_len) {
try { this.pending_manager_events.wait(); } catch (InterruptedException e) { assert false; }
}
peer2.nio_peer_handler.check_events();
}
chan_manager.as_EventsProvider().process_pending_events(EventHandler.new_impl(l::add));
- assert l.size() == expected_len || l.size() == 0; // We don't handle partial results
}
return l.toArray(new Event[0]);
}
assert !Arrays.equals(payment_preimage, new byte[32]);
state.peer2.chan_manager.claim_funds(payment_preimage);
- events = state.peer1.get_manager_events(1, state.peer1, state.peer2);
+ events = state.peer1.get_manager_events(2, state.peer1, state.peer2);
assert events[0] instanceof Event.PaymentSent;
assert Arrays.equals(((Event.PaymentSent) events[0]).payment_preimage, payment_preimage);
+ assert events[1] instanceof Event.PaymentPathSuccessful;
+ assert Arrays.equals(((Event.PaymentPathSuccessful) events[1]).payment_hash, ((Event.PaymentSent) events[0]).payment_hash);
if (use_nio_peer_handler) {
// We receive PaymentSent immediately upon receipt of the payment preimage, but we expect to not have an
String txid = Arrays.toString(bindings.OutPoint_get_txid(funding_txo));
assert monitors.containsKey(txid);
long update_res = bindings.ChannelMonitor_update_monitor(monitors.get(txid), update, tx_broadcaster, fee_estimator, logger);
- assert bindings.CResult_NoneMonitorUpdateErrorZ_is_ok(update_res);
- bindings.CResult_NoneMonitorUpdateErrorZ_free(update_res);
+ assert bindings.CResult_NoneNoneZ_is_ok(update_res);
+ bindings.CResult_NoneNoneZ_free(update_res);
}
bindings.OutPoint_free(funding_txo);
bindings.ChannelMonitorUpdate_free(update);
for (long chan : peer2_chans) bindings.ChannelDetails_free(chan);
long no_min_val = bindings.COption_u64Z_none();
- long inbound_payment = bindings.ChannelManager_create_inbound_payment(peer2.chan_manager, no_min_val, 7200, 42);
+ long inbound_payment = bindings.ChannelManager_create_inbound_payment(peer2.chan_manager, no_min_val, 7200);
+ assert bindings.CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(inbound_payment);
+ long payment_tuple = bindings.LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(inbound_payment);
bindings.COption_u64Z_free(no_min_val);
long scorer = bindings.Scorer_default();
long scorer_interface = bindings.Scorer_as_Score(scorer);
for (long chan : peer1_chans) bindings.ChannelDetails_free(chan);
assert bindings.CResult_RouteLightningErrorZ_is_ok(route);
long payment_res = bindings.ChannelManager_send_payment(peer1.chan_manager, bindings.LDKCResult_RouteLightningErrorZ_get_ok(route),
- bindings.C2Tuple_PaymentHashPaymentSecretZ_get_a(inbound_payment), bindings.C2Tuple_PaymentHashPaymentSecretZ_get_b(inbound_payment));
+ bindings.C2Tuple_PaymentHashPaymentSecretZ_get_a(payment_tuple), bindings.C2Tuple_PaymentHashPaymentSecretZ_get_b(payment_tuple));
bindings.CResult_RouteLightningErrorZ_free(route);
- bindings.C2Tuple_PaymentHashPaymentSecretZ_free(inbound_payment);
+ bindings.CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(inbound_payment);
assert bindings.CResult_NonePaymentSendFailureZ_is_ok(payment_res);
bindings.CResult_NonePaymentSendFailureZ_free(payment_res);
deliver_peer_messages(list, peer1.peer_manager, peer2.peer_manager);
bindings.EventsProvider_process_pending_events(peer1.chan_manager_events, handler);
- assert events.size() == 1;
+ assert events.size() == 2;
bindings.LDKEvent sent = bindings.LDKEvent_ref_from_ptr(events.get(0));
assert sent instanceof bindings.LDKEvent.PaymentSent;
bindings.Event_free(events.remove(0));
+ bindings.LDKEvent sent_path = bindings.LDKEvent_ref_from_ptr(events.get(0));
+ assert sent_path instanceof bindings.LDKEvent.PaymentPathSuccessful;
+ bindings.Event_free(events.remove(0));
bindings.EventHandler_free(handler);