- // Use the same construction as a lightning channel id to generate
- // the package id for this request based on the first HTLC. It
- // doesn't matter what we use as long as it's unique per request.
- let mut package_id = [0; 32];
- package_id[..].copy_from_slice(&htlcs[0].commitment_txid[..]);
- let htlc_output_index = htlcs[0].htlc.transaction_output_index.unwrap();
- package_id[30] ^= ((htlc_output_index >> 8) & 0xff) as u8;
- package_id[31] ^= ((htlc_output_index >> 0) & 0xff) as u8;
- package_id
+ // For HTLC claims, commit to the entire set of HTLC outputs to
+ // claim, which will always be unique per request. Once a claim ID
+ // is generated, it is assigned and remains unchanged, even if the
+ // underlying set of HTLCs changes.
+ let mut engine = Sha256::engine();
+ for htlc in htlcs {
+ engine.input(&htlc.commitment_txid.into_inner());
+ engine.input(&htlc.htlc.transaction_output_index.unwrap().to_be_bytes());
+ }
+ ClaimId(Sha256::from_engine(engine).into_inner())