Skip to content

Commit

Permalink
Version 1.14.0.0 (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrNaif2018 authored Jan 10, 2024
1 parent 79d4210 commit f40891b
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.coverage
.idea/
.mypy_cache/
.prettiercache
.vscode/
__pycache__/
backup/
Expand Down
16 changes: 9 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-merge-conflict
- repo: https://github.com/asottile/yesqa
rev: v1.5.0
hooks:
- id: yesqa
- repo: https://github.com/psf/black
rev: 23.7.0
rev: 23.12.1
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
rev: 7.0.0
hooks:
- id: flake8
- repo: https://github.com/asottile/pyupgrade
rev: v3.10.1
rev: v3.15.0
hooks:
- id: pyupgrade
args: ["--py38-plus"]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
Expand All @@ -48,6 +48,8 @@ repos:
args: ["--remove"]
- id: detect-private-key
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.1
rev: v4.0.0-alpha.8
hooks:
- id: prettier
require_serial: true
args: ["--cache-location=.prettiercache"]
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Latest changes

## 1.14.0.0

Electrums upgrade

**Breaking changes**: `get_config` method no longer has `default` argument, this is determined by electrum. Also it is no longer possible to programmatically disable lightning

## 1.12.1.1

Rename BitcartCC to Bitcart
Expand Down
8 changes: 4 additions & 4 deletions bitcart/coins/btc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def lightning(f: Callable) -> Callable:
async def wrapper(*args: Any, **kwargs: Any) -> Any:
if len(args) > 0:
obj = args[0]
if not await obj.get_config("lightning"): # pragma: no cover: can't be changed during tests
capabilities = (await obj.spec).get("capabilities", {})
if not capabilities.get("lightning", False): # pragma: no cover: can't be changed during tests
raise LightningDisabledError("Lightning is disabled in current daemon.")
return await f(*args, **kwargs)

Expand Down Expand Up @@ -415,10 +416,9 @@ async def set_config(self, key: str, value: Any) -> bool:
"""
return await self.server.setconfig(key, value) # type: ignore

async def get_config(self, key: str, default: Any = None) -> Any:
async def get_config(self, key: str) -> Any:
"""Get config key
If the key doesn't exist, default value is returned.
Keys are stored in electrum's config file, check :meth:`bitcart.coins.btc.BTC.set_config` doc for details.
Example:
Expand All @@ -434,7 +434,7 @@ async def get_config(self, key: str, default: Any = None) -> Any:
Returns:
Any: value of the key or default value provided
"""
return await self.server.getconfig(key) or default
return await self.server.getconfig(key)

async def validate_key(self, key: str, *args: Any, **kwargs: Any) -> bool:
"""Validate whether provided key is valid to restore a wallet
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
setup(
name="bitcart",
packages=find_packages(),
version="1.12.1.1",
version="1.14.0.0",
license="MIT",
description="Bitcart coins support library",
long_description=open("README.md").read(),
Expand Down
5 changes: 0 additions & 5 deletions tests/coins/btc/test_lightning.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ async def test_connect(btc_wallet):
assert await btc_wallet.connect("0214382bdce7750dfcb8126df8e2b12de38536902dc36abcebdaeefdeca1df8284@172.81.181.3")


async def test_lightning_always_enabled(btc_wallet):
await btc_wallet.set_config("lightning", False)
assert await btc_wallet.node_id is not None # env variables can't be overwritten


async def test_wallet_methods_on_non_segwit(lightning_unsupported_wallet):
request = await lightning_unsupported_wallet.add_request(0.5)
assert request["is_lightning"] is False
Expand Down
3 changes: 2 additions & 1 deletion tests/coins/btc/test_without_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ async def test_get_tx(btc):


async def test_config_methods(btc):
k, v = "x", 1
k, v = "auto_connect", False
await btc.set_config(k, v)
assert await btc.get_config(k) == v
await btc.set_config(k, True)


async def test_get_address(btc):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_spec.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
def test_spec(btc):
assert btc.spec == btc.server.spec
assert isinstance(btc.spec, dict)
assert btc.spec.keys() == {"exceptions", "electrum_map", "version"}
assert btc.spec.keys() == {"exceptions", "electrum_map", "version", "capabilities"}

0 comments on commit f40891b

Please sign in to comment.