Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,13 @@ jobs:
os: [ubuntu-latest]
python-version: ["3.12"]
poetry-version: ["2.3.2"]
# Wallet v0 / deprecated mint API support was removed in https://github.com/cashubtc/nutshell/pull/814; deprecated-only CI runs are no longer valid.
# mint-only-deprecated: ["false", "true"]
mint-only-deprecated: ["false"]
mint-database: ["./test_data/test_mint", "postgres://cashu:cashu@localhost:5432/cashu"]
backend-wallet-class: ["FakeWallet"]
uses: ./.github/workflows/tests.yml
with:
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
poetry-version: ${{ matrix.poetry-version }}
mint-only-deprecated: ${{ matrix.mint-only-deprecated }}
mint-database: ${{ matrix.mint-database }}

tests_redis_cache:
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@ on:
os:
default: "ubuntu-latest"
type: string
mint-only-deprecated:
default: "false"
type: string

permissions:
contents: read

jobs:
poetry:
name: Run (db ${{ inputs.mint-database }}, deprecated api ${{ inputs.mint-only-deprecated }})
name: Run (db ${{ inputs.mint-database }})
runs-on: ${{ inputs.os }}
steps:
- name: Start PostgreSQL service
Expand All @@ -45,7 +42,6 @@ jobs:
MINT_HOST: localhost
MINT_PORT: 3337
MINT_TEST_DATABASE: ${{ inputs.mint-database }}
DEBUG_MINT_ONLY_DEPRECATED: ${{ inputs.mint-only-deprecated }}
TOR: false
run: |
make test
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/tests_redis_cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@ on:
os:
default: "ubuntu-latest"
type: string
mint-only-deprecated:
default: "false"
type: string

permissions:
contents: read

jobs:
poetry:
name: Run (db ${{ inputs.mint-database }}, deprecated api ${{ inputs.mint-only-deprecated }})
name: Run (db ${{ inputs.mint-database }})
runs-on: ${{ inputs.os }}
steps:
- name: Start PostgreSQL service
Expand Down
4 changes: 0 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,3 @@ MINT_CORELIGHTNING_REST_CERT=../cashu-regtest-enviroment/data/clightning-2-rest/
### Profiling

If you'd like to profile your code (measure how long steps take to execute), run the mint using `DEBUG_PROFILING=TRUE`. Make sure to turn this off again, as your application will be significantly slower with profiling enabled.

### V0 API only

To run the mint with only V0 API support (deprecated), use `DEBUG_MINT_ONLY_DEPRECATED=TRUE`
80 changes: 12 additions & 68 deletions cashu/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,23 +241,6 @@ def from_row(cls, row: RowMapping):
return cls(amount=row["amount"], B_=row["b_"], id=row["id"], C_=row.get("c_"))


class BlindedMessage_Deprecated(BaseModel):
"""
Deprecated: BlindedMessage for v0 protocol (deprecated api routes) have no id field.

Blinded message or blinded secret or "output" which is to be signed by the mint
"""

amount: int
B_: str # Hex-encoded blinded message
witness: Union[str, None] = None # witnesses (used for P2PK with SIG_ALL)

@property
def p2pksigs(self) -> List[str]:
assert self.witness, "Witness missing in output"
return P2PKWitness.from_witness(self.witness).signatures


