Compare commits

..

3 Commits

Author SHA1 Message Date
0b4744bc0d Set NWC URI in data-nwc 2024-10-28 00:12:17 +01:00
303dca42a0 Update .env.sample 2024-10-27 23:50:27 +01:00
e7fe183cd5 users, sessions and wallets w/o authentication
* if a request has no session cookie, a new user, session and wallet is created and session cookie is set
* if a request has a session cookie and session exists in db, we will fetch user and wallet from db
* this means that we have a user and wallet during each render without any login required
2024-10-27 23:45:41 +01:00
17 changed files with 45 additions and 58 deletions

View File

@ -1,6 +1,6 @@
PORT=4321 PORT=4321
DATABASE_URL=postgres://magicwallet:magicwallet@localhost:5432/magicwallet?sslmode=disable DATABASE_URL=postgres://hermes:hermes@localhost:5432/hermes?sslmode=disable
LND_ADDRESS=localhost:10001 LND_HOST=localhost:10001
LND_CERT= LND_CERT=
LND_MACAROON= LND_MACAROON=
LND_NETWORK=regtest LND_NETWORK=regtest

2
.gitignore vendored
View File

@ -1,5 +1,5 @@
# go executable # go executable
magicwallet hermes
# environment # environment
.env .env

View File

@ -3,11 +3,11 @@
SOURCE := $(shell find fonts lib pages server -type f) main.go SOURCE := $(shell find fonts lib pages server -type f) main.go
# build binary for deployment # build binary for deployment
build: magicwallet build: hermes
magicwallet: $(SOURCE) hermes: $(SOURCE)
tailwindcss -i public/css/base.css -o public/css/tailwind.css tailwindcss -i public/css/base.css -o public/css/tailwind.css
TEMPL_EXPERIMENT=rawgo templ generate -path pages TEMPL_EXPERIMENT=rawgo templ generate -path pages
go build -o magicwallet . go build -o hermes .
# run code for development (no watch mode yet) # run code for development (no watch mode yet)
run: run:

View File

@ -1,28 +1,15 @@
# hermes
``` ```
.__ .__
_____ _____ ____ |__| ____ | |__ ___________ _____ ____ ______
/ \\__ \ / ___\| |/ ___\ | | \_/ __ \_ __ \/ \_/ __ \ / ___/
| Y Y \/ __ \_/ /_/ > \ \___ | Y \ ___/| | \/ Y Y \ ___/ \___ \
|__|_| (____ /\___ /|__|\___ > |___| /\___ >__| |__|_| /\___ >____ >
\/ \//_____/..wallet..\/ \/ \/....wallet....\/ \/ \/
``` ```
> _the wallet that will make your sats disappear_ > _Not the wallet you need, but the wallet you deserve._
**Features**
- magic sats: you never know if they are real
- does not care about your privacy
- lessons about exit scams, shotgun KYC and other fun stuff
- any balance above $100 is a donation
- Wild West experience with no support
**Bugs**
- can be self-hosted
- supports NWC send and receive
- withdrawals are sometimes possible
- might actually be useful
**Development** **Development**

View File

@ -1,20 +1,20 @@
services: services:
db: db:
image: postgres:14 image: postgres:14
container_name: magicwallet-db container_name: hermes-db
environment: environment:
POSTGRES_PASSWORD: magicwallet POSTGRES_PASSWORD: hermes
POSTGRES_USER: magicwallet POSTGRES_USER: hermes
POSTGRES_DB: magicwallet POSTGRES_DB: hermes
PORT: 5432 PORT: 5432
# POSTGRES_HOST_AUTH_METHOD: trust # POSTGRES_HOST_AUTH_METHOD: trust
ports: ports:
- 127.0.0.1:5432:5432 - 127.0.0.1:5432:5432
volumes: volumes:
- magicwallet:/var/lib/postgresql/data - hermes:/var/lib/postgresql/data
- ./db/postgresql.conf:/etc/postgresql.conf - ./db/postgresql.conf:/etc/postgresql.conf
- ./db/schema.sql:/docker-entrypoint-initdb.d/schema.sql - ./db/schema.sql:/docker-entrypoint-initdb.d/schema.sql
command: postgres -c config_file=/etc/postgresql.conf command: postgres -c config_file=/etc/postgresql.conf
volumes: volumes:
magicwallet: hermes:

2
go.mod
View File

@ -1,4 +1,4 @@
module github.com/ekzyis/magicwallet module github.com/ekzyis/hermes
go 1.22.0 go 1.22.0

View File

@ -2,7 +2,7 @@
# TODO: enumerate directories with shell # TODO: enumerate directories with shell
WATCH="db/ env/ fonts/ lib/ lightning/ pages/ public/ server/" WATCH="db/ env/ fonts/ lib/ lightning/ pages/ public/ server/"
BINARY=magicwallet BINARY=hermes
PID= PID=
set -e set -e

10
main.go
View File

@ -6,10 +6,10 @@ import (
"log" "log"
"net/http" "net/http"
"github.com/ekzyis/magicwallet/db" "github.com/ekzyis/hermes/db"
"github.com/ekzyis/magicwallet/env" "github.com/ekzyis/hermes/env"
"github.com/ekzyis/magicwallet/lightning" "github.com/ekzyis/hermes/lightning"
"github.com/ekzyis/magicwallet/server" "github.com/ekzyis/hermes/server"
"github.com/lightninglabs/lndclient" "github.com/lightninglabs/lndclient"
"github.com/namsral/flag" "github.com/namsral/flag"
) )
@ -40,7 +40,7 @@ func main() {
log.Fatal(err) log.Fatal(err)
} }
flag.StringVar(&dbUrl, "DATABASE_URL", "", "Database connection") flag.StringVar(&dbUrl, "DATABASE_URL", "", "Database connection")
flag.StringVar(&lndAddress, "LND_ADDRESS", "localhost:10001", "LND gRPC server address") flag.StringVar(&lndAddress, "LND_HOST", "localhost:10001", "LND gRPC server address")
flag.StringVar(&lndCert, "LND_CERT", "", "LND TLS certificate in hex") flag.StringVar(&lndCert, "LND_CERT", "", "LND TLS certificate in hex")
flag.StringVar(&lndMacaroon, "LND_MACAROON", "", "LND macaroon in hex") flag.StringVar(&lndMacaroon, "LND_MACAROON", "", "LND macaroon in hex")
flag.StringVar(&lndNetwork, "LND_NETWORK", "regtest", "LND network") flag.StringVar(&lndNetwork, "LND_NETWORK", "regtest", "LND network")

