-
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into keyset-balance-views
- Loading branch information
Showing
52 changed files
with
1,864 additions
and
769 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,8 +39,11 @@ MINT_INFO_DESCRIPTION="The short mint description" | |
MINT_INFO_DESCRIPTION_LONG="A long mint description that can be a long piece of text." | ||
MINT_INFO_CONTACT=[["email","[email protected]"], ["twitter","@me"], ["nostr", "npub..."]] | ||
MINT_INFO_MOTD="Message to users" | ||
MINT_INFO_ICON_URL="https://mint.host/icon.jpg" | ||
MINT_INFO_URLS=["https://mint.host", "http://mint8gv0sq5ul602uxt2fe0t80e3c2bi9fy0cxedp69v1vat6ruj81wv.onion"] | ||
|
||
MINT_PRIVATE_KEY=supersecretprivatekey | ||
# This is used to derive your mint's private keys. Store it securely. | ||
# MINT_PRIVATE_KEY=<openssl rand -hex 32> | ||
|
||
# Increment derivation path to rotate to a new keyset | ||
# Example: m/0'/0'/0' -> m/0'/0'/1' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: tests_redis_cache | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
python-version: | ||
default: "3.10.4" | ||
type: string | ||
poetry-version: | ||
default: "1.7.1" | ||
type: string | ||
mint-database: | ||
default: "" | ||
type: string | ||
os: | ||
default: "ubuntu-latest" | ||
type: string | ||
mint-only-deprecated: | ||
default: "false" | ||
type: string | ||
|
||
jobs: | ||
poetry: | ||
name: Run (db ${{ inputs.mint-database }}, deprecated api ${{ inputs.mint-only-deprecated }}) | ||
runs-on: ${{ inputs.os }} | ||
steps: | ||
- name: Start PostgreSQL service | ||
if: contains(inputs.mint-database, 'postgres') | ||
run: | | ||
docker run -d --name postgres -e POSTGRES_USER=cashu -e POSTGRES_PASSWORD=cashu -e POSTGRES_DB=cashu -p 5432:5432 postgres:latest | ||
until docker exec postgres pg_isready; do sleep 1; done | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Prepare environment | ||
uses: ./.github/actions/prepare | ||
with: | ||
python-version: ${{ inputs.python-version }} | ||
poetry-version: ${{ inputs.poetry-version }} | ||
|
||
- name: Start Redis service | ||
run: | | ||
docker compose -f docker/docker-compose.yml up -d redis | ||
- name: Run tests | ||
env: | ||
MINT_BACKEND_BOLT11_SAT: FakeWallet | ||
WALLET_NAME: test_wallet | ||
MINT_HOST: localhost | ||
MINT_PORT: 3337 | ||
MINT_TEST_DATABASE: ${{ inputs.mint-database }} | ||
TOR: false | ||
MINT_REDIS_CACHE_ENABLED: true | ||
MINT_REDIS_CACHE_URL: redis://localhost:6379 | ||
run: | | ||
poetry run pytest tests/test_mint_api_cache.py -v --cov=mint --cov-report=xml | ||
- name: Stop and clean up Docker Compose | ||
run: | | ||
docker compose -f docker/docker-compose.yml down | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from hashlib import sha256 | ||
from typing import List | ||
|
||
from ..base import BlindedMessage | ||
from ..crypto.secp import PrivateKey, PublicKey | ||
|
||
|
||
def generate_keypair() -> tuple[str, str]: | ||
privkey = PrivateKey() | ||
assert privkey.pubkey | ||
pubkey = privkey.pubkey | ||
return privkey.serialize(), pubkey.serialize(True).hex() | ||
|
||
|
||
def construct_message(quote_id: str, outputs: List[BlindedMessage]) -> bytes: | ||
serialized_outputs = b"".join([o.B_.encode("utf-8") for o in outputs]) | ||
msgbytes = sha256(quote_id.encode("utf-8") + serialized_outputs).digest() | ||
return msgbytes | ||
|
||
|
||
def sign_mint_quote( | ||
quote_id: str, | ||
outputs: List[BlindedMessage], | ||
private_key: str, | ||
) -> str: | ||
privkey = PrivateKey(bytes.fromhex(private_key), raw=True) | ||
msgbytes = construct_message(quote_id, outputs) | ||
sig = privkey.schnorr_sign(msgbytes, None, raw=True) | ||
return sig.hex() | ||
|
||
|
||
def verify_mint_quote( | ||
quote_id: str, | ||
outputs: List[BlindedMessage], | ||
public_key: str, | ||
signature: str, | ||
) -> bool: | ||
pubkey = PublicKey(bytes.fromhex(public_key), raw=True) | ||
msgbytes = construct_message(quote_id, outputs) | ||
sig = bytes.fromhex(signature) | ||
return pubkey.schnorr_verify(msgbytes, sig, None, raw=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.