Skip to content

Commit

Permalink
sdk: utils
Browse files Browse the repository at this point in the history
  • Loading branch information
krishpranav committed Dec 25, 2024
1 parent dc12bcf commit 1d6493c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions sdk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,14 @@ def convert_amount_type(amount: str | Decimal) -> Decimal:

def satoshis(amount: str | Decimal) -> int:
return int(convert_amount_type(amount) * CONVERT_RATE)

def bitcoins(amount: int) -> Decimal:
return Decimal(amount) / Decimal(CONVERT_RATE)

class CustomJSONEncoder(json.JSONEncoder):
def default(self, obj: Any) -> Any:
if isinstance(obj, Decimal):
return str(obj)

return super().default(obj)

0 comments on commit 1d6493c

Please sign in to comment.