+ for &opt_anchors in [false, true].iter() {
+ let mut claim_tx = Transaction { version: 0, lock_time: 0, input: Vec::new(), output: Vec::new() };
+ let mut sum_actual_sigs = 0;
+ for i in 0..4 {
+ claim_tx.input.push(TxIn {
+ previous_output: BitcoinOutPoint {
+ txid,
+ vout: i,
+ },
+ script_sig: Script::new(),
+ sequence: 0xfffffffd,
+ witness: Vec::new(),
+ });
+ }
+ claim_tx.output.push(TxOut {
+ script_pubkey: script_pubkey.clone(),
+ value: 0,
+ });
+ let base_weight = claim_tx.get_weight();
+ let inputs_weight = vec![weight_offered_htlc(opt_anchors), weight_received_htlc(opt_anchors), weight_received_htlc(opt_anchors), weight_received_htlc(opt_anchors)];
+ let mut inputs_total_weight = 2; // count segwit flags
+ {
+ let mut sighash_parts = bip143::SigHashCache::new(&mut claim_tx);
+ for (idx, inp) in inputs_weight.iter().enumerate() {
+ sign_input!(sighash_parts, idx, 0, inp, sum_actual_sigs, opt_anchors);
+ inputs_total_weight += inp;
+ }
+ }
+ assert_eq!(base_weight + inputs_total_weight as usize, claim_tx.get_weight() + /* max_length_sig */ (73 * inputs_weight.len() - sum_actual_sigs));
+ }
+
+ // Justice tx with 1 revoked HTLC-Success tx output
+ for &opt_anchors in [false, true].iter() {
+ let mut claim_tx = Transaction { version: 0, lock_time: 0, input: Vec::new(), output: Vec::new() };
+ let mut sum_actual_sigs = 0;