@@ -178,16 +178,16 @@ public ChannelMonitorUpdateStatus update_channel(OutPoint funding_txo, ChannelMo
178178 }
179179
180180 @ Override
181- public ThreeTuple_OutPointCVec_MonitorEventZPublicKeyZ [] release_pending_monitor_events () {
181+ public FourTuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ [] release_pending_monitor_events () {
182182 synchronized (monitors ) {
183183 assert monitors .size () <= 1 ;
184184 for (ChannelMonitor mon : monitors .values ()) {
185- ThreeTuple_OutPointCVec_MonitorEventZPublicKeyZ [] res = new ThreeTuple_OutPointCVec_MonitorEventZPublicKeyZ [1 ];
186- res [0 ] = ThreeTuple_OutPointCVec_MonitorEventZPublicKeyZ .of (mon .get_funding_txo ().get_a (), mon .get_and_clear_pending_monitor_events (), mon .get_counterparty_node_id ());
185+ FourTuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ [] res = new FourTuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ [1 ];
186+ 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 ());
187187 return res ;
188188 }
189189 }
190- return new ThreeTuple_OutPointCVec_MonitorEventZPublicKeyZ [0 ];
190+ return new FourTuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ [0 ];
191191 }
192192 };
193193 Watch watch = Watch .new_impl (watch_impl );
@@ -277,7 +277,7 @@ private Peer(Object _dummy, byte seed) {
277277 @ Override
278278 public ChannelMonitorUpdateStatus persist_new_channel (OutPoint id , ChannelMonitor data , MonitorUpdateId update_id ) {
279279 synchronized (monitors ) {
280- String key = Arrays .toString (id . to_channel_id ());
280+ String key = Arrays .toString (ChannelId . v1_from_funding_outpoint ( id ). get_a ());
281281 ChannelMonitor res = test_mon_roundtrip (id , data .write ());
282282 assert monitors .put (key , res ) == null ;
283283 }
@@ -287,14 +287,19 @@ public ChannelMonitorUpdateStatus persist_new_channel(OutPoint id, ChannelMonito
287287 @ Override
288288 public ChannelMonitorUpdateStatus update_persisted_channel (OutPoint id , ChannelMonitorUpdate update , ChannelMonitor data , MonitorUpdateId update_id ) {
289289 synchronized (monitors ) {
290- String key = Arrays .toString (id . to_channel_id ());
290+ String key = Arrays .toString (ChannelId . v1_from_funding_outpoint ( id ). get_a ());
291291 ChannelMonitor res = test_mon_roundtrip (id , data .write ());
292292 // Note that we use a serialization-roundtrip copy of data here, not the original, as this can
293293 // expose the JVM JIT bug where it finalize()s things still being called.
294294 assert monitors .put (key , res ) != null ;
295295 }
296296 return ChannelMonitorUpdateStatus .LDKChannelMonitorUpdateStatus_Completed ;
297297 }
298+
299+ @ Override
300+ public void archive_persisted_channel (OutPoint channel_funding_outpoint ) {
301+ assert false ;
302+ }
298303 });
299304
300305 filter_additions = new HashSet <>();
@@ -822,7 +827,7 @@ void connect_peers(final Peer peer1, final Peer peer2) {
822827 try {
823828 peer1 .nio_peer_handler .connect (peer2 .chan_manager .get_our_node_id (), new InetSocketAddress ("127.0.0.1" , peer2 .nio_port ), 100 );
824829 } catch (IOException e ) { assert false ; }
825- while (peer1 .peer_manager .get_peer_node_ids ().length == 0 || peer2 .peer_manager .get_peer_node_ids ().length == 0 ) {
830+ while (peer1 .peer_manager .list_peers ().length == 0 || peer2 .peer_manager .list_peers ().length == 0 ) {
826831 Thread .yield ();
827832 }
828833 } else {
@@ -871,8 +876,8 @@ TestState do_test_message_handler() throws InterruptedException {
871876
872877 UInt128 user_id = new UInt128 (new byte [] {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 });
873878
874- Result_ThirtyTwoBytesAPIErrorZ cc_res = peer1 .chan_manager .create_channel (peer2 .node_id , 100000 , 1000 , user_id , Option_ThirtyTwoBytesZ . none () , null );
875- assert cc_res instanceof Result_ThirtyTwoBytesAPIErrorZ . Result_ThirtyTwoBytesAPIErrorZ_OK ;
879+ Result_ChannelIdAPIErrorZ cc_res = peer1 .chan_manager .create_channel (peer2 .node_id , 100000 , 1000 , user_id , null , null );
880+ assert cc_res instanceof Result_ChannelIdAPIErrorZ . Result_ChannelIdAPIErrorZ_OK ;
876881
877882 // Previously, this was a SEGFAULT instead of get_funding_txo() returning null.
878883 ChannelDetails pre_funding_chan = peer1 .chan_manager .list_channels ()[0 ];
@@ -884,7 +889,7 @@ TestState do_test_message_handler() throws InterruptedException {
884889 assert ((Event .FundingGenerationReady ) events [0 ]).user_channel_id .equals (user_id );
885890 byte [] funding_spk = ((Event .FundingGenerationReady ) events [0 ]).output_script ;
886891 assert funding_spk .length == 34 && funding_spk [0 ] == 0 && funding_spk [1 ] == 32 ; // P2WSH
887- byte [] chan_id = ((Event .FundingGenerationReady ) events [0 ]).temporary_channel_id ;
892+ ChannelId chan_id = ((Event .FundingGenerationReady ) events [0 ]).temporary_channel_id ;
888893
889894 BitcoinNetworkParams bitcoinj_net = BitcoinNetworkParams .of (BitcoinNetwork .MAINNET );
890895
@@ -945,8 +950,8 @@ TestState do_test_message_handler() throws InterruptedException {
945950 Option_u64Z short_chan_id = peer1_chans [0 ].get_short_channel_id ();
946951 assert short_chan_id instanceof Option_u64Z .Some ;
947952 assert ((Option_u64Z .Some )short_chan_id ).some == (1L << 40 ); // 0th output in the 0th transaction in the 1st block
948- assert Arrays .equals (peer1_chans [0 ].get_channel_id (), funding .getTxId ().getReversedBytes ());
949- assert Arrays .equals (peer2_chans [0 ].get_channel_id (), funding .getTxId ().getReversedBytes ());
953+ assert Arrays .equals (peer1_chans [0 ].get_channel_id (). get_a () , funding .getTxId ().getReversedBytes ());
954+ assert Arrays .equals (peer2_chans [0 ].get_channel_id (). get_a () , funding .getTxId ().getReversedBytes ());
950955
951956 // Generate a random invoice description to exercise the string conversion logic a good bit
952957 String invoice_description ;
@@ -1101,17 +1106,17 @@ void do_test_message_handler_b(TestState state) throws Exception {
11011106
11021107 events = state .peer2 .get_manager_events (1 , state .peer1 , state .peer2 );
11031108 assert events [0 ] instanceof Event .PaymentClaimable ;
1104- assert ((Event .PaymentClaimable )events [0 ]).purpose instanceof PaymentPurpose .InvoicePayment ;
1105- assert ((PaymentPurpose .InvoicePayment ) ((Event .PaymentClaimable )events [0 ]).purpose ).payment_preimage instanceof Option_ThirtyTwoBytesZ .Some ;
1106- byte [] payment_preimage = ((Option_ThirtyTwoBytesZ .Some ) ((PaymentPurpose .InvoicePayment )((Event .PaymentClaimable )events [0 ]).purpose ).payment_preimage ).some ;
1109+ assert ((Event .PaymentClaimable )events [0 ]).purpose instanceof PaymentPurpose .Bolt11InvoicePayment ;
1110+ assert ((PaymentPurpose .Bolt11InvoicePayment ) ((Event .PaymentClaimable )events [0 ]).purpose ).payment_preimage instanceof Option_ThirtyTwoBytesZ .Some ;
1111+ byte [] payment_preimage = ((Option_ThirtyTwoBytesZ .Some ) ((PaymentPurpose .Bolt11InvoicePayment )((Event .PaymentClaimable )events [0 ]).purpose ).payment_preimage ).some ;
11071112 assert !Arrays .equals (payment_preimage , new byte [32 ]);
11081113 state .peer2 .chan_manager .claim_funds (payment_preimage );
11091114
11101115 events = state .peer2 .get_manager_events (1 , state .peer1 , state .peer2 );
11111116 assert events [0 ] instanceof Event .PaymentClaimed ;
1112- assert ((Event .PaymentClaimed )events [0 ]).purpose instanceof PaymentPurpose .InvoicePayment ;
1113- assert ((PaymentPurpose .InvoicePayment ) ((Event .PaymentClaimed )events [0 ]).purpose ).payment_preimage instanceof Option_ThirtyTwoBytesZ .Some ;
1114- payment_preimage = ((Option_ThirtyTwoBytesZ .Some )((PaymentPurpose .InvoicePayment )((Event .PaymentClaimed )events [0 ]).purpose ).payment_preimage ).some ;
1117+ assert ((Event .PaymentClaimed )events [0 ]).purpose instanceof PaymentPurpose .Bolt11InvoicePayment ;
1118+ assert ((PaymentPurpose .Bolt11InvoicePayment ) ((Event .PaymentClaimed )events [0 ]).purpose ).payment_preimage instanceof Option_ThirtyTwoBytesZ .Some ;
1119+ payment_preimage = ((Option_ThirtyTwoBytesZ .Some )((PaymentPurpose .Bolt11InvoicePayment )((Event .PaymentClaimed )events [0 ]).purpose ).payment_preimage ).some ;
11151120 assert !Arrays .equals (payment_preimage , new byte [32 ]);
11161121
11171122 events = state .peer1 .get_manager_events (2 , state .peer1 , state .peer2 );
@@ -1202,15 +1207,11 @@ void do_test_message_handler_b(TestState state) throws Exception {
12021207 }
12031208
12041209 Event [] broadcastable_event = state .peer2 .get_monitor_events (1 );
1205- for (ChannelMonitor mon : state .peer2 .monitors .values ()) {
1206- // This used to be buggy and double-free, so go ahead and fetch them!
1207- byte [][] txn = mon .get_latest_holder_commitment_txn (state .peer2 .logger );
1208- }
12091210 assert broadcastable_event .length == 1 ;
12101211 assert broadcastable_event [0 ] instanceof Event .SpendableOutputs ;
12111212 if (state .peer2 .explicit_keys_manager != null ) {
12121213 TxOut [] additional_outputs = new TxOut []{new TxOut (420 , new byte []{0x42 })};
1213- 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_u32Z .none ());
1214+ 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 ());
12141215 assert tx_res instanceof Result_TransactionNoneZ .Result_TransactionNoneZ_OK ;
12151216 Transaction built_tx = new Transaction (bitcoinj_net , ((Result_TransactionNoneZ .Result_TransactionNoneZ_OK ) tx_res ).res );
12161217 assert built_tx .getOutputs ().size () == 2 ;
@@ -1219,7 +1220,7 @@ void do_test_message_handler_b(TestState state) throws Exception {
12191220 assert built_tx .getOutput (0 ).getValue ().value == 420 ;
12201221 }
12211222
1222- while (state .peer1 .peer_manager .get_peer_node_ids ().length != 0 || state .peer2 .peer_manager .get_peer_node_ids ().length != 0 ) {
1223+ while (state .peer1 .peer_manager .list_peers ().length != 0 || state .peer2 .peer_manager .list_peers ().length != 0 ) {
12231224 // LDK disconnects peers before sending an error message, so wait for disconnection.
12241225 Thread .sleep (10 );
12251226 }
@@ -1250,8 +1251,8 @@ void do_test_message_handler_b(TestState state) throws Exception {
12501251
12511252 if (use_nio_peer_handler ) {
12521253 state .peer1 .peer_manager .disconnect_by_node_id (state .peer2 .chan_manager .get_our_node_id ());
1253- while (state .peer1 .peer_manager .get_peer_node_ids ().length != 0 ) Thread .yield ();
1254- while (state .peer2 .peer_manager .get_peer_node_ids ().length != 0 ) Thread .yield ();
1254+ while (state .peer1 .peer_manager .list_peers ().length != 0 ) Thread .yield ();
1255+ while (state .peer2 .peer_manager .list_peers ().length != 0 ) Thread .yield ();
12551256 state .peer1 .nio_peer_handler .interrupt ();
12561257 state .peer2 .nio_peer_handler .interrupt ();
12571258 }
0 commit comments