{
 "cells": [
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "",
   "id": "1865ec9f54c7b22e"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": [
    "# Hello there, fellow DVM enthusiast\n",
    "This is the first of a series of tutorials on how to use nostr-dvm.\n",
    "\n",
    "Before we start, we have to make sure you have a .env file in the working directory.\n",
    "\n",
    "In order to make sure you have it and to get you started quickly, here is a small function to create an inital .env file for you. Just make sure you set the parameters in the following field:"
   ],
   "id": "e1f5dcfcad069462"
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": [
    "lnbits_admin_key = \"\" #TODO set your key here\n",
    "lnbits_wallet_id = \"\" #TODO set your key here\n",
    "lnbits_host= \"https://demo.lnbits.com\" #TODO you can use demo.lnbits.com, but rather use your own instance\n",
    "nostdress_domain = \"nostrdvm.com\" # use your own nostdress instance, or use the default one"
   ],
   "id": "2e71e7aa2ebdac50"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": [
    "LNBITS_HOST is an Lnbits instance. We'll use Lnbits to generate wallets for each DVM automatically.\n",
    "You can use the demo server, but it is highly recommended to move to your own instance,\n",
    "or an instance of someone you trust.\n",
    "\n",
    "LNBITS_ADMIN_KEY  and LNBITS_WALLET_ID are the API keys you get from Lnbits. You might also want to activate the User Manager module in LNBits.\n",
    "\n",
    "NOSTDRESS_DOMAIN: You can run your own instance of Nostdress https://github.com/believethehype/nostdress, so your DVMs get their own unique zapable lightning address, or you can use the default one. Make sure that the used identifier is unique, or otherwise it will add some random string to your identifier.\n",
    "\n",
    " By the way, if that's not your kind of thing, you don't have to set an Lnbits account. If your DVM should receive zaps somehow, make sure you manually set a valid, zappable lightning address in its profile, once we created it. In this case leave the lnbits_admin_key and lnbits_wallet_id empty\n"
   ],
   "id": "bb26e7180f1d1f0"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "The following script will make an initial .env file with the parameters set in the field above, if it doesn't exist yet.\n",
   "id": "f6b316e1cace5adc"
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2024-09-16T13:36:56.451990Z",
     "start_time": "2024-09-16T13:36:56.448752Z"
    }
   },
   "cell_type": "code",
   "source": [
    "config =  \"LNBITS_ADMIN_KEY = \\\"\"+lnbits_admin_key+\"\\\"\\nLNBITS_WALLET_ID = \\\"\"+ lnbits_wallet_id +\"\\\"\\nLNBITS_HOST = \\\"\"+ lnbits_host + \"\\\"\\nNOSTDRESS_DOMAIN = \\\"\" + nostdress_domain + \"\\\"\"\n",
    "\n",
    "import os.path\n",
    "if not os.path.isfile(\".env\"):\n",
    "    with open(\".env\", \"w\") as f:   # Opens file and casts as f \n",
    "        f.write(config)       # Writing\n",
    "        # File closed automatically\n",
    "else:\n",
    "    print(\".env file already exists\")"
   ],
   "id": "a3e16002be388215",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      ".env file already exists\n"
     ]
    }
   ],
   "execution_count": 8
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "Cool. That's it for the prepartion. Once the .env file exists we won't overwrite it here again. You can open the .env file in this folder (maybe refresh your IDE) and check if everything worked as expected",
   "id": "f4e3ed80abdad23a"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "",
   "id": "d32b5abd00600e64"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
