Do not panic if input_index is out of bounds

There is no need to panic if input index is out of bounds because we
have a function to check the validity of the `input_index` argument and
use it in other places already.
This commit is contained in:
Tobin C. Harding 2024-04-03 12:33:30 +11:00
parent f79f20d4e6
commit ffd5664c08
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 3 additions and 4 deletions

View File

@ -402,8 +402,7 @@ impl Psbt {
/// # Returns
///
/// - Ok: A list of the public keys used in signing.
/// - Err: Error encountered trying to calculate the sighash AND we had the signing key. Also panics
/// if input_index is out of bounds.
/// - Err: Error encountered trying to calculate the sighash AND we had the signing key.
fn bip32_sign_schnorr<C, K, T>(
&mut self,
k: &K,
@ -416,7 +415,7 @@ impl Psbt {
T: Borrow<Transaction>,
K: GetKey,
{
let mut input = self.inputs[input_index].clone();
let mut input = self.checked_input(input_index)?.clone();
let mut used = vec![]; // List of pubkeys used to sign the input.
@ -487,7 +486,7 @@ impl Psbt {
}
}
self.inputs[input_index] = input;
self.inputs[input_index] = input; // input_index is checked above.
Ok(used)
}