Skip to content

Commit

Permalink
improve: add flakebox
Browse files Browse the repository at this point in the history
  • Loading branch information
yato-sketch committed Oct 22, 2023
1 parent 102a76e commit 91cad6e
Show file tree
Hide file tree
Showing 23 changed files with 714 additions and 90 deletions.
1 change: 1 addition & 0 deletions .config/flakebox/id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6ed8d7bac0d49950f28394f623607c29d00896bcf1505d366717626babadd81f8f111f93afd1b991b7087d5ce0684b4bcc10124aad93b3876ba1aba600a09cb4
32 changes: 32 additions & 0 deletions .config/flakebox/shellHook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
root="$(git rev-parse --show-toplevel)"
dot_git="$(git rev-parse --git-common-dir)"
if [[ ! -d "${dot_git}/hooks" ]]; then mkdir -p "${dot_git}/hooks"; fi
# fix old bug
rm -f "${dot_git}/hooks/comit-msg"
rm -f "${dot_git}/hooks/commit-msg"
ln -sf "${root}/misc/git-hooks/commit-msg" "${dot_git}/hooks/commit-msg"

root="$(git rev-parse --show-toplevel)"
dot_git="$(git rev-parse --git-common-dir)"
if [[ ! -d "${dot_git}/hooks" ]]; then mkdir -p "${dot_git}/hooks"; fi
# fix old bug
rm -f "${dot_git}/hooks/pre-comit"
rm -f "${dot_git}/hooks/pre-commit"
ln -sf "${root}/misc/git-hooks/pre-commit" "${dot_git}/hooks/pre-commit"

# set template
git config commit.template misc/git-hooks/commit-template.txt

if ! flakebox lint --silent; then
>&2 echo "ℹ️ Project recommendations detected. Run 'flakebox lint' for more info."
fi

if [ -n "${DIRENV_IN_ENVRC:-}" ]; then
# and not set DIRENV_LOG_FORMAT
if [ -n "${DIRENV_LOG_FORMAT:-}" ]; then
>&2 echo "💡 Set 'DIRENV_LOG_FORMAT=\"\"' in your shell environment variables for a cleaner output of direnv"
fi
fi

>&2 echo "💡 Run 'just' for a list of available 'just ...' helper recipes"
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
78 changes: 78 additions & 0 deletions .github/workflows/flakebox-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# THIS FILE IS AUTOGENERATED FROM FLAKEBOX CONFIGURATION

jobs:
build:
name: Build
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v4
- name: Magic Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v2
- name: Build on ${{ matrix.host }}
run: 'nix flake check -L .#
'
strategy:
matrix:
host:
- macos
- linux
include:
- host: linux
runs-on: ubuntu-latest
timeout: 60
- host: macos
runs-on: macos-12
timeout: 60
timeout-minutes: ${{ matrix.timeout }}
flake:
name: Flake self-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check Nix flake inputs
uses: DeterminateSystems/flake-checker-action@v5
with:
fail-mode: true
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v4
- name: Magic Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v2
- name: Cargo Cache
uses: actions/cache@v3
with:
key: ${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
path: ~/.cargo
- name: Commit Check
run: '# run the same check that git `pre-commit` hook does
nix develop --ignore-environment .#lint --command ./misc/git-hooks/pre-commit
'
name: CI
'on':
merge_group:
branches:
- master
- main
pull_request:
branches:
- master
- main
push:
branches:
- master
- main
tags:
- v*
workflow_dispatch: {}


# THIS FILE IS AUTOGENERATED FROM FLAKEBOX CONFIGURATION
35 changes: 35 additions & 0 deletions .github/workflows/flakebox-flakehub-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# THIS FILE IS AUTOGENERATED FROM FLAKEBOX CONFIGURATION

jobs:
flakehub-publish:
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ (inputs.tag != null) && format('refs/tags/{0}', inputs.tag) || ''
}}
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v4
- name: Flakehub Push
uses: DeterminateSystems/flakehub-push@main
with:
name: ${{ github.repository }}
tag: ${{ inputs.tag }}
visibility: public
name: Publish to Flakehub
'on':
push:
tags:
- v?[0-9]+.[0-9]+.[0-9]+*
workflow_dispatch:
inputs:
tags:
description: The existing tag to publish to FlakeHub
required: true
type: string


# THIS FILE IS AUTOGENERATED FROM FLAKEBOX CONFIGURATION
Empty file modified .github/workflows/lint.yml
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ config.toml
TODO.md

*.redb
pay_index
pay_index
4 changes: 4 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
group_imports = "StdExternalCrate"
wrap_comments = true
format_code_in_doc_comments = true
imports_granularity = "Module"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Sats paid to this address are minted as cashu tokens of the users preferred mint
# Zaps
To enable [zap](https://github.com/nostr-protocol/nips/blob/master/57.md) notes to be published some extra configuration is needed as well as a CLN node. This is because a valid zap request requires the invoice description to be a zap_request. In order to provide best privacy mints do not allow descriptions to be set.

When zaps are enabled (proxy = true) this service uses the configured CLN rpc to create an invoice, that is returned to the when a request is made to the lighting address. Once this invoice is paid this service then requests a mint, mints a cashu token and sends a nostr direct message to the preconfigured pubkey. This could be improved in two ways, the first being make this a true wrapped invoice so the service cannot take funds they must pay the mint invoice, the second is use P2SH to lock the cashu token to only be readable by the nostr key it is being sent to. This reduced the trust in the service, though of course there is no way to know if the service is doing this for every invoice request, so there will always be some trust involved, though more temporary then a custodial wallet, as once the token is redeamed by the user there is no way for the service to claim it back or know what happens to it next.
When zaps are enabled (proxy = true) this service uses the configured CLN rpc to create an invoice, that is returned to the when a request is made to the lighting address. Once this invoice is paid this service then requests a mint, mints a cashu token and sends a nostr direct message to the preconfigured pubkey. This could be improved in two ways, the first being make this a true wrapped invoice so the service cannot take funds they must pay the mint invoice, the second is use P2SH to lock the cashu token to only be readable by the nostr key it is being sent to. This reduced the trust in the service, though of course there is no way to know if the service is doing this for every invoice request, so there will always be some trust involved, though more temporary then a custodial wallet, as once the token is redeamed by the user there is no way for the service to claim it back or know what happens to it next.
2 changes: 1 addition & 1 deletion example.config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ db_path = "/home/thesimplekid/Documents/Development/cashu-lnurl"
address = "127.0.0.1"

# Listen on this port
port = 8080
port = 8080
Loading

0 comments on commit 91cad6e

Please sign in to comment.