- #[allow(unused_assignments)]
- let mut tx = Transaction {
- version: 2,
- lock_time: bitcoin::PackedLockTime::ZERO,
- input: vec![],
- output: vec![],
- };
- #[allow(unused_assignments)]
- let mut feerate = 0;
- #[cfg(anchors)] {
- feerate = if let Event::BumpTransaction(BumpTransactionEvent::HTLCResolution {
- target_feerate_sat_per_1000_weight, mut htlc_descriptors, tx_lock_time, ..
- }) = events.pop().unwrap() {
- let secp = Secp256k1::new();
- assert_eq!(htlc_descriptors.len(), 1);
- let descriptor = htlc_descriptors.pop().unwrap();
- assert_eq!(descriptor.commitment_txid, commitment_txn[0].txid());
- let htlc_output_idx = descriptor.htlc.transaction_output_index.unwrap() as usize;
- assert!(htlc_output_idx < commitment_txn[0].output.len());
- tx.lock_time = tx_lock_time;
- // Note that we don't care about actually making the HTLC transaction meet the
- // feerate for the test, we just want to make sure the feerates we receive from
- // the events never decrease.
- tx.input.push(descriptor.unsigned_tx_input());
- let signer = nodes[0].keys_manager.derive_channel_keys(
- descriptor.channel_value_satoshis, &descriptor.channel_keys_id,
- );
- let per_commitment_point = signer.get_per_commitment_point(
- descriptor.per_commitment_number, &secp
- );
- tx.output.push(descriptor.tx_output(&per_commitment_point, &secp));
- let our_sig = signer.sign_holder_htlc_transaction(&mut tx, 0, &descriptor, &secp).unwrap();
- let witness_script = descriptor.witness_script(&per_commitment_point, &secp);
- tx.input[0].witness = descriptor.tx_input_witness(&our_sig, &witness_script);
- target_feerate_sat_per_1000_weight as u64
- } else { panic!("unexpected event"); };
+ match &events[0] {
+ Event::BumpTransaction(event) => {
+ nodes[0].bump_tx_handler.handle_event(&event);
+ let mut txn = nodes[0].tx_broadcaster.unique_txn_broadcast();
+ assert_eq!(txn.len(), 1);
+ let htlc_tx = txn.pop().unwrap();
+ check_spends!(&htlc_tx, &commitment_txn[0], &coinbase_tx);
+ let htlc_tx_fee = HTLC_AMT_SAT + coinbase_tx.output[0].value -
+ htlc_tx.output.iter().map(|output| output.value).sum::<u64>();
+ let htlc_tx_weight = htlc_tx.weight() as u64;
+ (htlc_tx, compute_feerate_sat_per_1000_weight(htlc_tx_fee, htlc_tx_weight))
+ }
+ _ => panic!("Unexpected event"),