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:
parent
f79f20d4e6
commit
ffd5664c08
|
@ -402,8 +402,7 @@ impl Psbt {
|
||||||
/// # Returns
|
/// # Returns
|
||||||
///
|
///
|
||||||
/// - Ok: A list of the public keys used in signing.
|
/// - 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
|
/// - Err: Error encountered trying to calculate the sighash AND we had the signing key.
|
||||||
/// if input_index is out of bounds.
|
|
||||||
fn bip32_sign_schnorr<C, K, T>(
|
fn bip32_sign_schnorr<C, K, T>(
|
||||||
&mut self,
|
&mut self,
|
||||||
k: &K,
|
k: &K,
|
||||||
|
@ -416,7 +415,7 @@ impl Psbt {
|
||||||
T: Borrow<Transaction>,
|
T: Borrow<Transaction>,
|
||||||
K: GetKey,
|
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.
|
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)
|
Ok(used)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue