#!/bin/bash
# NOSTR Account Restore Instructions
# Usage: ./RESTORE_INSTRUCTIONS.sh

echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "   NOSTR Account Restore Instructions"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "This encrypted backup contains:"
echo "  • nostr_export.json - All your Nostr events"
echo "  • uDRIVE_manifest.json - Your uDRIVE file manifest"
echo "  • .secret.disco - Your OLD secret key (for reference)"
echo "  • .next.disco - PRE-GENERATED new .disco for restoration"
echo "  • .next.hex - Next HEX address for new relay/captain"
echo "  • secret.june - ZEN Card transaction history (capital shares)"
echo "  • .g1pub - ZEN Card G1 wallet access"
echo ""
echo "🔐 BACKUP PASSWORD: "
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "IMPORTANT: Account Migration to New Relay/Captain"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "Your account has been deactivated on the previous relay."
echo "To restore on a NEW relay/captain, you MUST use the NEW .disco:"
echo ""
if [[ -n "9317c635735824d1233d010c4548b96d8bd3d6293787dc707ca2639fcedcbf00" ]]; then
    echo "  🔮 Next HEX (pre-generated): 9317c635735824d1233d..."
    echo "  📝 New .disco: .next.disco (in backup)"
    echo ""
    echo "The next HEX is also stored in:"
    echo "  • Your DID document (did:nostr:e89a5d30ca5d450522c032fc6fde67846312eb6fd4a232f7f6075411b90c0b49)"
    echo "  • Your NOSTR profile (about field)"
    echo ""
else
    echo "  ⚠️  Next HEX not pre-generated - you'll need to create new .disco"
    echo ""
fi
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "RESTORATION METHODS:"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "Method 1: Automated restore (RECOMMENDED)"
echo "  cd ~/.zen/Astroport.ONE"
echo "  ./tools/nostr_RESTORE_TW.sh <IPFS_CID>"
echo "  (Script will use .next.disco automatically)"
echo ""
echo "Method 2: Manual restoration with NEW .disco"
echo "  1. Extract backup with password: "
echo "  2. Use .next.disco to create MULTIPASS on new relay:"
echo "     cat .next.disco"
echo "     # Use this .disco when creating new MULTIPASS"
echo "  3. Create MULTIPASS with same email + .next.disco:"
echo "     ./tools/make_NOSTRCARD.sh <EMAIL> <LANG> <LAT> <LON> <NEW_SALT> <NEW_PEPPER>"
echo "  4. Import events to new account:"
echo "     jq -c '.[]' nostr_export.json | ./strfry import --no-verify"
echo ""
echo "Method 3: uDRIVE restoration"
echo "  - Use uDRIVE_manifest.json to recreate your file structure"
echo "  - All files are still available via IPFS links in manifest"
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "ZEN Card Capital Shares:"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "Your ZEN Card capital shares are preserved in secret.june"
echo "This file contains the transaction history of capital shares"
echo "received from UPLANETNAME_SOCIETY."
echo ""
echo "The ZEN Card wallet (.g1pub) is NOT emptied - it maintains"
echo "minimum 1 G1 for capital shares management."
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
