From 023184dcb4c5f262e0f3e6dc141160f267998728 Mon Sep 17 00:00:00 2001 From: Chuy Garcia <75956027+chuygarcia92@users.noreply.github.com> Date: Tue, 20 Oct 2026 14:05:00 -0600 Subject: [PATCH] Refactor public key extraction in entrypoint.sh Updated public key extraction logic to handle multiple field names and added error message for missing keys. --- operator/entrypoint.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/operator/entrypoint.sh b/operator/entrypoint.sh index e0e4f12..025095d 100755 --- a/operator/entrypoint.sh +++ b/operator/entrypoint.sh @@ -64,11 +64,12 @@ handle_private_key() { } post_pubkey_to_dappmanager() { - PUBLIC_KEY=$(jq -r '.pubKey' "${PRIVATE_KEY_FILE}") + # The field name varies by keystore format/version: pubKey, publicKey or pubkey + PUBLIC_KEY=$(jq -r '(.pubKey // .publicKey // .pubkey // empty)' "${PRIVATE_KEY_FILE}") - # If the PUBLIC_KEY is empty, try extracting using the '.publicKey' field (for previous SSV versions) - if [ -z "$PUBLIC_KEY" ] || [ "$PUBLIC_KEY" = "null" ]; then - PUBLIC_KEY=$(jq -r '.publicKey' "${PRIVATE_KEY_FILE}") + if [ -z "${PUBLIC_KEY}" ]; then + echo "[ERROR] Public key not found in ${PRIVATE_KEY_FILE}. Fields present: $(jq -c 'keys' "${PRIVATE_KEY_FILE}")" + return 0 fi curl --connect-timeout 5 \