mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-20 02:24:20 +01:00
nut-09 mint info (#155)
* nut-09 mint info * bump to 0.11.1 * make format
This commit is contained in:
22
.env.example
22
.env.example
@@ -2,7 +2,7 @@ DEBUG=FALSE
|
||||
|
||||
CASHU_DIR=~/.cashu
|
||||
|
||||
# WALLET
|
||||
# --------- WALLET ---------
|
||||
|
||||
# MINT_URL=https://localhost:3338
|
||||
MINT_HOST=127.0.0.1
|
||||
@@ -17,7 +17,20 @@ TOR=TRUE
|
||||
#SOCKS_HOST=localhost
|
||||
#SOCKS_PORT=9050
|
||||
|
||||
# MINT
|
||||
# NOSTR
|
||||
# nostr private key to which to receive tokens to
|
||||
NOSTR_PRIVATE_KEY=nostr_privatekey_here_hex_or_bech32
|
||||
# nostr relays (comma separated list)
|
||||
NOSTR_RELAYS="wss://nostr-pub.wellorder.net"
|
||||
|
||||
# --------- MINT ---------
|
||||
|
||||
MINT_INFO_NAME="My Cashu mint"
|
||||
MINT_INFO_PUBKEY="<hex_pubkey>"
|
||||
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: contact@me.com", "Twitter: @me", "Nostr: npub..."]
|
||||
# MINT_INFO_MOTD="Message to users"
|
||||
|
||||
MINT_PRIVATE_KEY=supersecretprivatekey
|
||||
|
||||
@@ -36,8 +49,3 @@ LIGHTNING_RESERVE_FEE_MIN=4000
|
||||
MINT_LNBITS_ENDPOINT=https://legend.lnbits.com
|
||||
MINT_LNBITS_KEY=yourkeyasdasdasd
|
||||
|
||||
# NOSTR
|
||||
# nostr private key to which to receive tokens to
|
||||
NOSTR_PRIVATE_KEY=nostr_privatekey_here_hex_or_bech32
|
||||
# nostr relays (comma separated list)
|
||||
NOSTR_RELAYS="wss://nostr-pub.wellorder.net"
|
||||
|
||||
@@ -115,7 +115,7 @@ cashu info
|
||||
|
||||
Returns:
|
||||
```bash
|
||||
Version: 0.11.0
|
||||
Version: 0.11.1
|
||||
Debug: False
|
||||
Cashu dir: /home/user/.cashu
|
||||
Wallet: wallet
|
||||
|
||||
@@ -102,6 +102,19 @@ class Invoice(BaseModel):
|
||||
|
||||
# ------- API -------
|
||||
|
||||
# ------- API: INFO -------
|
||||
|
||||
|
||||
class GetInfoResponse(BaseModel):
|
||||
name: Optional[str] = None
|
||||
pubkey: Optional[str] = None
|
||||
version: Optional[str] = None
|
||||
description: Optional[str] = None
|
||||
description_long: Optional[str] = None
|
||||
contact: Optional[List[str]] = None
|
||||
nuts: Optional[List[str]] = None
|
||||
motd: Optional[str] = None
|
||||
|
||||
|
||||
# ------- API: KEYS -------
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ def derive_keys(master_key: str, derivation_path: str = ""):
|
||||
return {
|
||||
2
|
||||
** i: PrivateKey(
|
||||
hashlib.sha256((str(master_key) + derivation_path + str(i)).encode("utf-8"))
|
||||
hashlib.sha256((master_key + derivation_path + str(i)).encode("utf-8"))
|
||||
.hexdigest()
|
||||
.encode("utf-8")[:32],
|
||||
raw=True,
|
||||
@@ -31,6 +31,13 @@ def derive_keys(master_key: str, derivation_path: str = ""):
|
||||
}
|
||||
|
||||
|
||||
def derive_pubkey(master_key: str):
|
||||
return PrivateKey(
|
||||
hashlib.sha256((master_key).encode("utf-8")).hexdigest().encode("utf-8")[:32],
|
||||
raw=True,
|
||||
).pubkey
|
||||
|
||||
|
||||
def derive_pubkeys(keys: Dict[int, PrivateKey]):
|
||||
return {
|
||||
amt: keys[amt].pubkey for amt in [2**i for i in range(settings.max_order)]
|
||||
|
||||
@@ -8,7 +8,7 @@ from pydantic import BaseSettings, Extra, Field, validator
|
||||
|
||||
env = Env()
|
||||
|
||||
VERSION = "0.11.0"
|
||||
VERSION = "0.11.1"
|
||||
|
||||
|
||||
def find_env_file():
|
||||
@@ -58,6 +58,15 @@ class MintSettings(CashuSettings):
|
||||
mint_lnbits_key: str = Field(default=None)
|
||||
|
||||
|
||||
class MintInformation(CashuSettings):
|
||||
mint_info_name: str = Field(default="Cashu mint")
|
||||
mint_info_description: str = Field(default=None)
|
||||
mint_info_description_long: str = Field(default=None)
|
||||
mint_info_contact: List[str] = Field(default=[])
|
||||
mint_info_nuts: List[str] = Field(default=["NUT-07", "NUT-08"])
|
||||
mint_info_motd: str = Field(default=None)
|
||||
|
||||
|
||||
class WalletSettings(CashuSettings):
|
||||
lightning: bool = Field(default=True)
|
||||
tor: bool = Field(default=True)
|
||||
@@ -79,7 +88,9 @@ class WalletSettings(CashuSettings):
|
||||
)
|
||||
|
||||
|
||||
class Settings(EnvSettings, MintSettings, WalletSettings, CashuSettings):
|
||||
class Settings(
|
||||
EnvSettings, MintSettings, MintInformation, WalletSettings, CashuSettings
|
||||
):
|
||||
version: str = Field(default=VERSION)
|
||||
|
||||
# def __init__(self, env_file=None):
|
||||
|
||||
@@ -14,6 +14,7 @@ from cashu.core.base import (
|
||||
MintKeysets,
|
||||
Proof,
|
||||
)
|
||||
from cashu.core.crypto import derive_pubkey
|
||||
from cashu.core.db import Database
|
||||
from cashu.core.helpers import fee_reserve, sum_proofs
|
||||
from cashu.core.script import verify_script
|
||||
@@ -40,6 +41,7 @@ class Ledger:
|
||||
self.db = db
|
||||
self.crud = crud
|
||||
self.lightning = lightning
|
||||
self.pubkey = derive_pubkey(self.master_key)
|
||||
|
||||
async def load_used_proofs(self):
|
||||
"""Load all used proofs from database."""
|
||||
|
||||
@@ -10,6 +10,7 @@ from cashu.core.base import (
|
||||
CheckFeesResponse,
|
||||
CheckSpendableRequest,
|
||||
CheckSpendableResponse,
|
||||
GetInfoResponse,
|
||||
GetMeltResponse,
|
||||
GetMintResponse,
|
||||
KeysetsResponse,
|
||||
@@ -21,11 +22,32 @@ from cashu.core.base import (
|
||||
PostSplitResponse,
|
||||
)
|
||||
from cashu.core.errors import CashuError
|
||||
from cashu.core.settings import settings
|
||||
from cashu.mint.startup import ledger
|
||||
|
||||
router: APIRouter = APIRouter()
|
||||
|
||||
|
||||
@router.get(
|
||||
"/info",
|
||||
name="Mint information",
|
||||
summary="Mint information, operator contact information, and other info.",
|
||||
response_model=GetInfoResponse,
|
||||
response_model_exclude_none=True,
|
||||
)
|
||||
async def info():
|
||||
return GetInfoResponse(
|
||||
name=settings.mint_info_name,
|
||||
pubkey=ledger.pubkey.serialize().hex() if ledger.pubkey else None,
|
||||
version=f"Nutshell/{settings.version}",
|
||||
description=settings.mint_info_description,
|
||||
description_long=settings.mint_info_description_long,
|
||||
contact=settings.mint_info_contact,
|
||||
nuts=settings.mint_info_nuts,
|
||||
motd=settings.mint_info_motd,
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/keys",
|
||||
name="Mint public keys",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "cashu"
|
||||
version = "0.11.0"
|
||||
version = "0.11.1"
|
||||
description = "Ecash wallet and mint."
|
||||
authors = ["calle <callebtc@protonmail.com>"]
|
||||
license = "MIT"
|
||||
|
||||
2
setup.py
2
setup.py
@@ -13,7 +13,7 @@ entry_points = {"console_scripts": ["cashu = cashu.wallet.cli.cli:cli"]}
|
||||
|
||||
setuptools.setup(
|
||||
name="cashu",
|
||||
version="0.11.0",
|
||||
version="0.11.1",
|
||||
description="Ecash wallet and mint for Bitcoin Lightning",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
|
||||
Reference in New Issue
Block a user