- let mut payment_preimage = None;
- for i in 0..payments_sent {
- let mut payment_hash = [0; 32];
- payment_hash[0..8].copy_from_slice(&be64_to_array(i));
- let mut sha = Sha256::new();
- sha.input(&payment_hash);
- sha.result(&mut payment_hash);
- for i in 1..32 { payment_hash[i] = 0; }
- if payment_hash == payment {
- payment_hash = [0; 32];
- payment_hash[0..8].copy_from_slice(&be64_to_array(i));
- payment_preimage = Some(payment_hash);
- break;
- }
- }
- channelmanager.claim_funds(payment_preimage.unwrap());
+ let mut payment_preimage = [0; 32];
+ payment_preimage[0] = payment[0];
+ let mut sha = Sha256::new();
+ sha.input(&payment_preimage);
+ let mut payment_hash_check = [0; 32];
+ sha.result(&mut payment_hash_check);
+ assert!(payment_hash_check == payment);
+ channelmanager.claim_funds(payment_preimage);