Skip to content

Commit

Permalink
Merge branch 'main' into mint-fix-fee-reserve-msat
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc authored Mar 12, 2024
2 parents 12e16f4 + 150195d commit 2c586fb
Show file tree
Hide file tree
Showing 55 changed files with 3,083 additions and 876 deletions.
30 changes: 24 additions & 6 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ NOSTR_RELAYS=["wss://nostr-pub.wellorder.net"]
# Wallet API port
API_PORT=4448

# Wallet default unit
WALLET_UNIT="sat"

# --------- MINT ---------

# Network
Expand All @@ -38,29 +41,44 @@ MINT_INFO_CONTACT=[["email","[email protected]"],["twitter","@me"],["nostr","npub..
MINT_INFO_MOTD="Message to users"

MINT_PRIVATE_KEY=supersecretprivatekey
# increment derivation path to rotate to a new keyset
MINT_DERIVATION_PATH="0/0/0/0"

# Increment derivation path to rotate to a new keyset
# Example: m/0'/0'/0' -> m/0'/0'/1'
MINT_DERIVATION_PATH="m/0'/0'/0'"

# Multiple derivation paths and units. Unit is parsed from the derivation path.
# m/0'/0'/0' is "sat" (default)
# m/0'/1'/0' is "msat"
# m/0'/2'/0' is "usd"
# In this example, we have 2 keysets for sat, 1 for msat and 1 for usd
# MINT_DERIVATION_PATH_LIST=["m/0'/0'/0'", "m/0'/0'/1'", "m/0'/1'/0'", "m/0'/2'/0'"]

MINT_DATABASE=data/mint

# Lightning
# Supported: LndRestWallet, LNbitsWallet, FakeWallet
MINT_LIGHTNING_BACKEND=LNbitsWallet
# Supported: FakeWallet, LndRestWallet, CoreLightningRestWallet, BlinkWallet, LNbitsWallet, StrikeWallet
MINT_LIGHTNING_BACKEND=FakeWallet

# for use with LNbitsWallet
MINT_LNBITS_ENDPOINT=https://legend.lnbits.com
MINT_LNBITS_KEY=yourkeyasdasdasd

# LndRestWallet
# Use with LndRestWallet
MINT_LND_REST_ENDPOINT=https://127.0.0.1:8086
MINT_LND_REST_CERT="/home/lnd/.lnd/tls.cert"
MINT_LND_REST_MACAROON="/home/lnd/.lnd/data/chain/bitcoin/regtest/admin.macaroon"

# CoreLightningRestWallet
# Use with CoreLightningRestWallet
MINT_CORELIGHTNING_REST_URL=https://localhost:3001
MINT_CORELIGHTNING_REST_MACAROON="/home/cln/cln-rest/access.macaroon"
MINT_CORELIGHTNING_REST_CERT="/home/cln/cln-rest/certificate.pem"

# Use with BlinkWallet
MINT_BLINK_KEY=blink_abcdefgh

# Use with StrikeWallet
MINT_STRIKE_KEY=ABC123

# Fee to reserve in percent of the amount
LIGHTNING_FEE_PERCENT=1.0
# minimum Lightning fee to reserve in msat
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
type: string

jobs:
formatting:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -26,8 +26,8 @@ jobs:
cache: "poetry"
- name: Install packages
run: poetry install
- name: Check black
run: make black-check
- name: Ruff check
run: make ruff-check
mypy:
runs-on: ubuntu-latest
steps:
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Nutshell CI
name: CI
on:
push:
branches:
Expand All @@ -17,8 +17,7 @@ jobs:
poetry-version: ["1.7.1"]
mint-cache-secrets: ["false", "true"]
mint-only-deprecated: ["false", "true"]
# db-url: ["", "postgres://cashu:cashu@localhost:5432/test"] # TODO: Postgres test not working
db-url: [""]
mint-database: ["./test_data/test_mint", "postgres://cashu:cashu@localhost:5432/cashu"]
backend-wallet-class: ["FakeWallet"]
uses: ./.github/workflows/tests.yml
with:
Expand All @@ -27,6 +26,7 @@ jobs:
poetry-version: ${{ matrix.poetry-version }}
mint-cache-secrets: ${{ matrix.mint-cache-secrets }}
mint-only-deprecated: ${{ matrix.mint-only-deprecated }}
mint-database: ${{ matrix.mint-database }}
regtest:
uses: ./.github/workflows/regtest.yml
strategy:
Expand All @@ -38,3 +38,4 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
backend-wallet-class: ${{ matrix.backend-wallet-class }}
mint-database: "./test_data/test_mint"
38 changes: 38 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Docker Build

on:
push:
release:
types: [published]

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Determine Tag
id: get_tag
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
echo "::set-output name=tag::latest"
elif [[ "${{ github.event_name }}" == "release" ]]; then
echo "::set-output name=tag::${{ github.event.release.tag_name }}"
fi
- name: Build and push on release
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name == 'release' }}
tags: ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}:${{ steps.get_tag.outputs.tag }}
18 changes: 16 additions & 2 deletions .github/workflows/regtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
os-version:
default: "ubuntu-latest"
type: string
db-url:
mint-database:
default: ""
type: string
backend-wallet-class:
Expand All @@ -23,6 +23,20 @@ jobs:
regtest:
runs-on: ${{ inputs.os-version }}
timeout-minutes: 10
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: cashu
POSTGRES_PASSWORD: cashu
POSTGRES_DB: cashu
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3

