[TS] Update auto-generated bindings to LDK-C-Bindings 0.0.123.1
[ldk-java] / src / test / java / org / ldk / HumanObjectPeerTest.java
index c8d6cda1182f46f4dd9de351cf64fc8d7ed4cdfa..7a30f10ada867b8d3057def08919c140fb18c059 100644 (file)
@@ -15,6 +15,7 @@ import org.ldk.structs.*;
 import org.ldk.util.UInt128;
 import org.ldk.util.UInt5;
 
+import java.io.FileReader;
 import java.io.IOException;
 import java.lang.ref.WeakReference;
 import java.net.InetSocketAddress;
@@ -24,6 +25,7 @@ import java.util.function.IntConsumer;
 class HumanObjectPeerTestInstance {
     private final boolean nice_close;
     private final boolean use_km_wrapper;
+    private final boolean use_full_km_wrapper;
     private final boolean use_manual_watch;
     private final boolean reload_peers;
     private final boolean break_cross_peer_refs;
@@ -34,9 +36,10 @@ class HumanObjectPeerTestInstance {
     private final boolean use_invoice_payer;
     TxOut gossip_txout = null;
 
-    HumanObjectPeerTestInstance(boolean nice_close, boolean use_km_wrapper, boolean use_manual_watch, boolean reload_peers, boolean break_cross_peer_refs, boolean use_nio_peer_handler, boolean use_filter, boolean use_ignore_handler, boolean use_chan_manager_constructor, boolean use_invoice_payer) {
+    HumanObjectPeerTestInstance(boolean nice_close, boolean use_km_wrapper, boolean use_full_km_wrapper, boolean use_manual_watch, boolean reload_peers, boolean break_cross_peer_refs, boolean use_nio_peer_handler, boolean use_filter, boolean use_ignore_handler, boolean use_chan_manager_constructor, boolean use_invoice_payer) {
         this.nice_close = nice_close;
         this.use_km_wrapper = use_km_wrapper;
+        this.use_full_km_wrapper = use_full_km_wrapper;
         this.use_manual_watch = use_manual_watch;
         this.reload_peers = reload_peers;
         this.break_cross_peer_refs = break_cross_peer_refs;
@@ -54,13 +57,19 @@ class HumanObjectPeerTestInstance {
             return NodeSigner.new_impl(new NodeSigner.NodeSignerInterface() {
                 @Override public byte[] get_inbound_payment_key_material() { return underlying_ns.get_inbound_payment_key_material(); }
                 @Override public Result_PublicKeyNoneZ get_node_id(Recipient recipient) { return underlying_ns.get_node_id(recipient); }
-                @Override public Result_SharedSecretNoneZ ecdh(Recipient recipient, byte[] other_key, Option_ScalarZ tweak) {
+                @Override public Result_ThirtyTwoBytesNoneZ ecdh(Recipient recipient, byte[] other_key, Option_BigEndianScalarZ tweak) {
                     return underlying_ns.ecdh(recipient, other_key, tweak);
                 }
                 @Override public Result_RecoverableSignatureNoneZ sign_invoice(byte[] hrp_bytes, UInt5[] invoice_data, Recipient recipient) {
                     return underlying_ns.sign_invoice(hrp_bytes, invoice_data, recipient);
                 }
-                @Override public Result_SignatureNoneZ sign_gossip_message(UnsignedGossipMessage msg) {
+                @Override public Result_SchnorrSignatureNoneZ sign_bolt12_invoice_request(UnsignedInvoiceRequest invoice_request) {
+                    return underlying_ns.sign_bolt12_invoice_request(invoice_request);
+                }
+                @Override public Result_SchnorrSignatureNoneZ sign_bolt12_invoice(UnsignedBolt12Invoice invoice) {
+                    return underlying_ns.sign_bolt12_invoice(invoice);
+                }
+                @Override public Result_ECDSASignatureNoneZ sign_gossip_message(UnsignedGossipMessage msg) {
                     return underlying_ns.sign_gossip_message(msg);
                 }
             });
@@ -69,71 +78,77 @@ class HumanObjectPeerTestInstance {
             SignerProvider underlying_sp = underlying_km.as_SignerProvider();
             must_free_objs.add(new WeakReference<>(underlying_sp));
             return SignerProvider.new_impl(new SignerProvider.SignerProviderInterface() {
-                @Override public Result_ScriptNoneZ get_destination_script() { return underlying_sp.get_destination_script(); }
+                @Override public Result_CVec_u8ZNoneZ get_destination_script(byte[] channel_keys_id) { return underlying_sp.get_destination_script(channel_keys_id); }
                 @Override public Result_ShutdownScriptNoneZ get_shutdown_scriptpubkey() { return underlying_sp.get_shutdown_scriptpubkey(); }
                 @Override public byte[] generate_channel_keys_id(boolean inbound, long channel_value_satoshis, UInt128 user_channel_id) {
                     return underlying_sp.generate_channel_keys_id(inbound, channel_value_satoshis, user_channel_id);
                 }
                 @Override
                 public WriteableEcdsaChannelSigner derive_channel_signer(long channel_value_satoshis, byte[] channel_keys_id) {
-                    WriteableEcdsaChannelSigner underlying_wecs = underlying_sp.derive_channel_signer(channel_value_satoshis, channel_keys_id);
-                    EcdsaChannelSigner underlying_ecs = underlying_wecs.get_ecdsa_channel_signer();
-                    ChannelSigner underlying_cs = underlying_ecs.get_channel_signer();
-                    ChannelSigner.ChannelSignerInterface csi = new ChannelSigner.ChannelSignerInterface() {
-                        @Override public byte[] get_per_commitment_point(long idx) { return underlying_cs.get_per_commitment_point(idx); }
-                        @Override public byte[] release_commitment_secret(long idx) { return underlying_cs.release_commitment_secret(idx); }
-                        @Override public Result_NoneNoneZ validate_holder_commitment(HolderCommitmentTransaction holder_tx, byte[][] preimages) {
-                            return underlying_cs.validate_holder_commitment(holder_tx, preimages);
-                        }
-                        @Override public byte[] channel_keys_id() { return underlying_cs.channel_keys_id(); }
-                        @Override public void provide_channel_parameters(ChannelTransactionParameters channel_parameters) {
-                            underlying_cs.provide_channel_parameters(channel_parameters);
-                        }
-                    };
-                    EcdsaChannelSigner.EcdsaChannelSignerInterface ecsi = new EcdsaChannelSigner.EcdsaChannelSignerInterface() {
-                        @Override public Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment(CommitmentTransaction commitment_tx, byte[][] preimages) {
-                            return underlying_ecs.sign_counterparty_commitment(commitment_tx, preimages);
-                        }
-                        @Override public Result_NoneNoneZ validate_counterparty_revocation(long idx, byte[] secret) {
-                            return underlying_ecs.validate_counterparty_revocation(idx, secret);
-                        }
-                        @Override public Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs(HolderCommitmentTransaction commitment_tx) {
-                            return underlying_ecs.sign_holder_commitment_and_htlcs(commitment_tx);
-                        }
-                        @Override public Result_SignatureNoneZ sign_justice_revoked_output(byte[] justice_tx, long input, long amount, byte[] per_commitment_key) {
-                            return underlying_ecs.sign_justice_revoked_output(justice_tx, input, amount, per_commitment_key);
-                        }
-                        @Override public Result_SignatureNoneZ sign_justice_revoked_htlc(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, HTLCOutputInCommitment htlc) {
-                            return underlying_ecs.sign_justice_revoked_htlc(justice_tx, input, amount, per_commitment_key, htlc);
-                        }
-                        @Override public Result_SignatureNoneZ sign_holder_htlc_transaction(byte[] htlc_tx, long input, HTLCDescriptor htlc_descriptor) {
-                            return underlying_ecs.sign_holder_htlc_transaction(htlc_tx, input, htlc_descriptor);
-                        }
-                        @Override public Result_SignatureNoneZ sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, HTLCOutputInCommitment htlc) {
-                            return underlying_ecs.sign_counterparty_htlc_transaction(htlc_tx, input, amount, per_commitment_point, htlc);
-                        }
-                        @Override public Result_SignatureNoneZ sign_closing_transaction(ClosingTransaction closing_tx) {
-                            return underlying_ecs.sign_closing_transaction(closing_tx);
-                        }
-                        @Override public Result_SignatureNoneZ sign_holder_anchor_input(byte[] anchor_tx, long input) {
-                            return underlying_ecs.sign_holder_anchor_input(anchor_tx, input);
-                        }
-                        @Override public Result_SignatureNoneZ sign_channel_announcement_with_funding_key(UnsignedChannelAnnouncement msg) {
-                            return underlying_ecs.sign_channel_announcement_with_funding_key(msg);
-                        }
-                    };
-                    WriteableEcdsaChannelSigner.WriteableEcdsaChannelSignerInterface wecsi = new WriteableEcdsaChannelSigner.WriteableEcdsaChannelSignerInterface() {
-                        @Override public byte[] write() { return underlying_wecs.write(); }
-                    };
-                    WriteableEcdsaChannelSigner resp = WriteableEcdsaChannelSigner.new_impl(wecsi, ecsi, csi, underlying_cs.get_pubkeys());
-                    must_free_objs.add(new WeakReference<>(wecsi));
-                    must_free_objs.add(new WeakReference<>(ecsi));
-                    must_free_objs.add(new WeakReference<>(csi));
-                    must_free_objs.add(new WeakReference<>(resp));
-                    must_free_objs.add(new WeakReference<>(underlying_wecs));
-                    must_free_objs.add(new WeakReference<>(underlying_ecs));
-                    must_free_objs.add(new WeakReference<>(underlying_cs));
-                    return resp;
+                    if (!use_full_km_wrapper) {
+                        WriteableEcdsaChannelSigner underlying_signer = underlying_sp.derive_channel_signer(channel_value_satoshis, channel_keys_id);
+                        must_free_objs.add(new WeakReference<>(underlying_signer));
+                        return underlying_signer;
+                    } else {
+                        WriteableEcdsaChannelSigner underlying_wecs = underlying_sp.derive_channel_signer(channel_value_satoshis, channel_keys_id);
+                        EcdsaChannelSigner underlying_ecs = underlying_wecs.get_ecdsa_channel_signer();
+                        ChannelSigner underlying_cs = underlying_ecs.get_channel_signer();
+                        ChannelSigner.ChannelSignerInterface csi = new ChannelSigner.ChannelSignerInterface() {
+                            @Override public byte[] get_per_commitment_point(long idx) { return underlying_cs.get_per_commitment_point(idx); }
+                            @Override public byte[] release_commitment_secret(long idx) { return underlying_cs.release_commitment_secret(idx); }
+                            @Override public Result_NoneNoneZ validate_holder_commitment(HolderCommitmentTransaction holder_tx, byte[][] preimages) {
+                                return underlying_cs.validate_holder_commitment(holder_tx, preimages);
+                            }
+                            @Override public Result_NoneNoneZ validate_counterparty_revocation(long idx, byte[] secret) {
+                                return underlying_cs.validate_counterparty_revocation(idx, secret);
+                            }
+                            @Override public byte[] channel_keys_id() { return underlying_cs.channel_keys_id(); }
+                            @Override public void provide_channel_parameters(ChannelTransactionParameters channel_parameters) {
+                                underlying_cs.provide_channel_parameters(channel_parameters);
+                            }
+                        };
+                        EcdsaChannelSigner.EcdsaChannelSignerInterface ecsi = new EcdsaChannelSigner.EcdsaChannelSignerInterface() {
+                            @Override public Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ sign_counterparty_commitment(CommitmentTransaction commitment_tx, byte[][] inbound_htlc_preimages, byte[][] outbound_htlc_preimages) {
+                                return underlying_ecs.sign_counterparty_commitment(commitment_tx, inbound_htlc_preimages, outbound_htlc_preimages);
+                            }
+                            @Override public Result_ECDSASignatureNoneZ sign_holder_commitment(HolderCommitmentTransaction commitment_tx) {
+                                return underlying_ecs.sign_holder_commitment(commitment_tx);
+                            }
+                            @Override public Result_ECDSASignatureNoneZ sign_justice_revoked_output(byte[] justice_tx, long input, long amount, byte[] per_commitment_key) {
+                                return underlying_ecs.sign_justice_revoked_output(justice_tx, input, amount, per_commitment_key);
+                            }
+                            @Override public Result_ECDSASignatureNoneZ sign_justice_revoked_htlc(byte[] justice_tx, long input, long amount, byte[] per_commitment_key, HTLCOutputInCommitment htlc) {
+                                return underlying_ecs.sign_justice_revoked_htlc(justice_tx, input, amount, per_commitment_key, htlc);
+                            }
+                            @Override public Result_ECDSASignatureNoneZ sign_holder_htlc_transaction(byte[] htlc_tx, long input, HTLCDescriptor htlc_descriptor) {
+                                return underlying_ecs.sign_holder_htlc_transaction(htlc_tx, input, htlc_descriptor);
+                            }
+                            @Override public Result_ECDSASignatureNoneZ sign_counterparty_htlc_transaction(byte[] htlc_tx, long input, long amount, byte[] per_commitment_point, HTLCOutputInCommitment htlc) {
+                                return underlying_ecs.sign_counterparty_htlc_transaction(htlc_tx, input, amount, per_commitment_point, htlc);
+                            }
+                            @Override public Result_ECDSASignatureNoneZ sign_closing_transaction(ClosingTransaction closing_tx) {
+                                return underlying_ecs.sign_closing_transaction(closing_tx);
+                            }
+                            @Override public Result_ECDSASignatureNoneZ sign_holder_anchor_input(byte[] anchor_tx, long input) {
+                                return underlying_ecs.sign_holder_anchor_input(anchor_tx, input);
+                            }
+                            @Override public Result_ECDSASignatureNoneZ sign_channel_announcement_with_funding_key(UnsignedChannelAnnouncement msg) {
+                                return underlying_ecs.sign_channel_announcement_with_funding_key(msg);
+                            }
+                        };
+                        WriteableEcdsaChannelSigner.WriteableEcdsaChannelSignerInterface wecsi = new WriteableEcdsaChannelSigner.WriteableEcdsaChannelSignerInterface() {
+                            @Override public byte[] write() { return underlying_wecs.write(); }
+                        };
+                        WriteableEcdsaChannelSigner resp = WriteableEcdsaChannelSigner.new_impl(wecsi, ecsi, csi, underlying_cs.get_pubkeys());
+                        must_free_objs.add(new WeakReference<>(wecsi));
+                        must_free_objs.add(new WeakReference<>(ecsi));
+                        must_free_objs.add(new WeakReference<>(csi));
+                        must_free_objs.add(new WeakReference<>(resp));
+                        must_free_objs.add(new WeakReference<>(underlying_wecs));
+                        must_free_objs.add(new WeakReference<>(underlying_ecs));
+                        must_free_objs.add(new WeakReference<>(underlying_cs));
+                        return resp;
+                    }
                 }
 
                 @Override
@@ -145,11 +160,11 @@ class HumanObjectPeerTestInstance {
 
         Watch get_manual_watch() {
             Watch.WatchInterface watch_impl = new Watch.WatchInterface() {
-                public ChannelMonitorUpdateStatus watch_channel(OutPoint funding_txo, ChannelMonitor monitor) {
+                public Result_ChannelMonitorUpdateStatusNoneZ watch_channel(OutPoint funding_txo, ChannelMonitor monitor) {
                     synchronized (monitors) {
                         assert monitors.put(Arrays.toString(funding_txo.get_txid()), monitor) == null;
                     }
-                    return ChannelMonitorUpdateStatus.LDKChannelMonitorUpdateStatus_Completed;
+                    return Result_ChannelMonitorUpdateStatusNoneZ.ok(ChannelMonitorUpdateStatus.LDKChannelMonitorUpdateStatus_Completed);
                 }
 
                 public ChannelMonitorUpdateStatus update_channel(OutPoint funding_txo, ChannelMonitorUpdate update) {
@@ -163,16 +178,16 @@ class HumanObjectPeerTestInstance {
                 }
 
                 @Override
-                public ThreeTuple_OutPointCVec_MonitorEventZPublicKeyZ[] release_pending_monitor_events() {
+                public FourTuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ[] release_pending_monitor_events() {
                     synchronized (monitors) {
                         assert monitors.size() <= 1;
                         for (ChannelMonitor mon : monitors.values()) {
-                            ThreeTuple_OutPointCVec_MonitorEventZPublicKeyZ[] res = new ThreeTuple_OutPointCVec_MonitorEventZPublicKeyZ[1];
-                            res[0] = ThreeTuple_OutPointCVec_MonitorEventZPublicKeyZ.of(mon.get_funding_txo().get_a(), mon.get_and_clear_pending_monitor_events(), mon.get_counterparty_node_id());
+                            FourTuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ[] res = new FourTuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ[1];
+                            res[0] = FourTuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ.of(mon.get_funding_txo().get_a(), ChannelId.of(new byte[32]), mon.get_and_clear_pending_monitor_events(), mon.get_counterparty_node_id());
                             return res;
                         }
                     }
-                    return new ThreeTuple_OutPointCVec_MonitorEventZPublicKeyZ[0];
+                    return new FourTuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ[0];
                 }
             };
             Watch watch = Watch.new_impl(watch_impl);
@@ -224,20 +239,20 @@ class HumanObjectPeerTestInstance {
             // Because get_funding_txo() returns an OutPoint in a tuple that is a reference to an OutPoint inside the
             // ChannelMonitor, its a good test to ensure that the OutPoint isn't freed (or is cloned) before the
             // ChannelMonitor is. This used to be broken.
-            Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ roundtrip_monitor = UtilMethods.C2Tuple_BlockHashChannelMonitorZ_read(data, this.entropy_source, this.signer_provider);
-            assert roundtrip_monitor instanceof Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_OK;
+            Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ roundtrip_monitor = UtilMethods.C2Tuple_ThirtyTwoBytesChannelMonitorZ_read(data, this.entropy_source, this.signer_provider);
+            assert roundtrip_monitor instanceof Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ.Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_OK;
             must_free_objs.add(new WeakReference<>(roundtrip_monitor));
-            TwoTuple_OutPointScriptZ funding_txo = ((Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_OK) roundtrip_monitor).res.get_b().get_funding_txo();
+            TwoTuple_OutPointCVec_u8ZZ funding_txo = ((Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ.Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_OK) roundtrip_monitor).res.get_b().get_funding_txo();
             must_free_objs.add(new WeakReference<>(funding_txo));
             System.gc(); System.runFinalization(); // Give the GC a chance to run.
             assert Arrays.equals(funding_txo.get_a().get_txid(), expected_id.get_txid());
             assert funding_txo.get_a().get_index() == expected_id.get_index();
-            Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ roundtrip_two = UtilMethods.C2Tuple_BlockHashChannelMonitorZ_read(data, this.entropy_source, this.signer_provider);
-            assert roundtrip_two instanceof Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_OK;
-            must_free_objs.add(new WeakReference<>(((Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_OK) roundtrip_two).res.get_b()));
-            must_free_objs.add(new WeakReference<>(((Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_OK) roundtrip_two).res));
+            Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ roundtrip_two = UtilMethods.C2Tuple_ThirtyTwoBytesChannelMonitorZ_read(data, this.entropy_source, this.signer_provider);
+            assert roundtrip_two instanceof Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ.Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_OK;
+            must_free_objs.add(new WeakReference<>(((Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ.Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_OK) roundtrip_two).res.get_b()));
+            must_free_objs.add(new WeakReference<>(((Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ.Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_OK) roundtrip_two).res));
             must_free_objs.add(new WeakReference<>(roundtrip_two));
-            return ((Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_OK) roundtrip_two).res.get_b();
+            return ((Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ.Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_OK) roundtrip_two).res.get_b();
         }
 
         private Peer(Object _dummy, byte seed) {
@@ -262,7 +277,7 @@ class HumanObjectPeerTestInstance {
                 @Override
                 public ChannelMonitorUpdateStatus persist_new_channel(OutPoint id, ChannelMonitor data, MonitorUpdateId update_id) {
                     synchronized (monitors) {
-                        String key = Arrays.toString(id.to_channel_id());
+                        String key = Arrays.toString(ChannelId.v1_from_funding_outpoint(id).get_a());
                         ChannelMonitor res = test_mon_roundtrip(id, data.write());
                         assert monitors.put(key, res) == null;
                     }
@@ -272,7 +287,7 @@ class HumanObjectPeerTestInstance {
                 @Override
                 public ChannelMonitorUpdateStatus update_persisted_channel(OutPoint id, ChannelMonitorUpdate update, ChannelMonitor data, MonitorUpdateId update_id) {
                     synchronized (monitors) {
-                        String key = Arrays.toString(id.to_channel_id());
+                        String key = Arrays.toString(ChannelId.v1_from_funding_outpoint(id).get_a());
                         ChannelMonitor res = test_mon_roundtrip(id, data.write());
                         // Note that we use a serialization-roundtrip copy of data here, not the original, as this can
                         // expose the JVM JIT bug where it finalize()s things still being called.
@@ -280,6 +295,11 @@ class HumanObjectPeerTestInstance {
                     }
                     return ChannelMonitorUpdateStatus.LDKChannelMonitorUpdateStatus_Completed;
                 }
+
+                @Override
+                public void archive_persisted_channel(OutPoint channel_funding_outpoint) {
+                    assert false;
+                }
             });
 
             filter_additions = new HashSet<>();
@@ -423,6 +443,11 @@ class HumanObjectPeerTestInstance {
                         return find_route(payer, route_params, first_hops, inflight_htlcs);
                     }
 
+                    @Override
+                    public Result_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ create_blinded_payment_paths(byte[] recipient, ChannelDetails[] first_hops, ReceiveTlvs tlvs, long amount_msats) {
+                        return Result_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ.err();
+                    }
+
                     @Override
                     public Result_RouteLightningErrorZ find_route(byte[] payer, RouteParameters params, ChannelDetails[] first_hops, InFlightHtlcs inflight_htlcs) {
                         while (true) {
@@ -442,14 +467,16 @@ class HumanObjectPeerTestInstance {
                                 break;
                             }
                         }
-                        return UtilMethods.find_route(payer, params, net_graph, first_hops, logger, Score.new_impl(new Score.ScoreInterface() {
-                            @Override public void payment_path_failed(Path path, long scid) {}
-                            @Override public long channel_penalty_msat(long short_channel_id, NodeId source, NodeId target, ChannelUsage usage, ProbabilisticScoringFeeParameters params) { return 0; }
-                            @Override public void payment_path_successful(Path path) {}
-                            @Override public void probe_failed(Path path, long short_channel_id) { assert false; }
-                            @Override public void probe_successful(Path path) { assert false; }
-                            @Override public byte[] write() { assert false; return null; }
-                        }), ProbabilisticScoringFeeParameters.with_default(), new byte[32]);
+                        return UtilMethods.find_route(payer, params, net_graph, first_hops, logger,
+                                ScoreLookUp.new_impl((candidate, usage, params1) -> candidate.source().as_slice()[1]),
+                                ProbabilisticScoringFeeParameters.with_default(), new byte[32]);
+                    }
+                }, new MessageRouter.MessageRouterInterface() {
+                    @Override public Result_OnionMessagePathNoneZ find_path(byte[] sender, byte[][] peers, Destination destination) {
+                        return Result_OnionMessagePathNoneZ.err();
+                    }
+                    @Override public Result_CVec_BlindedPathZNoneZ create_blinded_paths(byte[] recipient, byte[][] peers) {
+                        return Result_CVec_BlindedPathZNoneZ.err();
                     }
                 });
                 ChainParameters params = ChainParameters.of(Network.LDKNetwork_Bitcoin, BestBlock.of(new byte[32], 0));
@@ -533,6 +560,11 @@ class HumanObjectPeerTestInstance {
                         return find_route(payer, route_params, first_hops, inflight_htlcs);
                     }
 
+                    @Override
+                    public Result_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ create_blinded_payment_paths(byte[] recipient, ChannelDetails[] first_hops, ReceiveTlvs tlvs, long amount_msats) {
+                        return Result_CVec_C2Tuple_BlindedPayInfoBlindedPathZZNoneZ.err();
+                    }
+
                     @Override
                     public Result_RouteLightningErrorZ find_route(byte[] payer, RouteParameters params, ChannelDetails[] first_hops, InFlightHtlcs inflight_htlcs) {
                         while (true) {
@@ -552,14 +584,16 @@ class HumanObjectPeerTestInstance {
                                 break;
                             }
                         }
-                        return UtilMethods.find_route(payer, params, net_graph, first_hops, logger, Score.new_impl(new Score.ScoreInterface() {
-                            @Override public void payment_path_failed(Path path, long scid) {}
-                            @Override public long channel_penalty_msat(long short_channel_id, NodeId source, NodeId target, ChannelUsage usage, ProbabilisticScoringFeeParameters params) { return 0; }
-                            @Override public void payment_path_successful(Path path) {}
-                            @Override public void probe_failed(Path path, long short_channel_id) { assert false; }
-                            @Override public void probe_successful(Path path) { assert false; }
-                            @Override public byte[] write() { assert false; return null; }
-                        }), ProbabilisticScoringFeeParameters.with_default(), new byte[32]);
+                        return UtilMethods.find_route(payer, params, net_graph, first_hops, logger,
+                                ScoreLookUp.new_impl((candidate, usage, params1) -> candidate.source().as_slice()[0]),
+                                ProbabilisticScoringFeeParameters.with_default(), new byte[32]);
+                    }
+                }, new MessageRouter.MessageRouterInterface() {
+                    @Override public Result_OnionMessagePathNoneZ find_path(byte[] sender, byte[][] peers, Destination destination) {
+                        return Result_OnionMessagePathNoneZ.err();
+                    }
+                    @Override public Result_CVec_BlindedPathZNoneZ create_blinded_paths(byte[] recipient, byte[][] peers) {
+                        return Result_CVec_BlindedPathZNoneZ.err();
                     }
                 });
                 this.setup_route_handler();
@@ -569,16 +603,16 @@ class HumanObjectPeerTestInstance {
                     monitors[0] = orig.monitors.values().stream().iterator().next();
                 } else {
                     byte[] serialized = orig.monitors.values().stream().iterator().next().write();
-                    Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ res =
-                            UtilMethods.C2Tuple_BlockHashChannelMonitorZ_read(serialized, this.entropy_source, this.signer_provider);
-                    assert res instanceof Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_OK;
-                    monitors[0] = ((Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ.Result_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_OK) res).res.get_b();
+                    Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ res =
+                            UtilMethods.C2Tuple_ThirtyTwoBytesChannelMonitorZ_read(serialized, this.entropy_source, this.signer_provider);
+                    assert res instanceof Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ.Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_OK;
+                    monitors[0] = ((Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ.Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_OK) res).res.get_b();
                 }
                 byte[] serialized = orig.chan_manager.write();
-                Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ read_res =
-                        UtilMethods.C2Tuple_BlockHashChannelManagerZ_read(serialized, this.entropy_source, this.node_signer, this.signer_provider, this.fee_estimator, this.chain_watch, this.tx_broadcaster, router, this.logger, get_config(), monitors);
-                assert read_res instanceof Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_OK;
-                this.chan_manager = ((Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ.Result_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_OK) read_res).res.get_b();
+                Result_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ read_res =
+                        UtilMethods.C2Tuple_ThirtyTwoBytesChannelManagerZ_read(serialized, this.entropy_source, this.node_signer, this.signer_provider, this.fee_estimator, this.chain_watch, this.tx_broadcaster, router, this.logger, get_config(), monitors);
+                assert read_res instanceof Result_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ.Result_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_OK;
+                this.chan_manager = ((Result_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ.Result_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ_OK) read_res).res.get_b();
                 this.chain_watch.watch_channel(monitors[0].get_funding_txo().get_a(), monitors[0]);
                 this.peer_manager = PeerManager.of(chan_manager.as_ChannelMessageHandler(), route_handler.as_RoutingMessageHandler(),
                         IgnoringMessageHandler.of().as_OnionMessageHandler(), this.custom_message_handler,
@@ -607,7 +641,7 @@ class HumanObjectPeerTestInstance {
             this.filter = null;
         }
 
-        TwoTuple_TxidCVec_C2Tuple_u32TxOutZZZ[] connect_block(Block b, int height, long expected_monitor_update_len) {
+        TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ[] connect_block(Block b, int height, long expected_monitor_update_len) {
             byte[] header = Arrays.copyOfRange(b.bitcoinSerialize(), 0, 80);
             TwoTuple_usizeTransactionZ[] txn;
             if (b.hasTransactions()) {
@@ -626,7 +660,7 @@ class HumanObjectPeerTestInstance {
                 synchronized (monitors) {
                     assert monitors.size() == 1;
                     for (ChannelMonitor mon : monitors.values()) {
-                        TwoTuple_TxidCVec_C2Tuple_u32TxOutZZZ[] ret = mon.block_connected(header, txn, height, tx_broadcaster, fee_estimator, logger);
+                        TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ[] ret = mon.block_connected(header, txn, height, tx_broadcaster, fee_estimator, logger);
                         assert ret.length == expected_monitor_update_len;
                         return ret;
                     }
@@ -763,6 +797,16 @@ class HumanObjectPeerTestInstance {
             peer2.nio_peer_handler.check_events();
         }
     }
+    void do_disconnect_event(PeerManager pm, SocketDescriptor descriptor) {
+        if (!t.isAlive()) t.start();
+        synchronized (runqueue) {
+            ran = true;
+            runqueue.add(() -> {
+                pm.socket_disconnected(descriptor);
+            });
+            runqueue.notifyAll();
+        }
+    }
     void do_read_event(PeerManager pm, SocketDescriptor descriptor, byte[] data) {
         if (!t.isAlive()) t.start();
         synchronized (runqueue) {
@@ -783,7 +827,7 @@ class HumanObjectPeerTestInstance {
             try {
                 peer1.nio_peer_handler.connect(peer2.chan_manager.get_our_node_id(), new InetSocketAddress("127.0.0.1", peer2.nio_port), 100);
             } catch (IOException e) { assert false; }
-            while (peer1.peer_manager.get_peer_node_ids().length == 0 || peer2.peer_manager.get_peer_node_ids().length == 0) {
+            while (peer1.peer_manager.list_peers().length == 0 || peer2.peer_manager.list_peers().length == 0) {
                 Thread.yield();
             }
         } else {
@@ -796,7 +840,7 @@ class HumanObjectPeerTestInstance {
                     return data.length;
                 }
 
-                @Override public void disconnect_socket() { assert false; }
+                @Override public void disconnect_socket() { do_disconnect_event(peer1.peer_manager, descriptor1ref.val); }
                 @Override public boolean eq(SocketDescriptor other_arg) { return other_arg.hash() == 2; }
                 @Override public long hash() { return 2; }
             });
@@ -808,15 +852,15 @@ class HumanObjectPeerTestInstance {
                     return data.length;
                 }
 
-                @Override public void disconnect_socket() { assert false; }
+                @Override public void disconnect_socket() { do_disconnect_event(peer2.peer_manager, descriptor2); }
                 @Override public boolean eq(SocketDescriptor other_arg) { return other_arg.hash() == 1; }
                 @Override public long hash() { return 1; }
             });
 
-            Result_CVec_u8ZPeerHandleErrorZ conn_res = peer1.peer_manager.new_outbound_connection(peer2.node_id, descriptor1.val, Option_NetAddressZ.none());
+            Result_CVec_u8ZPeerHandleErrorZ conn_res = peer1.peer_manager.new_outbound_connection(peer2.node_id, descriptor1.val, Option_SocketAddressZ.none());
             assert conn_res instanceof Result_CVec_u8ZPeerHandleErrorZ.Result_CVec_u8ZPeerHandleErrorZ_OK;
 
-            Result_NonePeerHandleErrorZ inbound_conn_res = peer2.peer_manager.new_inbound_connection(descriptor2, Option_NetAddressZ.none());
+            Result_NonePeerHandleErrorZ inbound_conn_res = peer2.peer_manager.new_inbound_connection(descriptor2, Option_SocketAddressZ.none());
             assert inbound_conn_res instanceof Result_NonePeerHandleErrorZ.Result_NonePeerHandleErrorZ_OK;
             do_read_event(peer2.peer_manager, descriptor2, ((Result_CVec_u8ZPeerHandleErrorZ.Result_CVec_u8ZPeerHandleErrorZ_OK) conn_res).res);
 
@@ -832,8 +876,8 @@ class HumanObjectPeerTestInstance {
 
         UInt128 user_id = new UInt128(new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16});
 
-        Result__u832APIErrorZ cc_res = peer1.chan_manager.create_channel(peer2.node_id, 100000, 1000, user_id, null);
-        assert cc_res instanceof Result__u832APIErrorZ.Result__u832APIErrorZ_OK;
+        Result_ChannelIdAPIErrorZ cc_res = peer1.chan_manager.create_channel(peer2.node_id, 100000, 1000, user_id, null, null);
+        assert cc_res instanceof Result_ChannelIdAPIErrorZ.Result_ChannelIdAPIErrorZ_OK;
 
         // Previously, this was a SEGFAULT instead of get_funding_txo() returning null.
         ChannelDetails pre_funding_chan = peer1.chan_manager.list_channels()[0];
@@ -845,12 +889,14 @@ class HumanObjectPeerTestInstance {
         assert ((Event.FundingGenerationReady) events[0]).user_channel_id.equals(user_id);
         byte[] funding_spk = ((Event.FundingGenerationReady) events[0]).output_script;
         assert funding_spk.length == 34 && funding_spk[0] == 0 && funding_spk[1] == 32; // P2WSH
-        byte[] chan_id = ((Event.FundingGenerationReady) events[0]).temporary_channel_id;
+        ChannelId chan_id = ((Event.FundingGenerationReady) events[0]).temporary_channel_id;
 
         BitcoinNetworkParams bitcoinj_net = BitcoinNetworkParams.of(BitcoinNetwork.MAINNET);
 
+        Transaction funding_input = new Transaction(bitcoinj_net);
+        funding_input.addOutput(Coin.SATOSHI.multiply(100000), new Script(funding_spk));
         Transaction funding = new Transaction(bitcoinj_net);
-        funding.addInput(new TransactionInput(bitcoinj_net, funding, new byte[0]));
+        funding.addInput(funding_input.getOutput(0));
         funding.getInputs().get(0).setWitness(new TransactionWitness(2)); // Make sure we don't complain about lack of witness
         funding.getInput(0).getWitness().setPush(0, new byte[]{0x1});
         funding.addOutput(Coin.SATOSHI.multiply(100000), new Script(funding_spk));
@@ -904,28 +950,45 @@ class HumanObjectPeerTestInstance {
         Option_u64Z short_chan_id = peer1_chans[0].get_short_channel_id();
         assert short_chan_id instanceof Option_u64Z.Some;
         assert ((Option_u64Z.Some)short_chan_id).some == (1L << 40); // 0th output in the 0th transaction in the 1st block
-        assert Arrays.equals(peer1_chans[0].get_channel_id(), funding.getTxId().getReversedBytes());
-        assert Arrays.equals(peer2_chans[0].get_channel_id(), funding.getTxId().getReversedBytes());
+        assert Arrays.equals(peer1_chans[0].get_channel_id().get_a(), funding.getTxId().getReversedBytes());
+        assert Arrays.equals(peer2_chans[0].get_channel_id().get_a(), funding.getTxId().getReversedBytes());
+
+        // Generate a random invoice description to exercise the string conversion logic a good bit
+        String invoice_description;
+        char[] string_bytes = new char[16];
+        try {
+            new FileReader("/dev/urandom").read(string_bytes);
+        } catch (Exception e) { assert false; }
+        invoice_description = new String(string_bytes);
 
-        Result_Bolt11InvoiceSignOrCreationErrorZ invoice = UtilMethods.create_invoice_from_channelmanager(peer2.chan_manager, peer2.node_signer, peer2.logger, Currency.LDKCurrency_Bitcoin, Option_u64Z.some(10000000), "Invoice Description", 7200, Option_u16Z.none());
+        Result_Bolt11InvoiceSignOrCreationErrorZ invoice = UtilMethods.create_invoice_from_channelmanager(peer2.chan_manager, peer2.node_signer, peer2.logger, Currency.LDKCurrency_Bitcoin, Option_u64Z.some(10000000), invoice_description, 7200, Option_u16Z.none());
         assert invoice instanceof Result_Bolt11InvoiceSignOrCreationErrorZ.Result_Bolt11InvoiceSignOrCreationErrorZ_OK;
         System.out.println("Got invoice: " + ((Result_Bolt11InvoiceSignOrCreationErrorZ.Result_Bolt11InvoiceSignOrCreationErrorZ_OK) invoice).res.to_str());
 
-        Result_Bolt11InvoiceParseOrSemanticErrorZ parsed_invoice = Bolt11Invoice.from_str(((Result_Bolt11InvoiceSignOrCreationErrorZ.Result_Bolt11InvoiceSignOrCreationErrorZ_OK) invoice).res.to_str());
+        String fuck = ((Result_Bolt11InvoiceSignOrCreationErrorZ.Result_Bolt11InvoiceSignOrCreationErrorZ_OK) invoice).res.to_str();
+        Result_Bolt11InvoiceParseOrSemanticErrorZ parsed_invoice = Bolt11Invoice.from_str(fuck);
+if (parsed_invoice instanceof Result_Bolt11InvoiceParseOrSemanticErrorZ.Result_Bolt11InvoiceParseOrSemanticErrorZ_Err) {
+    System.err.println(((Result_Bolt11InvoiceParseOrSemanticErrorZ.Result_Bolt11InvoiceParseOrSemanticErrorZ_Err) parsed_invoice).err.to_str());
+}
         assert parsed_invoice instanceof Result_Bolt11InvoiceParseOrSemanticErrorZ.Result_Bolt11InvoiceParseOrSemanticErrorZ_OK;
-        //assert ((Result_Bolt11InvoiceParseOrSemanticErrorZ.Result_Bolt11InvoiceParseOrSemanticErrorZ_OK) parsed_invoice).res.fallback_addresses().length == 0;
+        assert ((Result_Bolt11InvoiceParseOrSemanticErrorZ.Result_Bolt11InvoiceParseOrSemanticErrorZ_OK) parsed_invoice).res.fallback_addresses().length == 0;
         assert Arrays.equals(((Result_Bolt11InvoiceParseOrSemanticErrorZ.Result_Bolt11InvoiceParseOrSemanticErrorZ_OK) parsed_invoice).res.payment_hash(), ((Result_Bolt11InvoiceSignOrCreationErrorZ.Result_Bolt11InvoiceSignOrCreationErrorZ_OK) invoice).res.payment_hash());
         SignedRawBolt11Invoice signed_raw = ((Result_Bolt11InvoiceParseOrSemanticErrorZ.Result_Bolt11InvoiceParseOrSemanticErrorZ_OK) parsed_invoice).res.into_signed_raw();
         RawBolt11Invoice raw_invoice = signed_raw.raw_invoice();
         byte[] desc_hash = raw_invoice.signable_hash();
         Description raw_invoice_description = raw_invoice.description();
-        String description_string = raw_invoice_description.into_inner();
-        assert description_string.equals("Invoice Description");
+        String description_string = raw_invoice_description.into_inner().get_a();
+        boolean has_null = false;
+        for (byte db : invoice_description.getBytes())
+            if (db == 0)
+                has_null = true;
+        if (!has_null) // Null codepoints are dropped, so may fail
+            assert description_string.equals(invoice_description);
 
         // Do a trivial test of constructing a phantom invoice
         Result_Bolt11InvoiceSignOrCreationErrorZ phantom_invoice = UtilMethods.create_phantom_invoice(
                 Option_u64Z.some(42000),
-                Option_PaymentHashZ.none(),
+                Option_ThirtyTwoBytesZ.none(),
                 "Phantom Invoice", 7200,
                 new PhantomRouteHints[]{ peer2.chan_manager.get_phantom_route_hints() },
                 peer2.entropy_source,
@@ -947,12 +1010,12 @@ class HumanObjectPeerTestInstance {
             RouteHint[] route_hints = ((Result_Bolt11InvoiceSignOrCreationErrorZ.Result_Bolt11InvoiceSignOrCreationErrorZ_OK) invoice).res.route_hints();
 
             Payee payee = Payee.clear(peer2.node_id, route_hints, invoice_features, 42);
-            PaymentParameters pay_params = PaymentParameters.of(payee, Option_u64Z.none(), 6*24*14, (byte)1, (byte)2, new long[0]);
-            RouteParameters route_params = RouteParameters.of(pay_params, 10000000);
+            PaymentParameters pay_params = PaymentParameters.of(payee, Option_u64Z.none(), 6*24*14, (byte)1, (byte)2, new long[0], new long[0]);
+            RouteParameters route_params = RouteParameters.from_payment_params_and_value(pay_params, 10000000);
             Result_RouteLightningErrorZ route_res = UtilMethods.find_route(
                     peer1.chan_manager.get_our_node_id(), route_params, peer1.net_graph,
                     peer1_chans, peer1.logger,
-                    ProbabilisticScorer.of(ProbabilisticScoringDecayParameters.with_default(), peer1.net_graph, peer1.logger).as_Score(),
+                    ProbabilisticScorer.of(ProbabilisticScoringDecayParameters.with_default(), peer1.net_graph, peer1.logger).as_ScoreLookUp(),
                     ProbabilisticScoringFeeParameters.with_default(), new byte[32]);
             assert route_res instanceof Result_RouteLightningErrorZ.Result_RouteLightningErrorZ_OK;
             Route route = ((Result_RouteLightningErrorZ.Result_RouteLightningErrorZ_OK) route_res).res;
@@ -970,15 +1033,20 @@ class HumanObjectPeerTestInstance {
             hop_pubkey[1] = 42;
             NodeFeatures node_features = NodeFeatures.empty();
             ChannelFeatures channel_features = ChannelFeatures.empty();
-            hops[0] = RouteHop.of(hop_pubkey, node_features, 42, channel_features, 100, 0);
+            hops[0] = RouteHop.of(hop_pubkey, node_features, 42, channel_features, 100, 0, false);
             Path[] paths = new Path[1];
             paths[0] = Path.of(hops, null);
-            Route r2 = Route.of(paths, pay_params);
+            Route r2 = Route.of(paths, RouteParameters.from_payment_params_and_value(pay_params, 100));
             payment_res = peer1.chan_manager.send_payment_with_route(r2, payment_hash, RecipientOnionFields.secret_only(payment_secret), payment_id);
             assert payment_res instanceof Result_NonePaymentSendFailureZ.Result_NonePaymentSendFailureZ_Err;
         } else {
-            Result_PaymentIdPaymentErrorZ send_res = UtilMethods.pay_invoice(((Result_Bolt11InvoiceParseOrSemanticErrorZ.Result_Bolt11InvoiceParseOrSemanticErrorZ_OK) parsed_invoice).res, Retry.attempts(0), peer1.chan_manager);
-            assert send_res instanceof Result_PaymentIdPaymentErrorZ.Result_PaymentIdPaymentErrorZ_OK;
+            Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ pay_params_res =
+                UtilMethods.payment_parameters_from_invoice(((Result_Bolt11InvoiceParseOrSemanticErrorZ.Result_Bolt11InvoiceParseOrSemanticErrorZ_OK) parsed_invoice).res);
+            assert pay_params_res.is_ok();
+            Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ.Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_OK pay_params =
+                (Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ.Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ_OK)pay_params_res;
+            Result_NoneRetryableSendFailureZ pay_res = peer1.chan_manager.send_payment(pay_params.res.get_a(), pay_params.res.get_b(), new byte[32], pay_params.res.get_c(), Retry.attempts(0));
+            assert pay_res.is_ok();
         }
 
         if (reload_peers) {
@@ -1038,25 +1106,25 @@ class HumanObjectPeerTestInstance {
 
         events = state.peer2.get_manager_events(1, state.peer1, state.peer2);
         assert events[0] instanceof Event.PaymentClaimable;
-        assert ((Event.PaymentClaimable)events[0]).purpose instanceof PaymentPurpose.InvoicePayment;
-        assert ((PaymentPurpose.InvoicePayment) ((Event.PaymentClaimable)events[0]).purpose).payment_preimage instanceof Option_PaymentPreimageZ.Some;
-        byte[] payment_preimage = ((Option_PaymentPreimageZ.Some) ((PaymentPurpose.InvoicePayment)((Event.PaymentClaimable)events[0]).purpose).payment_preimage).some;
+        assert ((Event.PaymentClaimable)events[0]).purpose instanceof PaymentPurpose.Bolt11InvoicePayment;
+        assert ((PaymentPurpose.Bolt11InvoicePayment) ((Event.PaymentClaimable)events[0]).purpose).payment_preimage instanceof Option_ThirtyTwoBytesZ.Some;
+        byte[] payment_preimage = ((Option_ThirtyTwoBytesZ.Some) ((PaymentPurpose.Bolt11InvoicePayment)((Event.PaymentClaimable)events[0]).purpose).payment_preimage).some;
         assert !Arrays.equals(payment_preimage, new byte[32]);
         state.peer2.chan_manager.claim_funds(payment_preimage);
 
         events = state.peer2.get_manager_events(1, state.peer1, state.peer2);
         assert events[0] instanceof Event.PaymentClaimed;
-        assert ((Event.PaymentClaimed)events[0]).purpose instanceof PaymentPurpose.InvoicePayment;
-        assert ((PaymentPurpose.InvoicePayment) ((Event.PaymentClaimed)events[0]).purpose).payment_preimage instanceof  Option_PaymentPreimageZ.Some;
-        payment_preimage = ((Option_PaymentPreimageZ.Some)((PaymentPurpose.InvoicePayment)((Event.PaymentClaimed)events[0]).purpose).payment_preimage).some;
+        assert ((Event.PaymentClaimed)events[0]).purpose instanceof PaymentPurpose.Bolt11InvoicePayment;
+        assert ((PaymentPurpose.Bolt11InvoicePayment) ((Event.PaymentClaimed)events[0]).purpose).payment_preimage instanceof  Option_ThirtyTwoBytesZ.Some;
+        payment_preimage = ((Option_ThirtyTwoBytesZ.Some)((PaymentPurpose.Bolt11InvoicePayment)((Event.PaymentClaimed)events[0]).purpose).payment_preimage).some;
         assert !Arrays.equals(payment_preimage, new byte[32]);
 
         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 ((Event.PaymentPathSuccessful) events[1]).payment_hash instanceof Option_PaymentHashZ.Some;
-        assert Arrays.equals(((Option_PaymentHashZ.Some) ((Event.PaymentPathSuccessful) events[1]).payment_hash).some, ((Event.PaymentSent) events[0]).payment_hash);
+        assert ((Event.PaymentPathSuccessful) events[1]).payment_hash instanceof Option_ThirtyTwoBytesZ.Some;
+        assert Arrays.equals(((Option_ThirtyTwoBytesZ.Some) ((Event.PaymentPathSuccessful) events[1]).payment_hash).some, ((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
@@ -1124,7 +1192,7 @@ class HumanObjectPeerTestInstance {
             Transaction tx = new Transaction(bitcoinj_net, state.peer1.broadcast_set.getFirst());
             Block b = new Block(bitcoinj_net, 2, state.best_blockhash, Sha256Hash.ZERO_HASH, 42, 0, 0,
                     Arrays.asList(new Transaction[]{tx}));
-            TwoTuple_TxidCVec_C2Tuple_u32TxOutZZZ[] watch_outputs = state.peer2.connect_block(b, 10, 1);
+            TwoTuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ[] watch_outputs = state.peer2.connect_block(b, 10, 1);
             if (watch_outputs != null) { // We only process watch_outputs manually when we use a manually-build Watch impl
                 assert watch_outputs.length == 1;
                 assert Arrays.equals(watch_outputs[0].get_a(), tx.getTxId().getReversedBytes());
@@ -1139,15 +1207,11 @@ class HumanObjectPeerTestInstance {
             }
 
             Event[] broadcastable_event = state.peer2.get_monitor_events(1);
-            for (ChannelMonitor mon : state.peer2.monitors.values()) {
-                // This used to be buggy and double-free, so go ahead and fetch them!
-                byte[][] txn = mon.get_latest_holder_commitment_txn(state.peer2.logger);
-            }
             assert broadcastable_event.length == 1;
             assert broadcastable_event[0] instanceof Event.SpendableOutputs;
             if (state.peer2.explicit_keys_manager != null) {
                 TxOut[] additional_outputs = new TxOut[]{new TxOut(420, new byte[]{0x42})};
-                Result_TransactionNoneZ tx_res = state.peer2.explicit_keys_manager.spend_spendable_outputs(((Event.SpendableOutputs) broadcastable_event[0]).outputs, additional_outputs, new byte[]{0x00}, 253, Option_PackedLockTimeZ.none());
+                Result_TransactionNoneZ tx_res = state.peer2.explicit_keys_manager.as_OutputSpender().spend_spendable_outputs(((Event.SpendableOutputs) broadcastable_event[0]).outputs, additional_outputs, new byte[]{0x00}, 253, Option_u32Z.none());
                 assert tx_res instanceof Result_TransactionNoneZ.Result_TransactionNoneZ_OK;
                 Transaction built_tx = new Transaction(bitcoinj_net, ((Result_TransactionNoneZ.Result_TransactionNoneZ_OK) tx_res).res);
                 assert built_tx.getOutputs().size() == 2;
@@ -1155,6 +1219,13 @@ class HumanObjectPeerTestInstance {
                 assert Arrays.equals(built_tx.getOutput(0).getScriptBytes(), new byte[]{0x42});
                 assert built_tx.getOutput(0).getValue().value == 420;
             }
+
+            while (state.peer1.peer_manager.list_peers().length != 0 || state.peer2.peer_manager.list_peers().length != 0) {
+                // LDK disconnects peers before sending an error message, so wait for disconnection.
+                Thread.sleep(10);
+            }
+
+            connect_peers(state.peer1, state.peer2);
         }
 
         // Test exchanging a custom message (note that ChannelManagerConstructor) always loads an IgnorimgMessageHandler
@@ -1180,8 +1251,8 @@ class HumanObjectPeerTestInstance {
 
         if (use_nio_peer_handler) {
             state.peer1.peer_manager.disconnect_by_node_id(state.peer2.chan_manager.get_our_node_id());
-            while (state.peer1.peer_manager.get_peer_node_ids().length != 0) Thread.yield();
-            while (state.peer2.peer_manager.get_peer_node_ids().length != 0) Thread.yield();
+            while (state.peer1.peer_manager.list_peers().length != 0) Thread.yield();
+            while (state.peer2.peer_manager.list_peers().length != 0) Thread.yield();
             state.peer1.nio_peer_handler.interrupt();
             state.peer2.nio_peer_handler.interrupt();
         }
@@ -1236,14 +1307,14 @@ class HumanObjectPeerTestInstance {
     }
 }
 public class HumanObjectPeerTest {
-    static HumanObjectPeerTestInstance do_test_run(boolean nice_close, boolean use_km_wrapper, boolean use_manual_watch, boolean reload_peers, boolean break_cross_peer_refs, boolean nio_peer_handler, boolean use_ignoring_routing_handler, boolean use_chan_manager_constructor, boolean use_invoice_payer) throws Exception {
-        HumanObjectPeerTestInstance instance = new HumanObjectPeerTestInstance(nice_close, use_km_wrapper, use_manual_watch, reload_peers, break_cross_peer_refs, nio_peer_handler, !nio_peer_handler, use_ignoring_routing_handler, use_chan_manager_constructor, use_invoice_payer);
+    static HumanObjectPeerTestInstance do_test_run(boolean nice_close, boolean use_km_wrapper, boolean use_full_km_wrapper, boolean use_manual_watch, boolean reload_peers, boolean break_cross_peer_refs, boolean nio_peer_handler, boolean use_ignoring_routing_handler, boolean use_chan_manager_constructor, boolean use_invoice_payer) throws Exception {
+        HumanObjectPeerTestInstance instance = new HumanObjectPeerTestInstance(nice_close, use_km_wrapper, use_full_km_wrapper, use_manual_watch, reload_peers, break_cross_peer_refs, nio_peer_handler, !nio_peer_handler, use_ignoring_routing_handler, use_chan_manager_constructor, use_invoice_payer);
         HumanObjectPeerTestInstance.TestState state = instance.do_test_message_handler();
         instance.do_test_message_handler_b(state);
         return instance;
     }
-    static void do_test(boolean nice_close, boolean use_km_wrapper, boolean use_manual_watch, boolean reload_peers, boolean break_cross_peer_refs, boolean nio_peer_handler, boolean use_ignoring_routing_handler, boolean use_chan_manager_constructor, boolean use_invoice_payer) throws Exception {
-        HumanObjectPeerTestInstance instance = do_test_run(nice_close, use_km_wrapper, use_manual_watch, reload_peers, break_cross_peer_refs, nio_peer_handler, use_ignoring_routing_handler, use_chan_manager_constructor, use_invoice_payer);
+    static void do_test(boolean nice_close, boolean use_km_wrapper, boolean use_full_km_wrapper, boolean use_manual_watch, boolean reload_peers, boolean break_cross_peer_refs, boolean nio_peer_handler, boolean use_ignoring_routing_handler, boolean use_chan_manager_constructor, boolean use_invoice_payer) throws Exception {
+        HumanObjectPeerTestInstance instance = do_test_run(nice_close, use_km_wrapper, use_full_km_wrapper, use_manual_watch, reload_peers, break_cross_peer_refs, nio_peer_handler, use_ignoring_routing_handler, use_chan_manager_constructor, use_invoice_payer);
         while (instance.gc_count != instance.gc_exp_count) {
             System.gc();
             System.runFinalization();
@@ -1251,7 +1322,7 @@ public class HumanObjectPeerTest {
         for (WeakReference<Object> o : instance.must_free_objs)
             assert o.get() == null;
     }
-    public static final int TEST_ITERATIONS = (1 << 9);
+    public static final int TEST_ITERATIONS = (1 << 10);
     public static void do_test_message_handler(IntConsumer statusFunction) throws Exception {
         Thread gc_thread = new Thread(() -> {
             while (true) {
@@ -1264,13 +1335,14 @@ public class HumanObjectPeerTest {
         for (int i = 0; i < TEST_ITERATIONS; i++) {
             boolean nice_close =                   (i & (1 << 0)) != 0;
             boolean use_km_wrapper =               (i & (1 << 1)) != 0;
-            boolean use_manual_watch =             (i & (1 << 2)) != 0;
-            boolean reload_peers =                 (i & (1 << 3)) != 0;
-            boolean break_cross_refs =             (i & (1 << 4)) != 0;
-            boolean use_ignoring_routing_handler = (i & (1 << 5)) != 0;
-            boolean use_chan_manager_constructor = (i & (1 << 6)) != 0;
-            boolean use_invoice_payer =            (i & (1 << 7)) != 0;
-            boolean nio_peer_handler =             (i & (1 << 8)) != 0;
+            boolean use_full_km_wrapper =          (i & (1 << 2)) != 0;
+            boolean use_manual_watch =             (i & (1 << 3)) != 0;
+            boolean reload_peers =                 (i & (1 << 4)) != 0;
+            boolean break_cross_refs =             (i & (1 << 5)) != 0;
+            boolean use_ignoring_routing_handler = (i & (1 << 6)) != 0;
+            boolean use_chan_manager_constructor = (i & (1 << 7)) != 0;
+            boolean use_invoice_payer =            (i & (1 << 8)) != 0;
+            boolean nio_peer_handler =             (i & (1 << 9)) != 0;
             if (break_cross_refs && !reload_peers) {
                 // There are no cross refs to break without reloading peers.
                 continue;
@@ -1286,7 +1358,7 @@ public class HumanObjectPeerTest {
             }
             if (use_chan_manager_constructor && use_ignoring_routing_handler && use_invoice_payer) {
                 // As documented on ChannelManagerConstructor, if we provide a `null` NetworkGraph (because we want to
-                // use an IgnoringMessageHandler), no InvoicePayer will be constructored for us, thus we cannot use an
+                // use an IgnoringMessageHandler), no InvoicePayer will be constructed for us, thus we cannot use an
                 // InvoicePayer to send payments in this case.
                 continue;
             }
@@ -1295,8 +1367,12 @@ public class HumanObjectPeerTest {
                 // any sense.
                 continue;
             }
+            if (use_full_km_wrapper && !use_km_wrapper) {
+                // Gotta use some KM wrapper if we're gonna use a full one.
+                continue;
+            }
             statusFunction.accept(i);
-            do_test(nice_close, use_km_wrapper, use_manual_watch, reload_peers, break_cross_refs, nio_peer_handler, use_ignoring_routing_handler, use_chan_manager_constructor, use_invoice_payer);
+            do_test(nice_close, use_km_wrapper, use_full_km_wrapper, use_manual_watch, reload_peers, break_cross_refs, nio_peer_handler, use_ignoring_routing_handler, use_chan_manager_constructor, use_invoice_payer);
         }
         gc_thread.interrupt();
         gc_thread.join();
@@ -1313,6 +1389,7 @@ public class HumanObjectPeerTest {
         } catch (Exception e) {
             System.err.println("Caught exception:");
             System.err.println(e);
+            e.printStackTrace();
             System.exit(1);
         }
     }