Skip to content

Instantly share code, notes, and snippets.

@vicariousdrama
Created April 8, 2024 05:26
Show Gist options
  • Save vicariousdrama/3228e06e4f8546b76a4918e2c801bc1f to your computer and use it in GitHub Desktop.
Save vicariousdrama/3228e06e4f8546b76a4918e2c801bc1f to your computer and use it in GitHub Desktop.
Quick python script to convert a file with a list of npubs into hexadecimal pubkeys
#!/usr/bin/env python3
from nostr.key import PublicKey
import os
import shutil
import sys
filename = "listofnpubs.txt"
if not os.path.exists(filename):
sys.exit("File does not exist")
with open(filename) as f:
Lines = f.readlines()
for line in Lines:
npub = line.strip()
pubkey = PublicKey().from_npub(npub).hex()
print(pubkey)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment