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
DATABASE_URL=postgres://magicwallet:magicwallet@localhost:5432/magicwallet?sslmode=disable
LND_ADDRESS=localhost:10001
DATABASE_URL=postgres://hermes:hermes@localhost:5432/hermes?sslmode=disable
LND_HOST=localhost:10001
LND_CERT=
LND_MACAROON=
LND_NETWORK=regtest

2
.gitignore vendored
View File

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

View File

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

View File

@ -1,28 +1,15 @@
# hermes
```
.__
_____ _____ ____ |__| ____
/ \\__ \ / ___\| |/ ___\
| Y Y \/ __ \_/ /_/ > \ \___
|__|_| (____ /\___ /|__|\___ >
\/ \//_____/..wallet..\/
.__
| |__ ___________ _____ ____ ______
| | \_/ __ \_ __ \/ \_/ __ \ / ___/
| Y \ ___/| | \/ Y Y \ ___/ \___ \
|___| /\___ >__| |__|_| /\___ >____ >
\/ \/....wallet....\/ \/ \/
```
> _the wallet that will make your sats disappear_
**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
> _Not the wallet you need, but the wallet you deserve._
**Development**

View File

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

View File

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

10
main.go
View File

@ -6,10 +6,10 @@ import (
"log"
"net/http"
"github.com/ekzyis/magicwallet/db"
"github.com/ekzyis/magicwallet/env"
"github.com/ekzyis/magicwallet/lightning"
"github.com/ekzyis/magicwallet/server"
"github.com/ekzyis/hermes/db"
"github.com/ekzyis/hermes/env"
"github.com/ekzyis/hermes/lightning"
"github.com/ekzyis/hermes/server"
"github.com/lightninglabs/lndclient"
"github.com/namsral/flag"
)
@ -40,7 +40,7 @@ func main() {
log.Fatal(err)
}
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(&lndMacaroon, "LND_MACAROON", "", "LND macaroon in hex")
flag.StringVar(&lndNetwork, "LND_NETWORK", "regtest", "LND network")

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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