class BlindedSignature(BaseModel):
"""
Blinded signature or "promise" which is the signature on a `BlindedMessage`
Expand Down Expand Up @@ -303,7 +286,6 @@ class MeltQuote(LedgerEvent):
fee_paid: int = 0
payment_preimage: Optional[str] = None
expiry: Optional[int] = None
outputs: Optional[List[BlindedMessage]] = None
change: Optional[List[BlindedSignature]] = None
mint: Optional[str] = None

Expand All @@ -322,10 +304,6 @@ def from_row(cls, row: Row, change: Optional[List[BlindedSignature]] = None):

payment_preimage = row.get("payment_preimage") or row.get("proof") # type: ignore

outputs = None
if "outputs" in row.keys() and row["outputs"]:
outputs = json.loads(row["outputs"])

return cls(
quote=row["quote"],
method=row["method"],
Expand All @@ -338,22 +316,19 @@ def from_row(cls, row: Row, change: Optional[List[BlindedSignature]] = None):
created_time=created_time,
paid_time=paid_time,
fee_paid=row["fee_paid"],
outputs=outputs,
change=change,
expiry=expiry,
payment_preimage=payment_preimage,
)

@classmethod
def from_resp_wallet(cls, melt_quote_resp, mint: str, unit: str, request: str):
def from_resp_wallet(cls, melt_quote_resp, mint: str):
return cls(
quote=melt_quote_resp.quote,
method=Method.bolt11.name,
request=melt_quote_resp.request
or request, # BACKWARDS COMPATIBILITY mint response < 0.17.0
request=melt_quote_resp.request,
checking_id="",
unit=melt_quote_resp.unit
or unit, # BACKWARDS COMPATIBILITY mint response < 0.17.0
unit=melt_quote_resp.unit,
amount=melt_quote_resp.amount,
fee_reserve=melt_quote_resp.fee_reserve,
state=MeltQuoteState(melt_quote_resp.state),
Expand Down Expand Up @@ -452,11 +427,7 @@ def from_row(cls, row: Row):
if "last_checked" in row.keys() and row["last_checked"]
else None
)
updated_at = (
int(row["updated_at"])
if "updated_at" in row.keys() and row["updated_at"]
else None
)
updated_at = int(row["updated_at"]) if row["updated_at"] else None
except Exception:
# POSTGRES: row is datetime.datetime
created_time = (
Expand All @@ -474,9 +445,7 @@ def from_row(cls, row: Row):
else None
)
updated_at = (
int(row["updated_at"].timestamp())
if "updated_at" in row.keys() and row["updated_at"]
else None
int(row["updated_at"].timestamp()) if row["updated_at"] else None
)
return cls(
quote=row["quote"],
Expand All @@ -492,12 +461,10 @@ def from_row(cls, row: Row):
last_checked=last_checked,
pubkey=row["pubkey"] if "pubkey" in row.keys() else None,
privkey=row["privkey"] if "privkey" in row.keys() else None,
amount_paid=row["amount_paid"]
if "amount_paid" in row.keys() and row["amount_paid"] is not None
else None,
amount_issued=row["amount_issued"]
if "amount_issued" in row.keys() and row["amount_issued"] is not None
else None,
amount_paid=row["amount_paid"] if row["amount_paid"] is not None else None,
amount_issued=(
row["amount_issued"] if row["amount_issued"] is not None else None
),
updated_at=updated_at
if updated_at is not None
else (issued_time or paid_time or created_time or int(time.time())),
Expand All @@ -508,8 +475,6 @@ def from_resp_wallet(
cls,
mint_quote_resp,
mint: str,
amount: int,
unit: str,
paid_time: Optional[int] = None,
issued_time: Optional[int] = None,
):
Expand All @@ -532,10 +497,8 @@ def from_resp_wallet(
state = MintQuoteState.issued
else:
state = MintQuoteState.unpaid
elif mint_quote_resp.state:
state = MintQuoteState(mint_quote_resp.state)
else:
state = MintQuoteState.unpaid
state = MintQuoteState(mint_quote_resp.state)

if paid_time is None and mint_quote_resp.updated_at is not None:
if state in [MintQuoteState.paid, MintQuoteState.issued]:
Expand All @@ -550,10 +513,8 @@ def from_resp_wallet(
method=Method.bolt11.name,
request=mint_quote_resp.request,
checking_id="",
unit=mint_quote_resp.unit
or unit, # BACKWARDS COMPATIBILITY mint response < 0.17.0
amount=mint_quote_resp.amount
or amount, # BACKWARDS COMPATIBILITY mint response < 0.17.0
unit=mint_quote_resp.unit,
amount=mint_quote_resp.amount,
state=state,
mint=mint,
expiry=mint_quote_resp.expiry,
Expand All @@ -572,8 +533,6 @@ def check_stale_and_from_resp_wallet(
mint_quote_resp,
mint: str,
mint_quote_local: Optional["MintQuote"] = None,
default_amount: int = 0,
default_unit: str = "sat",
) -> "MintQuote":
# Check if the response from the mint is stale compared to the local quote
is_stale = False
Expand Down Expand Up @@ -607,25 +566,12 @@ def check_stale_and_from_resp_wallet(
if is_stale and mint_quote_local:
return mint_quote_local

amount = (
(mint_quote_resp.amount or mint_quote_local.amount)
if mint_quote_local
else default_amount
)
unit = (
(mint_quote_resp.unit or mint_quote_local.unit)
if mint_quote_local
else default_unit
)

paid_time = mint_quote_local.paid_time if mint_quote_local else None
issued_time = mint_quote_local.issued_time if mint_quote_local else None

return cls.from_resp_wallet(
mint_quote_resp,
mint=mint,
amount=amount,
unit=unit,
paid_time=paid_time,
issued_time=issued_time,
)
Expand Down Expand Up @@ -992,8 +938,6 @@ class MintKeyset:
balance: int
final_expiry: Optional[int] = None # NEW: Final expiry timestamp for keyset v2

duplicate_keyset_id: Optional[str] = None # BACKWARDS COMPATIBILITY < 0.15.0

def __init__(
self,
*,
Expand Down
51 changes: 4 additions & 47 deletions cashu/core/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
from .blind_auth import PostAuthBlindMintRequest, PostAuthBlindMintResponse
from .check import (
CheckFeesRequest_deprecated,
CheckFeesResponse_deprecated,
CheckSpendableRequest_deprecated,
CheckSpendableResponse_deprecated,
PostCheckStateRequest,
PostCheckStateResponse,
)
from .check import PostCheckStateRequest, PostCheckStateResponse
from .info import (
GetInfoResponse,
GetInfoResponse_deprecated,
MeltMethodSetting,
MintInfoContact,
MintInfoProtectedEndpoint,
Expand All @@ -19,96 +11,61 @@
)
from .keys import (
KeysetsResponse,
KeysetsResponse_deprecated,
KeysetsResponseKeyset,
KeysResponse,
KeysResponse_deprecated,
KeysResponseKeyset,
)
from .melt import (
PostMeltRequest,
PostMeltRequest_deprecated,
PostMeltResponse_deprecated,
)
from .melt import PostMeltRequest
from .melt_quote import (
PostMeltQuoteRequest,
PostMeltQuoteResponse,
PostMeltRequestOptionMpp,
PostMeltRequestOptions,
)
from .mint import (
GetMintResponse_deprecated,
PostMintBatchRequest,
PostMintBatchResponse,
PostMintRequest,
PostMintRequest_deprecated,
PostMintResponse,
PostMintResponse_deprecated,
)
from .mint_quote import (
PostMintQuoteCheckRequest,
PostMintQuoteRequest,
PostMintQuoteResponse,
)
from .restore import (
PostRestoreRequest,
PostRestoreRequest_Deprecated,
PostRestoreResponse,
)
from .swap import (
PostSwapRequest,
PostSwapRequest_Deprecated,
PostSwapResponse,
PostSwapResponse_Deprecated,
PostSwapResponse_Very_Deprecated,
)
from .restore import PostRestoreRequest, PostRestoreResponse
from .swap import PostSwapRequest, PostSwapResponse

__all__ = [
"PostAuthBlindMintRequest",
"PostAuthBlindMintResponse",
"CheckFeesRequest_deprecated",
"CheckFeesResponse_deprecated",
"CheckSpendableRequest_deprecated",
"CheckSpendableResponse_deprecated",
"PostCheckStateRequest",
"PostCheckStateResponse",
"GetInfoResponse",
"GetInfoResponse_deprecated",
"MeltMethodSetting",
"MintInfoContact",
"MintInfoProtectedEndpoint",
"MintMethodBolt11OptionSetting",
"MintMethodSetting",
"Nut15MppSupport",
"KeysResponse",
"KeysResponse_deprecated",
"KeysResponseKeyset",
"KeysetsResponse",
"KeysetsResponse_deprecated",
"KeysetsResponseKeyset",
"PostMeltRequest",
"PostMeltRequest_deprecated",
"PostMeltResponse_deprecated",
"PostMeltQuoteRequest",
"PostMeltQuoteResponse",
"PostMeltRequestOptionMpp",
"PostMeltRequestOptions",
"GetMintResponse_deprecated",
"PostMintBatchRequest",
"PostMintBatchResponse",
"PostMintRequest",
"PostMintRequest_deprecated",
"PostMintResponse",
"PostMintResponse_deprecated",
"PostMintQuoteCheckRequest",
"PostMintQuoteRequest",
"PostMintQuoteResponse",
"PostRestoreRequest",
"PostRestoreRequest_Deprecated",
"PostRestoreResponse",
"PostSwapRequest",
"PostSwapRequest_Deprecated",
"PostSwapResponse",
"PostSwapResponse_Deprecated",
"PostSwapResponse_Very_Deprecated",
]
Loading
Loading