Commit Graph

51 Commits

Author SHA1 Message Date
Keyan 4675a2c29d
sndev cleanup (#1563)
* begin sndev cleanup

* cleanup sndev

* fix posix shell compliance

* add tests to sndev
2024-11-09 15:52:04 -06:00
Keyan d117549348
fix lightning module resolution (#1551)
* fix tsx usage

* Revert "Revert "Merge pull request #1521 from riccardobl/tordev""

This reverts commit 4cc3780eca.

* lightning module resolution

* fix our one test
2024-11-07 09:03:54 -06:00
k00b 4cc3780eca Revert "Merge pull request #1521 from riccardobl/tordev"
This reverts commit 3112fc30d8, reversing
changes made to 803daed2df.
2024-11-05 20:08:33 -06:00
Riccardo Balbo c708c5bf6f fix lnd paths 2024-11-04 10:13:22 +01:00
Riccardo Balbo 4fb873b105 enable tor for cln and lnbits 2024-10-26 11:36:06 +02:00
Riccardo Balbo 5a09c48e04 tor for the dev environment 2024-10-26 01:53:08 +02:00
ekzyis 75051f1c56 LNbits updates for local dev
* persistent lnbits db with lnbits superuser
* map localhost:5001 -> lnbits:5000 in local dev for LNbits receives
* updated ATTACH.md
2024-10-17 20:54:07 +02:00
k00b 177e0f6bb0 fix #1453 2024-10-05 13:57:55 -05:00
ekzyis 5d1be66eef
Add nwc_recv container (#1442) 2024-10-01 09:14:29 -05:00
ekzyis ae8cadd4be
Switch NWC from Damus to Primal relay (#1340) 2024-08-28 09:32:29 -05:00
Keyan cc289089cf
not-custodial zap beta (#1178)
* not-custodial zap scaffolding

* invoice forward state machine

* small refinements to state machine

* make wrap invoice work

* get state machine working end to end

* untested logic layout for paidAction invoice wraps

* perform pessimisitic actions before outgoing payment

* working end to end

* remove unneeded params from wallets/server/createInvoice

* fix cltv relative/absolute confusion + cancelling forwards

* small refinements

* add p2p wrap info to paidAction docs

* fallback to SN invoice when wrap fails

* fix paidAction retry description

* consistent naming scheme for state machine

* refinements

* have sn pay bounded outbound fee

* remove debug logging

* reenable lnc permissions checks

* don't p2p zap on item forward splits

* make createInvoice params json encodeable

* direct -> p2p badge on notifications

* allow no tls in dev for core lightning

* fix autowithdraw to create invoice with msats

* fix autowithdraw msats/sats inconsitency

* label p2p zaps properly in satistics

* add fees to autowithdrawal notifications

* add RETRYING as terminal paid action state

* Update api/paidAction/README.md

Co-authored-by: ekzyis <ek@stacker.news>

* Update api/paidAction/README.md

Co-authored-by: ekzyis <ek@stacker.news>

* Update api/lnd/index.js

Co-authored-by: ekzyis <ek@stacker.news>

* ek suggestions

* add bugetable to nwc card

* get paranoid with numbers

* better finalize retries and better max timeout height

* refine forward failure transitions

* more accurate satistics p2p status

* make sure paidaction cancel in state machine only

* dont drop bolt11s unless status is not null

* only allow PENDING_HELD to transition to FORWARDING

* add mermaid state machine diagrams to paid action doc

* fix cancel transition name

* cleanup readme

* move forwarding outside of transition

* refine testServerConnect and make sure ensureB64 transforms

* remove unused params from testServerConnect

---------

Co-authored-by: ekzyis <ek@stacker.news>
Co-authored-by: k00b <k00b@stacker.news>
2024-08-13 09:48:30 -05:00
ekzyis ae73b0c19f
Support receiving via LNbits (#1278)
* Support receiving with LNbits

* Remove hardcoded LNbits url on server

* Fix saveConfig ignoring save errors

* saveConfig was meant to only ignore validation errors, not save errors
* on server save errors, we redirected as if save was successful
* this is now fixed with a promise chain
* logging payments vs receivals was also moved to correct place

* Fix enabled falsely disabled on SSR

If a wallet was configured for payments but not for receivals and you refreshed the configuration form, enabled was disabled even though payments were enabled.

This was the case since we don't know during SSR if it's enabled since this information is stored on the client.

* Fix missing 'receivals disabled' log message

* Move 'wallet detached for payments' log message

* Fix stale walletId during detach

If page was reloaded, walletId in clearConfig was stale since callback dependency was missing.

* Add missing callback dependencies for saveConfig

* Verify that invoiceKey != adminKey

* Verify LNbits keys are hex-encoded

* Fix local config polluted with server data

* Fix creation of duplicate wallets

* Remove unused dependency

* Fix missing error message in logs

* Fix setPriority

* Rename: localConfig -> clientConfig

* Add description to LNbits autowithdrawals

* Rename: receivals -> receives

* Use try/catch instead of promise chain in saveConfig

* add connect label to lnbits for no url found for lnbits

* Fix adminKey not saved

* Remove hardcoded LNbits url on server again

* Add LNbits ATTACH.md

* Delete old docs to attach LNbits with polar

* Add missing callback dependencies

* Set editable: false

* Only set readOnly if field is configured

---------

Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2024-08-12 17:23:39 -05:00
Anis Khalfallah ed6ef2f82f
fix: constrain less important services in docker compose (#1289)
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2024-08-11 16:29:46 -05:00
Keyan 8000886e72
dont expect unrun services in dev (#1279) 2024-07-31 19:44:08 -05:00
keyan f05b6fab84 add wallets profile to allow exclusion on attached wallet containers 2024-07-09 11:37:55 -05:00
Keyan 79f0df17b2
improve pessimistic paid actions by letting the server perform actions and settle invoice on `HELD` (#1253)
* get rid of hash and hmac based pessimism

* fix readme
2024-07-04 12:30:42 -05:00
ekzyis ddaec36617
Fix litd healthcheck (#1246) 2024-06-24 20:28:42 -05:00
ekzyis 93713b33df
Optimistic updates via pending sats in item context (#1229)
* Use context for pending sats

* Fix sats going negative on zap undo

We already handle undoing pending sats by wrapping the payment+mutation with try/finally.

* Remove unnecessary ItemContextProvider

* Rename to parentCtx

* Fix hierarchy of ItemContextProvider

If a comment was root and it was zapped, the pending sats contributed to the sats shown in <CommentsHeader>.

This was caused by <CommentsHeader> accessing the root item context for all comments, even for the root comment.

So even if the root comment was zapped, the pending sats contributed to the sats for the comment section.

This wasn't the case for posts since their item context was above the context used by <CommentsHeader>.

This was fixed by moving <ItemProviderContext> down into <Comments> and <Item> instead of declaring it at <ItemFull> which wraps the root item and all comments.

* Optimistic update for poll votes

* prevent twice optimistic zap

* enhance client notifications with skeleton and no redudant queries

* enlarge nwc amount limits

* Disable max amount and daily limit in NWC container

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
2024-06-12 08:34:24 -05:00
ekzyis c6ab776091
Add nostr-wallet-connect-lnd container (#1174)
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
2024-05-15 10:10:24 -05:00
ekzyis 47bfa24b57
Add lnbits container (#1173) 2024-05-15 10:09:15 -05:00
ekzyis 7090ea3b70
Fix stacker_cln missing in channdler dependency (#1172) 2024-05-14 16:59:05 -05:00
keyan 46efb770fb actually fix worker in local dev 2024-05-08 16:25:01 -05:00
keyan 32f0b1722f fix local dev worker env loading 2024-05-08 15:15:51 -05:00
SatsAllDay 15f9950477
Store hashed and salted email addresses (#1111)
* first pass of hashing user emails

* use salt

* add a salt to .env.development (prod salt needs to be kept a secret)
* move `hashEmail` util to a new util module

* trigger a one-time job to migrate existing emails via the worker

so we can use the salt from an env var

* move newsletter signup

move newsletter signup to prisma adapter create user with email code path
so we can still auto-enroll email accounts without having to persist the email address
in plaintext

* remove `email` from api key session lookup query

* drop user email index before dropping column

* restore email column, just null values instead

* fix function name

* fix salt and hash raw sql statement

* update auth methods email type in typedefs from str to bool

* remove todo comment

* lowercase email before hashing during migration

* check for emailHash and email to accommodate migration window

update our lookups to check for a matching emailHash, and then a matching
email, in that order, to accommodate the case that a user tries to login
via email while the migration is running, and their account has not yet been migrated

also update sndev to have a command `./sndev email` to launch the mailhog inbox in your browser

also update `./sndev login` to hash the generated email address and insert it into the db record

* update sndev help

* update awards.csv

* update the hack in next-auth to re-use the email supplied on input to `getUserByEmail`

* consolidate console.error logs

* create generic open command

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
2024-05-04 18:06:15 -05:00
ekzyis 10e58d41c7
Remove .env.local from env_file (#1113)
Arrays for env_file are only supported in Docker Compose >=v2.24 which is too new (from January 2024). Most distros distribute older packages.

Since --env-file as defined in the sndev script acts as an override for env_file anyway, we can safely remove it here.

Co-authored-by: ekzyis <ekzyis@ekzy.is>
2024-04-27 18:25:37 -05:00
Keyan c3d709b025
add lnc attached wallet (#1104)
* add litd to docker env

* lnc payments

* handle locked wallet configuration

* create new lnc connection for every action

* ensure creds are decrypted before reconnecting

* perform permissions check
2024-04-26 21:22:30 -05:00
ekzyis dd6e921e2e
Fix local env in docker-compose.yaml (#1085)
* Allow docker env override via .env.local

* Make .env.local optional

* Fix env var expansion ignoring .env.local

* Rename .env.development to .env.docker

* Use YAML anchors

* Revert rename of .env.development
2024-04-17 13:46:18 -05:00
keyan 51f1c08a7e get rid of docker compose version number deprecation warning 2024-04-14 17:40:52 -05:00
ekzyis 9f4d5e13aa
CLN autowithdrawal (#1042)
* Add CLN node to docker-compose.yml

* Attach CLN wallet via CLNRest

* Remove leading space

* Implement autowithdrawal to CLN in worker

* Fix UnhandledSchemeError during build

See https://github.com/vercel/next.js/discussions/33982

* Refactor CLN invoice code into @/lib/cln

* Fix missing env vars

* Fix validation error if rune invalid

* Update header

* Add rune placeholder

* Fix missing expiry for test invoice

* Remove nonsensical comment

* Remove unnecessary async

* Show level SUCCESS as OK in logs

* Add stacker_cln commands to sndev

* fix sndev posix compliance, add cln_withdraw

* give stacker_cln larger channels

---------

Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
2024-04-14 17:34:21 -05:00
Anis Khalfallah 0c0f303a11
Add capture's container from /capture (#1001)
* Modified docker-compose.yml to include capture from /capture

Signed-off-by: Anis Khalfallah <khafallah.anis@hotmail.com>

* Update capture's container to include health checks via /health api

* refine capure docker service

---------

Signed-off-by: Anis Khalfallah <khafallah.anis@hotmail.com>
Co-authored-by: Anis Khalfallah <khafallah.anis@hotmail.com>
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
2024-04-03 14:28:51 -05:00
Keyan 2055ccaf41
Merge branch 'master' into mailhog 2024-03-25 17:46:56 -05:00
ekzyis f4a7819bb3 Keep standard ports inside container
This makes it possible to continue to use lncli without --rpcserver inside the docker container even if the GRPC port exposed on the host machine is different.

This is the case on my machine since I am running a mainnet LND node on my machine so port 10009 is already used.

I could change the port to 20009 via LND_GRPC_PORT and STACKER_LND_GRPC_PORT (they can even have the same port) but then lncli inside the container needs to be aware of that which means that the sndev script would need to parse .env.development (or some other "magic") to know the GRPC port inside the container.

However, I decided that using standard ports inside the container is better to keep the sndev script simple at the cost of having to think about host vs container ports since they are different now.

One reason for that is that I think one even does not need to think about the host ports since they aren't even needed? But that's another topic.
2024-03-25 19:02:32 +01:00
Felipe Bueno e919efc144 MailHog healthcheck with wget instead of curl 2024-03-25 09:26:45 -03:00
keyan 2502c176f1 improve sndev db healthcheck 2024-03-24 13:59:23 -05:00
Felipe Bueno 561e62481d Add 'profiles: email' to the MailHog container 2024-03-21 09:16:29 -03:00
Felipe Bueno 82dc9b076d Add MailHog container to provide login with email without extra config 2024-03-20 18:41:25 -03:00
keyan 08f1db3f68 sndev profiles 2024-03-17 20:43:34 -05:00
keyan 806f42ed40 don't use imgproxy pro, set opensearch user/pass 2024-03-15 21:16:26 -05:00
Keyan efaa2193e0
new readme with contribution awards (#922)
* new readme

* Update README.md

* Update README.md

* move more docs to README

* add proper mapping for opensearch item index

* add sndev lint

* fix index creation
2024-03-15 14:29:42 -05:00
Keyan 23ee62fb21
add sndev shell script and enhance docker compose local dev
* add hot reloading worker:dev script

* refine docker config

* sndev bash script and docker reliability stuff

* make posix shell

* restart: always -> unless-stopped

* proper check for postgres health

* add db seed to sndev

* refinements after fresh builds

* begin adding regtest network

* add changes to .env.sample

* reorganize docker and add static certs/macroon to lnd

* copy wallet and macaroon dbs for deterministic wallets/macaroons

* fix perms of shared directories

* allow debian useradd with duplicate id

* add auto-mining

* make bitcoin health check dependent on blockheight

* open channel between ln nodes

* improve channel opens

* add sndev payinvoice

* add sndev withdraw

* ascii art

* add sndev status

* sndev passthrough to docker and containers

* add sndev psql command

* remove script logging

* small script cleanup

* smaller db seed

* pin opensearch version

Co-authored-by: ekzyis <ek@stacker.news>

* pin opensearch dashboard

Co-authored-by: ekzyis <ek@stacker.news>

* add sndev prisma

* add help for all commands

* set -e

* s3 and image proxy with broken name resolution

* finally fully working image uploads

* use a better diff algo

---------

Co-authored-by: ekzyis <ek@stacker.news>
2024-03-13 09:04:09 -05:00
ekzyis bfcca7d34e
Use docker container with ip4r installed (#698)
* Use docker container with ip4r installed

* Credit source

---------

Co-authored-by: ekzyis <ek@stacker.news>
2023-12-19 09:52:09 -06:00
keyan 51299820b9 fix module issues when running worker 2023-09-26 20:33:54 -05:00
rleed 2a7267a35a
Add OpenSearch to docker setup for development (#509)
* add containers for OpenSearch

* switch OpenSearch Dashboards to http

* add script to take care of index/mapping on first run

* limit mount in opensearch container to only the necessary scope

* handle both docker and non-docker dev setups

* cleanup

* make opensearch work in docker dev

---------

Co-authored-by: rleed <rleed1@pm.me>
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
2023-09-24 18:24:04 -05:00
Jo Wo bf4b8714fe
Render images without markdown and use image proxy (#245)
* Parse image links during markdown rendering

* Use imgproxy to replace links

* Add healthcheck

See https://docs.imgproxy.net/healthcheck

* Enable WebP and animation support

* Only replace image URLs

* Replace all occurrences

* Fix creating posts with no text

* Embed image on link posts where link is image

---------

Co-authored-by: ekzyis <ek@stacker.news>
2023-07-12 19:10:01 -05:00
ekzyis 422b2ce8b6
Use postgres:13.2 (#348)
Co-authored-by: ekzyis <ek@stacker.news>
2023-07-07 08:44:23 -05:00
ekzyis 3738f08ac2
Use docker volume for db data (#315)
Co-authored-by: ekzyis <ek@stacker.news>
2023-06-12 20:22:10 -05:00
keyan 1a271432c7 replace docker wait-for-it with long form of depends on 2023-04-26 13:02:42 -05:00
mvpratt 70551706d7 dont run npm install twice on `docker compose up` 2023-04-26 13:02:42 -05:00
austinkelsay d2f76a0c43 Created new image for worker, running work script on startup 2022-10-06 15:33:18 -05:00
keyan 68ddd0f86b sort by top posts 2021-10-21 17:05:06 -05:00