-
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip * wip * model * refactor wallet transactions * refactor wallet * sending with fees works and outputs fill up the wallet * wip work * ok * comments * receive with amount=0 * correctly import postmeltrequest * fix melt amount * tests working * remove mint_loaded decorator in deprecated wallet api * wallet works with units * refactor: melt_quote * fix fees * add file * fees for melt inputs * set default input fee for internal quotes to 0 * fix coinselect * coin selection working * yo * fix all tests * clean up * last commit added fees for inputs for melt transactions - this commit adds a blanace too low exception * fix fee return and melt quote max allowed amount check during creation of melt quote * clean up code * add tests for fees * add melt tests * update wallet fee information
- Loading branch information
Showing
47 changed files
with
2,444 additions
and
1,552 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,265 @@ | ||
from typing import Any, Dict, List, Optional, Union | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
from .base import ( | ||
BlindedMessage, | ||
BlindedMessage_Deprecated, | ||
BlindedSignature, | ||
Proof, | ||
ProofState, | ||
) | ||
from .settings import settings | ||
|
||
# ------- API ------- | ||
|
||
# ------- API: INFO ------- | ||
|
||
|
||
class MintMeltMethodSetting(BaseModel): | ||
method: str | ||
unit: str | ||
min_amount: Optional[int] = None | ||
max_amount: Optional[int] = None | ||
|
||
|
||
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[List[str]]] = None | ||
motd: Optional[str] = None | ||
nuts: Optional[Dict[int, Any]] = None | ||
|
||
|
||
class Nut15MppSupport(BaseModel): | ||
method: str | ||
unit: str | ||
mpp: bool | ||
|
||
|
||
class GetInfoResponse_deprecated(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[List[str]]] = None | ||
nuts: Optional[List[str]] = None | ||
motd: Optional[str] = None | ||
parameter: Optional[dict] = None | ||
|
||
|
||
# ------- API: KEYS ------- | ||
|
||
|
||
class KeysResponseKeyset(BaseModel): | ||
id: str | ||
unit: str | ||
keys: Dict[int, str] | ||
|
||
|
||
class KeysResponse(BaseModel): | ||
keysets: List[KeysResponseKeyset] | ||
|
||
|
||
class KeysetsResponseKeyset(BaseModel): | ||
id: str | ||
unit: str | ||
active: bool | ||
input_fee_ppk: Optional[int] = None | ||
|
||
|
||
class KeysetsResponse(BaseModel): | ||
keysets: list[KeysetsResponseKeyset] | ||
|
||
|
||
class KeysResponse_deprecated(BaseModel): | ||
__root__: Dict[str, str] | ||
|
||
|
||
class KeysetsResponse_deprecated(BaseModel): | ||
keysets: list[str] | ||
|
||
|
||
# ------- API: MINT QUOTE ------- | ||
|
||
|
||
class PostMintQuoteRequest(BaseModel): | ||
unit: str = Field(..., max_length=settings.mint_max_request_length) # output unit | ||
amount: int = Field(..., gt=0) # output amount | ||
|
||
|
||
class PostMintQuoteResponse(BaseModel): | ||
quote: str # quote id | ||
request: str # input payment request | ||
paid: bool # whether the request has been paid | ||
expiry: Optional[int] # expiry of the quote | ||
|
||
|
||
# ------- API: MINT ------- | ||
|
||
|
||
class PostMintRequest(BaseModel): | ||
quote: str = Field(..., max_length=settings.mint_max_request_length) # quote id | ||
outputs: List[BlindedMessage] = Field( | ||
..., max_items=settings.mint_max_request_length | ||
) | ||
|
||
|
||
class PostMintResponse(BaseModel): | ||
signatures: List[BlindedSignature] = [] | ||
|
||
|
||
class GetMintResponse_deprecated(BaseModel): | ||
pr: str | ||
hash: str | ||
|
||
|
||
class PostMintRequest_deprecated(BaseModel): | ||
outputs: List[BlindedMessage_Deprecated] = Field( | ||
..., max_items=settings.mint_max_request_length | ||
) | ||
|
||
|
||
class PostMintResponse_deprecated(BaseModel): | ||
promises: List[BlindedSignature] = [] | ||
|
||
|
||
# ------- API: MELT QUOTE ------- | ||
|
||
|
||
class PostMeltQuoteRequest(BaseModel): | ||
unit: str = Field(..., max_length=settings.mint_max_request_length) # input unit | ||
request: str = Field( | ||
..., max_length=settings.mint_max_request_length | ||
) # output payment request | ||
amount: Optional[int] = Field(default=None, gt=0) # input amount | ||
|
||
|
||
class PostMeltQuoteResponse(BaseModel): | ||
quote: str # quote id | ||
amount: int # input amount | ||
fee_reserve: int # input fee reserve | ||
paid: bool # whether the request has been paid | ||
expiry: Optional[int] # expiry of the quote | ||
|
||
|
||
# ------- API: MELT ------- | ||
|
||
|
||
class PostMeltRequest(BaseModel): | ||
quote: str = Field(..., max_length=settings.mint_max_request_length) # quote id | ||
inputs: List[Proof] = Field(..., max_items=settings.mint_max_request_length) | ||
outputs: Union[List[BlindedMessage], None] = Field( | ||
None, max_items=settings.mint_max_request_length | ||
) | ||
|
||
|
||
class PostMeltResponse(BaseModel): | ||
paid: Union[bool, None] | ||
payment_preimage: Union[str, None] | ||
change: Union[List[BlindedSignature], None] = None | ||
|
||
|
||
class PostMeltRequest_deprecated(BaseModel): | ||
proofs: List[Proof] = Field(..., max_items=settings.mint_max_request_length) | ||
pr: str = Field(..., max_length=settings.mint_max_request_length) | ||
outputs: Union[List[BlindedMessage_Deprecated], None] = Field( | ||
None, max_items=settings.mint_max_request_length | ||
) | ||
|
||
|
||
class PostMeltResponse_deprecated(BaseModel): | ||
paid: Union[bool, None] | ||
preimage: Union[str, None] | ||
change: Union[List[BlindedSignature], None] = None | ||
|
||
|
||
# ------- API: SPLIT ------- | ||
|
||
|
||
class PostSplitRequest(BaseModel): | ||
inputs: List[Proof] = Field(..., max_items=settings.mint_max_request_length) | ||
outputs: List[BlindedMessage] = Field( | ||
..., max_items=settings.mint_max_request_length | ||
) | ||
|
||
|
||
class PostSplitResponse(BaseModel): | ||
signatures: List[BlindedSignature] | ||
|
||
|
||
# deprecated since 0.13.0 | ||
class PostSplitRequest_Deprecated(BaseModel): | ||
proofs: List[Proof] = Field(..., max_items=settings.mint_max_request_length) | ||
amount: Optional[int] = None | ||
outputs: List[BlindedMessage_Deprecated] = Field( | ||
..., max_items=settings.mint_max_request_length | ||
) | ||
|
||
|
||
class PostSplitResponse_Deprecated(BaseModel): | ||
promises: List[BlindedSignature] = [] | ||
|
||
|
||
class PostSplitResponse_Very_Deprecated(BaseModel): | ||
fst: List[BlindedSignature] = [] | ||
snd: List[BlindedSignature] = [] | ||
deprecated: str = "The amount field is deprecated since 0.13.0" | ||
|
||
|
||
# ------- API: CHECK ------- | ||
|
||
|
||
class PostCheckStateRequest(BaseModel): | ||
Ys: List[str] = Field(..., max_items=settings.mint_max_request_length) | ||
|
||
|
||
class PostCheckStateResponse(BaseModel): | ||
states: List[ProofState] = [] | ||
|
||
|
||
class CheckSpendableRequest_deprecated(BaseModel): | ||
proofs: List[Proof] = Field(..., max_items=settings.mint_max_request_length) | ||
|
||
|
||
class CheckSpendableResponse_deprecated(BaseModel): | ||
spendable: List[bool] | ||
pending: List[bool] | ||
|
||
|
||
class CheckFeesRequest_deprecated(BaseModel): | ||
pr: str = Field(..., max_length=settings.mint_max_request_length) | ||
|
||
|
||
class CheckFeesResponse_deprecated(BaseModel): | ||
fee: Union[int, None] | ||
|
||
|
||
# ------- API: RESTORE ------- | ||
|
||
|
||
class PostRestoreRequest(BaseModel): | ||
outputs: List[BlindedMessage] = Field( | ||
..., max_items=settings.mint_max_request_length | ||
) | ||
|
||
|
||
class PostRestoreRequest_Deprecated(BaseModel): | ||
outputs: List[BlindedMessage_Deprecated] = Field( | ||
..., max_items=settings.mint_max_request_length | ||
) | ||
|
||
|
||
class PostRestoreResponse(BaseModel): | ||
outputs: List[BlindedMessage] = [] | ||
signatures: List[BlindedSignature] = [] | ||
promises: Optional[List[BlindedSignature]] = [] # deprecated since 0.15.1 | ||
|
||
# duplicate value of "signatures" for backwards compatibility with old clients < 0.15.1 | ||
def __init__(self, **data): | ||
super().__init__(**data) | ||
self.promises = self.signatures |
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
Oops, something went wrong.