@@ -7471,6 +7471,8 @@ impl<SP: Deref> Writeable for Channel<SP> where SP::Target: SignerProvider {
74717471 let mut channel_state = self.context.channel_state;
74727472 if matches!(channel_state, ChannelState::AwaitingChannelReady(_)|ChannelState::ChannelReady(_)) {
74737473 channel_state.set_peer_disconnected();
7474+ } else {
7475+ debug_assert!(false, "Pre-funded/shutdown channels should not be written");
74747476 }
74757477 channel_state.to_u32().write(writer)?;
74767478 }
@@ -8891,17 +8893,34 @@ mod tests {
88918893 fn blinding_point_skimmed_fee_malformed_ser() {
88928894 // Ensure that channel blinding points, skimmed fees, and malformed HTLCs are (de)serialized
88938895 // properly.
8896+ let logger = test_utils::TestLogger::new();
88948897 let feeest = LowerBoundedFeeEstimator::new(&TestFeeEstimator{fee_est: 15000});
88958898 let secp_ctx = Secp256k1::new();
88968899 let seed = [42; 32];
88978900 let network = Network::Testnet;
8901+ let best_block = BestBlock::from_network(network);
88988902 let keys_provider = test_utils::TestKeysInterface::new(&seed, network);
88998903
89008904 let node_b_node_id = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap());
89018905 let config = UserConfig::default();
89028906 let features = channelmanager::provided_init_features(&config);
8903- let outbound_chan = OutboundV1Channel::<&TestKeysInterface>::new(&feeest, &&keys_provider, &&keys_provider, node_b_node_id, &features, 10000000, 100000, 42, &config, 0, 42, None).unwrap();
8904- let mut chan = Channel { context: outbound_chan.context };
8907+ let mut outbound_chan = OutboundV1Channel::<&TestKeysInterface>::new(
8908+ &feeest, &&keys_provider, &&keys_provider, node_b_node_id, &features, 10000000, 100000, 42, &config, 0, 42, None
8909+ ).unwrap();
8910+ let inbound_chan = InboundV1Channel::<&TestKeysInterface>::new(
8911+ &feeest, &&keys_provider, &&keys_provider, node_b_node_id, &channelmanager::provided_channel_type_features(&config),
8912+ &features, &outbound_chan.get_open_channel(ChainHash::using_genesis_block(network)), 7, &config, 0, &&logger, false
8913+ ).unwrap();
8914+ outbound_chan.accept_channel(&inbound_chan.get_accept_channel_message(), &config.channel_handshake_limits, &features).unwrap();
8915+ let tx = Transaction { version: 1, lock_time: LockTime::ZERO, input: Vec::new(), output: vec![TxOut {
8916+ value: 10000000, script_pubkey: outbound_chan.context.get_funding_redeemscript(),
8917+ }]};
8918+ let funding_outpoint = OutPoint{ txid: tx.txid(), index: 0 };
8919+ let funding_created = outbound_chan.get_funding_created(tx.clone(), funding_outpoint, false, &&logger).map_err(|_| ()).unwrap().unwrap();
8920+ let mut chan = match inbound_chan.funding_created(&funding_created, best_block, &&keys_provider, &&logger) {
8921+ Ok((chan, _, _)) => chan,
8922+ Err((_, e)) => panic!("{}", e),
8923+ };
89058924
89068925 let dummy_htlc_source = HTLCSource::OutboundRoute {
89078926 path: Path {
0 commit comments