View File

@ -7,7 +7,7 @@ import (
"net/url" "net/url"
"strings" "strings"
"github.com/ekzyis/magicwallet/nostr" "github.com/ekzyis/hermes/nostr"
) )
type NwcConnection struct { type NwcConnection struct {

View File

@ -2,7 +2,7 @@ package components
templ Head() { templ Head() {
<head> <head>
<title>magicwallet</title> <title>hermes</title>
<!-- TODO: add favicon, manifest etc. --> <!-- TODO: add favicon, manifest etc. -->
<link rel="icon" type="image/x-icon" href="/favicon.ico"/> <link rel="icon" type="image/x-icon" href="/favicon.ico"/>
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"/> <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"/>

View File

@ -3,9 +3,9 @@ package pages
import ( import (
"fmt" "fmt"
"github.com/ekzyis/magicwallet/pages/components" "github.com/ekzyis/hermes/pages/components"
"github.com/ekzyis/magicwallet/db/models" "github.com/ekzyis/hermes/db/models"
"github.com/ekzyis/magicwallet/nostr/nwc" "github.com/ekzyis/hermes/nostr/nwc"
) )
templ Index() { templ Index() {

View File

@ -3,8 +3,8 @@ package context
import ( import (
"context" "context"
"github.com/ekzyis/magicwallet/db" "github.com/ekzyis/hermes/db"
"github.com/ekzyis/magicwallet/lightning" "github.com/ekzyis/hermes/lightning"
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
) )

View File

@ -3,7 +3,7 @@ package middleware
import ( import (
"net/http" "net/http"
"github.com/ekzyis/magicwallet/server/router/context" "github.com/ekzyis/hermes/server/router/context"
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
) )

View File

@ -3,7 +3,7 @@ package middleware
import ( import (
"net/http" "net/http"
"github.com/ekzyis/magicwallet/server/router" "github.com/ekzyis/hermes/server/router/context"
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
) )

View File

@ -7,9 +7,9 @@ import (
"time" "time"
"github.com/decred/dcrd/dcrec/secp256k1" "github.com/decred/dcrd/dcrec/secp256k1"
"github.com/ekzyis/magicwallet/db/models" "github.com/ekzyis/hermes/db/models"
"github.com/ekzyis/magicwallet/nostr/nwc" "github.com/ekzyis/hermes/nostr/nwc"
"github.com/ekzyis/magicwallet/server/router/context" "github.com/ekzyis/hermes/server/router/context"
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
) )

View File

@ -1,9 +1,9 @@
package router package router
import ( import (
"github.com/ekzyis/magicwallet/pages" "github.com/ekzyis/hermes/pages"
"github.com/ekzyis/magicwallet/server/router/context" "github.com/ekzyis/hermes/server/router/context"
"github.com/ekzyis/magicwallet/server/router/middleware" "github.com/ekzyis/hermes/server/router/middleware"
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
) )

View File

@ -1,8 +1,8 @@
package server package server
import ( import (
"github.com/ekzyis/magicwallet/server/router" "github.com/ekzyis/hermes/server/router"
"github.com/ekzyis/magicwallet/server/router/context" "github.com/ekzyis/hermes/server/router/context"
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware" "github.com/labstack/echo/v4/middleware"
) )