Skip to content

Commit 023184d

Browse files
authored
Refactor public key extraction in entrypoint.sh
Updated public key extraction logic to handle multiple field names and added error message for missing keys.
1 parent a927732 commit 023184d

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎operator/entrypoint.sh‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,12 @@ handle_private_key() {
6464
}
6565

6666
post_pubkey_to_dappmanager() {
67-
PUBLIC_KEY=$(jq -r '.pubKey' "${PRIVATE_KEY_FILE}")
67+
# The field name varies by keystore format/version: pubKey, publicKey or pubkey
68+
PUBLIC_KEY=$(jq -r '(.pubKey // .publicKey // .pubkey // empty)' "${PRIVATE_KEY_FILE}")
6869

69-
# If the PUBLIC_KEY is empty, try extracting using the '.publicKey' field (for previous SSV versions)
70-
if [ -z "$PUBLIC_KEY" ] || [ "$PUBLIC_KEY" = "null" ]; then
71-
PUBLIC_KEY=$(jq -r '.publicKey' "${PRIVATE_KEY_FILE}")
70+
if [ -z "${PUBLIC_KEY}" ]; then
71+
echo "[ERROR] Public key not found in ${PRIVATE_KEY_FILE}. Fields present: $(jq -c 'keys' "${PRIVATE_KEY_FILE}")"
72+
return 0
7273
fi
7374

7475
curl --connect-timeout 5 \

0 commit comments

Comments
 (0)