psbt: rename key_index to found_index in key_iter_next for better code reading
What changed, and why it matters
This commit is a pure variable rename inside a single function. The local variable `key_index` is renamed to `found_index` to make the code easier to read. No logic, behavior, or security properties change.
No security action needed; treat as a routine code-quality change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In main/utils/psbt.c, the function key_iter_next() previously declared size_t key_index; and used it to receive an output index from wally_map_keypath_get_bip32_key_from or wally_map_keypath_get_bip32_public_key_from. The commit renames that local variable to found_index and updates all three references within the function. The diff is +4/-4 with identical control flow and semantics.
Changed components
main/utils/psbt.cInspect captured patch +4 / −4
diff --git a/main/utils/psbt.c b/main/utils/psbt.c
index 27fa012..0bc8243 100644
--- a/main/utils/psbt.c
+++ b/main/utils/psbt.c
@@ -84,7 +84,7 @@ static const struct wally_map* key_iter_get_keypaths(const key_iter* iter)
bool key_iter_next(key_iter* iter)
{
const struct wally_map* keypaths = key_iter_get_keypaths(iter);
- size_t key_index;
+ size_t found_index;
++iter->key_index;
if (iter->is_taproot && !iter->key_index) {
// First iteration: validate
@@ -97,12 +97,12 @@ bool key_iter_next(key_iter* iter)
get_bip32_key_fn get_key
= iter->is_private ? wally_map_keypath_get_bip32_key_from : wally_map_keypath_get_bip32_public_key_from;
- ret = get_key(keypaths, iter->key_index, &keychain_get()->xpriv, &iter->hdkey, &key_index);
+ ret = get_key(keypaths, iter->key_index, &keychain_get()->xpriv, &iter->hdkey, &found_index);
JADE_WALLY_VERIFY(ret);
- if (key_index) {
+ if (found_index) {
iter->is_valid = true; // Found
- iter->key_index = key_index - 1; // Adjust to 0-based index
+ iter->key_index = found_index - 1; // Adjust to 0-based index
} else {
iter->is_valid = false; // Not found
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.