Skip to content

Commit 0884937

Browse files
authored
Merge pull request #61 from dappnode/go-ssv-fix-pubkey-post
Refactor public key extraction in entrypoint.sh
2 parents a927732 + 023184d commit 0884937

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)