+
+ assert!(!node_a_chan.channel_update(&update).unwrap());
+ }
+
+ #[test]
+ fn blinding_point_ser() {
+ // Ensure that channel blinding points are (de)serialized properly.
+ let feeest = LowerBoundedFeeEstimator::new(&TestFeeEstimator{fee_est: 15000});
+ let secp_ctx = Secp256k1::new();
+ let seed = [42; 32];
+ let network = Network::Testnet;
+ let keys_provider = test_utils::TestKeysInterface::new(&seed, network);
+
+ let node_b_node_id = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap());
+ let config = UserConfig::default();
+ let features = channelmanager::provided_init_features(&config);
+ let outbound_chan = OutboundV1Channel::<&TestKeysInterface>::new(&feeest, &&keys_provider, &&keys_provider, node_b_node_id, &features, 10000000, 100000, 42, &config, 0, 42, None).unwrap();
+ let mut chan = Channel { context: outbound_chan.context };
+
+ let dummy_htlc_source = HTLCSource::OutboundRoute {
+ path: Path {
+ hops: vec![RouteHop {
+ pubkey: test_utils::pubkey(2), channel_features: ChannelFeatures::empty(),
+ node_features: NodeFeatures::empty(), short_channel_id: 0, fee_msat: 0,
+ cltv_expiry_delta: 0, maybe_announced_channel: false,
+ }],
+ blinded_tail: None
+ },
+ session_priv: test_utils::privkey(42),
+ first_hop_htlc_msat: 0,
+ payment_id: PaymentId([42; 32]),
+ };
+ let dummy_outbound_output = OutboundHTLCOutput {
+ htlc_id: 0,
+ amount_msat: 0,
+ payment_hash: PaymentHash([43; 32]),
+ cltv_expiry: 0,
+ state: OutboundHTLCState::Committed,
+ source: dummy_htlc_source.clone(),
+ skimmed_fee_msat: None,
+ blinding_point: None,
+ };
+ let mut pending_outbound_htlcs = vec![dummy_outbound_output.clone(); 10];
+ for (idx, htlc) in pending_outbound_htlcs.iter_mut().enumerate() {
+ if idx % 2 == 0 {
+ htlc.blinding_point = Some(test_utils::pubkey(42 + idx as u8));
+ }
+ }
+ chan.context.pending_outbound_htlcs = pending_outbound_htlcs.clone();
+
+ let dummy_holding_cell_add_htlc = HTLCUpdateAwaitingACK::AddHTLC {
+ amount_msat: 0,
+ cltv_expiry: 0,
+ payment_hash: PaymentHash([43; 32]),
+ source: dummy_htlc_source.clone(),
+ onion_routing_packet: msgs::OnionPacket {
+ version: 0,
+ public_key: Ok(test_utils::pubkey(1)),
+ hop_data: [0; 20*65],
+ hmac: [0; 32]
+ },
+ skimmed_fee_msat: None,
+ blinding_point: None,
+ };
+ let dummy_holding_cell_claim_htlc = HTLCUpdateAwaitingACK::ClaimHTLC {
+ payment_preimage: PaymentPreimage([42; 32]),
+ htlc_id: 0,
+ };
+ let mut holding_cell_htlc_updates = Vec::with_capacity(10);
+ for i in 0..10 {
+ if i % 3 == 0 {
+ holding_cell_htlc_updates.push(dummy_holding_cell_add_htlc.clone());
+ } else if i % 3 == 1 {
+ holding_cell_htlc_updates.push(dummy_holding_cell_claim_htlc.clone());
+ } else {
+ let mut dummy_add = dummy_holding_cell_add_htlc.clone();
+ if let HTLCUpdateAwaitingACK::AddHTLC { ref mut blinding_point, .. } = &mut dummy_add {
+ *blinding_point = Some(test_utils::pubkey(42 + i));
+ } else { panic!() }
+ holding_cell_htlc_updates.push(dummy_add);
+ }
+ }
+ chan.context.holding_cell_htlc_updates = holding_cell_htlc_updates.clone();
+
+ // Encode and decode the channel and ensure that the HTLCs within are the same.
+ let encoded_chan = chan.encode();
+ let mut s = crate::io::Cursor::new(&encoded_chan);
+ let mut reader = crate::util::ser::FixedLengthReader::new(&mut s, encoded_chan.len() as u64);
+ let features = channelmanager::provided_channel_type_features(&config);
+ let decoded_chan = Channel::read(&mut reader, (&&keys_provider, &&keys_provider, 0, &features)).unwrap();
+ assert_eq!(decoded_chan.context.pending_outbound_htlcs, pending_outbound_htlcs);
+ assert_eq!(decoded_chan.context.holding_cell_htlc_updates, holding_cell_htlc_updates);