mirror of
https://github.com/aljazceru/nostrdvm.git
synced 2025-12-18 22:54:19 +01:00
162 lines
5.1 KiB
Plaintext
162 lines
5.1 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"metadata": {},
|
|
"cell_type": "markdown",
|
|
"source": "First we will load our .env file that we created in the last tutorial.",
|
|
"id": "de06960a2f8dae68"
|
|
},
|
|
{
|
|
"metadata": {
|
|
"ExecuteTime": {
|
|
"end_time": "2024-09-16T14:12:25.797327Z",
|
|
"start_time": "2024-09-16T14:12:25.792936Z"
|
|
}
|
|
},
|
|
"cell_type": "code",
|
|
"source": [
|
|
"import dotenv\n",
|
|
"from pathlib import Path\n",
|
|
"\n",
|
|
"env_path = Path('.env')\n",
|
|
"if not env_path.is_file():\n",
|
|
" with open('.env', 'w') as f:\n",
|
|
" print(\"Writing new .env file\")\n",
|
|
" f.write('')\n",
|
|
"if env_path.is_file():\n",
|
|
" print(f'loading environment from {env_path.resolve()}')\n",
|
|
" dotenv.load_dotenv(env_path, verbose=True, override=True)\n",
|
|
"else:\n",
|
|
" raise FileNotFoundError(f'.env file not found at {env_path} ')"
|
|
],
|
|
"id": "7a3909a4945f62c3",
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"loading environment from /Users/tobias/Documents/dvm/tutorials/.env\n"
|
|
]
|
|
}
|
|
],
|
|
"execution_count": 6
|
|
},
|
|
{
|
|
"metadata": {},
|
|
"cell_type": "markdown",
|
|
"source": [
|
|
"Ok, lets start with the very basics. We create the configuration for own DVM. The configuration contains infos like the lightning address, the private keys and some parameters that might come in handy for each DVM.\n",
|
|
"\n",
|
|
"In order to create a new Config, including everything we need to start, like a nostr private key, a lnbits wallet, and a lightning address, all we need to do is set an identifier and call the build_default_config function.\n",
|
|
"\n",
|
|
"Note: For the sake of this tutorial our identifier is tutorial01_ + some random word, to make sure ln addresses will not be overwritten. You can also pick an identifier of your choice (if its not taken on the nostdress server)."
|
|
],
|
|
"id": "75ae876bf5da9d35"
|
|
},
|
|
{
|
|
"metadata": {
|
|
"ExecuteTime": {
|
|
"end_time": "2024-09-16T14:12:27.820688Z",
|
|
"start_time": "2024-09-16T14:12:27.817674Z"
|
|
}
|
|
},
|
|
"cell_type": "code",
|
|
"source": [
|
|
"from nostr_dvm.utils.dvmconfig import build_default_config\n",
|
|
"from helper import randomword\n",
|
|
"identifier = \"tutorial01_\" + randomword(10)\n",
|
|
"print(identifier)"
|
|
],
|
|
"id": "5f5cfdf34488074a",
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"tutorial01_knicqxeqwq\n"
|
|
]
|
|
}
|
|
],
|
|
"execution_count": 7
|
|
},
|
|
{
|
|
"metadata": {},
|
|
"cell_type": "markdown",
|
|
"source": [
|
|
"Ok, now something important. I need you to do a manual step. Put what is printed above (tutorial01_somerandomword) in the next line down there:\n",
|
|
"\n",
|
|
"This way we make sure we don't create multiple configs for the same dvm. We just want to give it one fixed name and that's the one we created above. Or you can still pick your own one, if its unique.\n",
|
|
"\n",
|
|
"identifier = tutorial01_... "
|
|
],
|
|
"id": "e0f9f41907628fd7"
|
|
},
|
|
{
|
|
"metadata": {
|
|
"ExecuteTime": {
|
|
"end_time": "2024-09-16T14:12:34.572391Z",
|
|
"start_time": "2024-09-16T14:12:34.047756Z"
|
|
}
|
|
},
|
|
"cell_type": "code",
|
|
"source": [
|
|
"identifier = \"tutorial01_xxxxxxxx\"\n",
|
|
"\n",
|
|
"dvm_config = build_default_config(identifier)"
|
|
],
|
|
"id": "d9ef15853d433c66",
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"loading environment from /Users/tobias/Documents/dvm/tutorials/.env\n",
|
|
"https://demo.lnbits.com/usermanager/api/v1/users\n",
|
|
"{'id': 'b719b9d29e9d49a7a05d7eebfa4b6ebb', 'name': 'tutorial01_knicqxeqwq', 'admin': '43a50a6074f6427385b49460cf60c6a1', 'email': '', 'password': '', 'extra': None, 'wallets': [{'id': '8743fff6b78e429894062bca8ab076f2', 'admin': '43a50a6074f6427385b49460cf60c6a1', 'name': 'tutorial01_knicqxeqwq', 'user': 'b719b9d29e9d49a7a05d7eebfa4b6ebb', 'adminkey': '846aa1465c4641729a275e4988a8a458', 'inkey': '65851d26d8254836ae1a06e954a5311f'}]}\n",
|
|
"nostrdvm.com\n",
|
|
"65851d26d8254836ae1a06e954a5311f\n",
|
|
"{\"ok\":true,\"pin\":\"f0247b53c856e1a4d879e13c8daf88e16da32740fd23cf24e3ded8c0b6e7745b\"}\n",
|
|
"\n"
|
|
]
|
|
}
|
|
],
|
|
"execution_count": 8
|
|
},
|
|
{
|
|
"metadata": {},
|
|
"cell_type": "markdown",
|
|
"source": "If everything worked, your .env file should now be updated with the information. If you run this code box again, the dvm will know it already is configured. That's why we set the name manually. We don't want a random name each time we call it, but the identifier stays with the DVM.",
|
|
"id": "536ad95eaa6e628f"
|
|
},
|
|
{
|
|
"metadata": {},
|
|
"cell_type": "code",
|
|
"outputs": [],
|
|
"execution_count": null,
|
|
"source": "",
|
|
"id": "ea6243e7373d4b70"
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 2
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython2",
|
|
"version": "2.7.6"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|