Expand All @@ -47,7 +61,7 @@ jobs:
WALLET_NAME: test_wallet
MINT_HOST: localhost
MINT_PORT: 3337
MINT_DATABASE: ${{ inputs.db-url }}
MINT_TEST_DATABASE: ${{ inputs.mint-database }}
TOR: false
MINT_LIGHTNING_BACKEND: ${{ inputs.backend-wallet-class }}
MINT_LNBITS_ENDPOINT: http://localhost:5001
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
poetry-version:
default: "1.7.1"
type: string
db-url:
mint-database:
default: ""
type: string
os:
Expand All @@ -24,7 +24,7 @@ on:

jobs:
poetry:
name: Run (mint-cache-secrets ${{ inputs.mint-cache-secrets }}, mint-only-deprecated ${{ inputs.mint-only-deprecated }})
name: Run (mint-cache-secrets ${{ inputs.mint-cache-secrets }}, mint-only-deprecated ${{ inputs.mint-only-deprecated }}, mint-database ${{ inputs.mint-database }})
runs-on: ${{ inputs.os }}
services:
postgres:
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
WALLET_NAME: test_wallet
MINT_HOST: localhost
MINT_PORT: 3337
MINT_DATABASE: ${{ inputs.db-url }}
MINT_TEST_DATABASE: ${{ inputs.mint-database }}
MINT_CACHE_SECRETS: ${{ inputs.mint-cache-secrets }}
DEBUG_MINT_ONLY_DEPRECATED: ${{ inputs.mint-only-deprecated }}
TOR: false
Expand Down
12 changes: 4 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
exclude: "^cashu/nostr/.*"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -12,16 +12,12 @@ repos:
- id: debug-statements
- id: mixed-line-ending
- id: check-case-conflict
# - repo: https://github.com/psf/black
# rev: 23.11.0
# hooks:
# - id: black
# args: [--line-length=150]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.283
rev: v0.2.1
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
args: [--fix]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.6.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.9-slim
FROM python:3.10-slim
RUN apt-get update
RUN apt-get install -y curl python3-dev autoconf g++
RUN apt-get install -y libpq-dev
Expand Down
18 changes: 10 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@ ruff:
ruff-check:
poetry run ruff check .

black:
poetry run black .

black-check:
poetry run black . --check

mypy:
poetry run mypy cashu --check-untyped-defs

format: black ruff
format: ruff

check: black-check ruff-check mypy
check: ruff-check mypy

clean:
rm -r cashu.egg-info/ || true
Expand Down Expand Up @@ -59,3 +53,11 @@ install-pre-commit-hook:

pre-commit:
poetry run pre-commit run --all-files

docker-build:
rm -rf docker-build || true
mkdir -p docker-build
git clone . docker-build
cd docker-build
docker buildx build -f Dockerfile -t cashubtc/nutshell:0.15.0 --platform linux/amd64 .
# docker push cashubtc/nutshell:0.15.0
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ source ~/.bashrc
# install cashu
git clone https://github.com/cashubtc/nutshell.git cashu
cd cashu
git checkout <latest_tag>
pyenv local 3.10.4
poetry install
```
Expand Down
Loading

0 comments on commit 2c586fb

Please sign in to comment.