diff --git a/cashu/mint/db/write.py b/cashu/mint/db/write.py index 4ed833e1..279a2047 100644 --- a/cashu/mint/db/write.py +++ b/cashu/mint/db/write.py @@ -1,4 +1,5 @@ -from typing import List, Optional, Tuple, Union, Dict +import json +from typing import Dict, List, Optional, Tuple, Union from loguru import logger @@ -7,16 +8,16 @@ DlcBadInput, DlcFundingAck, DlcFundingError, + DlcPayout, + DlcPayoutForm, DlcSettlement, DlcSettlementAck, DlcSettlementError, - DlcPayoutForm, - DlcPayout, MeltQuote, MeltQuoteState, + MintKeyset, MintQuote, MintQuoteState, - MintKeyset, Proof, ProofSpentState, ProofState, @@ -26,18 +27,15 @@ from ...core.errors import ( CashuError, DlcAlreadyRegisteredError, + DlcPayoutFail, + DlcSettlementFail, TokenAlreadySpentError, TransactionError, - DlcSettlementFail, - DlcNotFoundError, - DlcPayoutFail, ) from ..crud import LedgerCrud from ..events.events import LedgerEventManager from .read import DbReadHelper -import json - class DbWriteHelper: db: Database diff --git a/cashu/mint/dlc.py b/cashu/mint/dlc.py index aee3f347..a5695e43 100644 --- a/cashu/mint/dlc.py +++ b/cashu/mint/dlc.py @@ -1,7 +1,5 @@ from typing import Dict -import json -from ..core.base import DlcSettlement from ..core.errors import TransactionError from ..core.nuts import DLC_NUT from .features import LedgerFeatures diff --git a/cashu/mint/ledger.py b/cashu/mint/ledger.py index 538dbac7..0dcc2b23 100644 --- a/cashu/mint/ledger.py +++ b/cashu/mint/ledger.py @@ -15,10 +15,10 @@ DlcFundingAck, DlcFundingError, DlcFundingProof, - DlcSettlement, - DlcSettlementError, DlcPayout, DlcPayoutForm, + DlcSettlement, + DlcSettlementError, MeltQuote, MeltQuoteState, Method, @@ -49,11 +49,12 @@ NotAllowedError, QuoteNotPaidError, TransactionError, - DlcPayoutFail, ) from ..core.helpers import sum_proofs from ..core.models import ( GetDlcStatusResponse, + PostDlcPayoutRequest, + PostDlcPayoutResponse, PostDlcRegistrationRequest, PostDlcRegistrationResponse, PostDlcSettleRequest, @@ -61,8 +62,6 @@ PostMeltQuoteRequest, PostMeltQuoteResponse, PostMintQuoteRequest, - PostDlcPayoutRequest, - PostDlcPayoutResponse, ) from ..core.settings import settings from ..core.split import amount_split diff --git a/cashu/mint/router.py b/cashu/mint/router.py index ebbbc42d..f1c7acbc 100644 --- a/cashu/mint/router.py +++ b/cashu/mint/router.py @@ -15,6 +15,8 @@ MintInfoContact, PostCheckStateRequest, PostCheckStateResponse, + PostDlcPayoutRequest, + PostDlcPayoutResponse, PostDlcRegistrationRequest, PostDlcRegistrationResponse, PostDlcSettleRequest, @@ -30,8 +32,6 @@ PostRestoreResponse, PostSwapRequest, PostSwapResponse, - PostDlcPayoutRequest, - PostDlcPayoutResponse, ) from ..core.settings import settings from ..mint.startup import ledger diff --git a/cashu/mint/verification.py b/cashu/mint/verification.py index ef068c80..3fcda794 100644 --- a/cashu/mint/verification.py +++ b/cashu/mint/verification.py @@ -18,11 +18,16 @@ Unit, ) from ..core.crypto import b_dhke -from ..core.crypto.dlc import merkle_verify, verify_payout_secret, verify_payout_signature +from ..core.crypto.dlc import ( + merkle_verify, + verify_payout_secret, + verify_payout_signature, +) from ..core.crypto.secp import PrivateKey, PublicKey from ..core.db import Connection, Database from ..core.errors import ( CashuError, + DlcPayoutFail, DlcSettlementFail, DlcVerificationFail, NoSecretInProofsError, @@ -30,7 +35,6 @@ SecretTooLongError, TransactionError, TransactionUnitError, - DlcPayoutFail, ) from ..core.settings import settings from ..lightning.base import LightningBackend diff --git a/tests/test_dlc.py b/tests/test_dlc.py index 5eda0b67..8c4085dd 100644 --- a/tests/test_dlc.py +++ b/tests/test_dlc.py @@ -12,9 +12,9 @@ from cashu.core.base import ( DiscreetLogContract, DlcOutcome, - DlcSettlement, DlcPayoutForm, DlcPayoutWitness, + DlcSettlement, Proof, SCTWitness, TokenV4, @@ -31,9 +31,9 @@ ) from cashu.core.errors import CashuError from cashu.core.models import ( + PostDlcPayoutRequest, PostDlcRegistrationRequest, PostDlcSettleRequest, - PostDlcPayoutRequest, ) from cashu.core.secret import Secret, SecretKind from cashu.mint.ledger import Ledger @@ -645,7 +645,7 @@ async def test_payout_dlc(wallet: Wallet, ledger: Ledger): # CLAIMING our victorious payout # Generating outputs - amounts = [64,32,16,8,4,2,1] + amounts = [128] secrets, rs, _ = await wallet.generate_n_secrets( len(amounts), skip_bump=True ) @@ -664,6 +664,6 @@ async def test_payout_dlc(wallet: Wallet, ledger: Ledger): response = await ledger.payout_dlc(request) assert response.errors is None, f"Payout failed: {response.errors[0].detail}" - assert len(response.paid) > 0, f"Payout failed: paid list is empty" + assert len(response.paid) > 0, "Payout failed: paid list is empty" assert response.paid[0].dlc_root == dlc_root.hex() assert len(response.paid[0].outputs) == len(amounts) \ No newline at end of file