Skip to content

Commit a6b3f0a

Browse files
committed
Version 1.12.0.0
1 parent 1498132 commit a6b3f0a

File tree

7 files changed

+20
-64
lines changed

7 files changed

+20
-64
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ repos:
88
hooks:
99
- id: yesqa
1010
- repo: https://github.com/psf/black
11-
rev: 22.12.0
11+
rev: 23.3.0
1212
hooks:
1313
- id: black
1414
- repo: https://github.com/pycqa/isort
@@ -48,6 +48,6 @@ repos:
4848
args: ["--remove"]
4949
- id: detect-private-key
5050
- repo: https://github.com/pre-commit/mirrors-prettier
51-
rev: v3.0.0-alpha.4
51+
rev: v3.0.0-alpha.6
5252
hooks:
5353
- id: prettier

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22

33
## Latest changes
44

5+
## 1.12.0.0
6+
7+
Breaking: removed `rate` and `list_fiat` commands.
8+
9+
This is because the current exchange rates model:
10+
11+
1. Didn't provide enough customization (tied to coingecko and it's currencies only)
12+
2. Often unreliable because sometimes depends on implementation in e.g. electrum
13+
3. Getting rate limited when many daemons are launched
14+
15+
To overcome the problem, we've moved the exchange rates functionality one layer up (like it should have always been), to the Merchants API
16+
17+
This means if you use rate command in your script, you should either use Merchants API directly (maybe your usage of SDK is not required at all), or fetch
18+
exchange rates from your favourite exchange rates provider (more customization)
19+
520
## 1.11.1.0
621

722
Add new `xpub_name` attribute in coin objects, used to display what "xpub" actually means in context of current coin (i.e. it may be xpub, or it may actually be an address)

bitcart/coins/btc.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import inspect
2-
from decimal import Decimal
32
from functools import wraps
43
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Union
54

@@ -391,46 +390,6 @@ async def pay_to_many(
391390
else:
392391
return tx_data # type: ignore
393392

394-
async def rate(self, currency: str = "USD") -> Decimal:
395-
"""Get bitcoin price in selected fiat currency
396-
397-
It uses the same method as electrum wallet gets exchange rate-via different payment providers
398-
399-
Examples:
400-
401-
>>> c.rate()
402-
9878.527
403-
404-
>>> c.rate("RUB")
405-
757108.226
406-
407-
Args:
408-
self (BTC): self
409-
currency (str, optional): Currency to get rate into. Defaults to "USD".
410-
411-
Returns:
412-
Decimal: price of 1 bitcoin in selected fiat currency
413-
"""
414-
return convert_amount_type(await self.server.exchange_rate(currency))
415-
416-
async def list_fiat(self) -> Iterable[str]:
417-
"""List of all available fiat currencies to get price for
418-
419-
This list is list of only valid currencies that could be passed to rate() function
420-
421-
Example:
422-
423-
>>> c.list_fiat()
424-
['AED', 'ARS', 'AUD', 'BCH', 'BDT', 'BHD', 'BMD', 'BNB', 'BRL', 'BTC', ...]
425-
426-
Args:
427-
self (BTC): self
428-
429-
Returns:
430-
Iterable[str]: list of available fiat currencies
431-
"""
432-
return await self.server.list_currencies() # type: ignore
433-
434393
async def set_config(self, key: str, value: Any) -> bool:
435394
"""Set config key to specified value
436395

examples/atomic_tipbot/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Full example of using BitcartCC: Telegram Atomic Tip Bot
22

3+
**_Note: this example doesn't work because of `rate()` command being removed. Fetch exchange rates yourself or use Merchants API for this_**
4+
35
The bot is available in telegram at @bitcart_atomic_tipbot
46

57
Used tools:
@@ -149,7 +151,6 @@ To see a list of all RPC methods, call
149151
RPC methods accessible via btc.server can't have intellisence in your IDE because they are completely dynamic(via `__getattr__`).
150152

151153
Now, about using BitcartCC in this bot's code.
152-
To get price of 1 bitcoin in USD, simply call `btc.rate()`
153154
Use `btc.add_request(amount, description="", expire=15)` to create BTC invoice
154155
Amount is amount in BTC, description is optional and is description of invoice, expire is the time invoice will expire in,
155156
default 15 minutes, but if you pass None, invoice will never expire.

examples/full.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
print(btc.RPC_PASS) # default rpc password
1515

1616
# Methods used without wallet #
17-
print(btc.rate()) # BTC rate in USD
18-
print(btc.rate("RUB")) # BTC rate in rubles, or any other currency
19-
print(btc.list_fiat()) # List of all fiat currencies to get bitcoin rate in
2017
print(btc.help()) # List of low level electrum methods
2118
print(btc.server.validateaddress("x")) # Example of calling lowlevel electrum method
2219
print(btc.get_tx("d0e9433f41e17ef74547aa5e1873cd3ad12f1402b488eb93e1c8e3dda971ef53")) # Get transaction info

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
setup(
44
name="bitcart",
55
packages=find_packages(),
6-
version="1.11.1.0",
6+
version="1.12.0.0",
77
license="MIT",
88
description="BitcartCC coins support library",
99
long_description=open("README.md").read(),

tests/coins/btc/test_without_wallet.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
33
If this succeeds, most likely other coins will succeed too
44
"""
5-
import decimal
65
import os
76

87
import pytest
@@ -28,21 +27,6 @@ async def test_help(btc):
2827
assert "help" in data
2928

3029

31-
@pytest.mark.parametrize("currency", ["USD", "RUB", "JPY", "nonexisting"])
32-
async def test_rate(btc, currency):
33-
price = await btc.rate(currency)
34-
if currency == "nonexisting":
35-
assert price.is_nan()
36-
else:
37-
assert price > 0
38-
assert isinstance(price, decimal.Decimal)
39-
40-
41-
async def test_fiat(btc):
42-
fiat_currencies = await btc.list_fiat()
43-
assert ["USD", "BTC", "RUB", "JPY", "EUR"] >= fiat_currencies
44-
45-
4630
@pytest.mark.parametrize("address,expected", [("x", False), ("tb1qzq67gkmp7fl45y5h87emyhhzdl3s77904h99c8", True)])
4731
async def test_electrum_validate_address(btc, address, expected):
4832
assert await btc.server.validateaddress(address) == expected

0 commit comments

Comments
 (0)