Skip to content

Lightning Tip Cards are a tip (or gift) card system, where you can fund tip cards via the lightning network and the gifted person can redeem the funded cards. The gifted person gets a short introduction to bitcoin and a lightning app recommendation to start their journey into the bitcoin rabbit hole.

License

Notifications You must be signed in to change notification settings

Satoshi-Engineering/tip-cards

Repository files navigation

⚡️ Lightning Tip Cards

by #sathoshiengineeringcrew

MIT License Badge

A tip card system based on LNbits and the lightning network

Lightning Tip Cards are a tip (or gift) card system, where you can fund tip cards via the lightning network and the gifted person can redeem the funded cards. The gifted person gets a short introduction to bitcoin and a lightning app recommendation to start their journey into the bitcoin rabbit hole.

It is an open-source project developed and operated for the benefit of the Bitcoin community, with a focus on "How to gentle orange pill nocoiners" - and without warranty of any kind.

LNbits is used for the wallet and lightning payments in the background.

Explanation Videos

#satohsiengineeringcrew is #happy2help

Host your own Tip Cars

Install guide

Setup for development

Prerequisites

Setup

npm install

If you are working at Satoshi Engineering, please configure your GIT repo to use the GIT hooks from the directory .githooks:

git config core.hooksPath .githooks

Backend

Setup

Custom Env File

Per default the backend loads the backend/.env file. If you need different setups locally (e.g. one for development and one for running integration tests) you can load a different one by adding a commandline argument. For running the backend you can use npm run backend-dev -- --envFilePostfix=somePostFix which would use the file backend/.env.somePostFix. You can also add the parameter to all other commands (cli, integration test, etc.).

Integration Test Script

You can run backend integration tests locally, including starting the local backend, in one command by running the helper script ./backend-integration-tests.sh. This command uses the backend/.env.integrationTest env file (see Custom EnvFile).

Alternately if you want to run specific tests you could do:

# create custom env file for testing + startup backend using it
vi backend/.env.integrationTest
npm run backend-dev -- --envFilePostfix=integrationTest

# run a specific test using the same env file
cd backend
../node_modules/jest/bin/jest.js --config jest.config.js --runInBand --testTimeout=50000 --envFilePostfix=integrationTest tests/integration/api/auth.test.ts

Frontend

  • Create a frontend/.env.development.local file (or copy it from frontend/.env.development) and add the following variable:

Testing

If you want to test the tipcards on your local machine, here are some hints

  • Fund your https://legend.lnbits.com/wallet with 1 - 100sats. The tipcard redeeming creates a lightning invoice via lnbits and there are transaction costs.
  • It won't work with your smartphone, because the development setup restricted to localhost. (And if you use vite --host to expose the port, your lightning apps will refuse to work because there is no ssl connection)
    • We use BlueWallet Deskop app for testing (it can access localhost)

Tools

VSCode

Recommended Extensions

Ngrok

Ngrok is used to expose you local environment to the web. This is needed to test auth/backend features with your phone (e.g. paying invoices, logging in via lnurl-auth).

  1. Copy backend/.env.example into backend/.env
  2. Go to https://ngrok.com and create an account
  3. Go to https://dashboard.ngrok.com/get-started/setup, copy your authtoken and add it to backend/.env

Now you have two possibilities:

Either use the dev-tip-cards.sh script:

  1. Run ./dev-tip-cards.sh and after it finishes copy the displayed ngrok url to your browser.

Or execute the following steps manually:

  1. Run npm run backend-proxy. This starts an express server that proxies all requests to your other services that we will start later.
  2. Run npm run backend-ngrok. Then copy the ngrok url that will be pasted in the console (something like https://cdb6-62-178-206-224.ngrok.io).
  3. Open backend/.env and set the ngrok url (from the previous point) for TIPCARDS_ORIGIN and TIPCARDS_API_ORIGIN as this is now your public URL for your phone and lnbits webhooks.
  4. Open frontend/.env.development.local and set VITE_BACKEND_API_ORIGIN= to an empty string. The API origin will be the same as the frontend origin (the ngrok URL).
  5. Run npm run backend-dev
  6. Run npm run frontend-dev

Please consider

As LNURL-auth tokens are based on the domain of the website where they are used, you will not be able to login with the same user after stopping and restarting the ngrok proxy.

Script

For additional developer tasks, scripts can be found in scripts.

Run from source

Start the frontend server on http://localhost:5173

npm run frontend-dev

Start the backend server on http://localhost:4000

npm run backend-dev

Production

Deployment is done via Gitlab CI/CD, see .gitlab-ci.yml

Tip us

If you like this project, please adapt the landingpage to your local stores, that accept bitcoin or even extend it. Why not send some tip love?

About

Lightning Tip Cards are a tip (or gift) card system, where you can fund tip cards via the lightning network and the gifted person can redeem the funded cards. The gifted person gets a short introduction to bitcoin and a lightning app recommendation to start their journey into the bitcoin rabbit hole.

Resources

License

Stars

Watchers

Forks

Packages