diff --git a/README.md b/README.md index 00f0d87..9d3ded0 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ cashu info Returns: ```bash -Version: 0.4.3 +Version: 0.5.0 Debug: False Cashu dir: /home/user/.cashu Wallet: wallet diff --git a/cashu/core/settings.py b/cashu/core/settings.py index b70d97e..22c60c4 100644 --- a/cashu/core/settings.py +++ b/cashu/core/settings.py @@ -53,4 +53,4 @@ LNBITS_ENDPOINT = env.str("LNBITS_ENDPOINT", default=None) LNBITS_KEY = env.str("LNBITS_KEY", default=None) MAX_ORDER = 64 -VERSION = "0.4.3" +VERSION = "0.5.0" diff --git a/cashu/tor/tor.py b/cashu/tor/tor.py index c41ca02..8adf1c7 100755 --- a/cashu/tor/tor.py +++ b/cashu/tor/tor.py @@ -91,15 +91,21 @@ class TorProxy: # current attached process running return self.tor_proc and self.tor_proc.poll() is None - def wait_until_startup(self): + def wait_until_startup(self, verbose=False): if self.is_port_open(): return if self.tor_proc is None: raise Exception("Tor proxy not attached.") if not self.tor_proc.stdout: raise Exception("could not get tor stdout.") + if verbose: + print("Starting Tor...", end="", flush=True) for line in self.tor_proc.stdout: + if verbose: + print(".", end="", flush=True) if "Bootstrapped 100%: Done" in str(line): + if verbose: + print("done.", flush=True) break # tor is ready self.startup_finished = True diff --git a/cashu/wallet/wallet.py b/cashu/wallet/wallet.py index 9cf1d2e..fd92d9c 100644 --- a/cashu/wallet/wallet.py +++ b/cashu/wallet/wallet.py @@ -58,14 +58,13 @@ class LedgerAPI: def __init__(self, url): self.url = url - self.s = self._set_requests() - self.s.headers.update({"Client-version": VERSION}) def _set_requests(self): s = requests.Session() + s.headers.update({"Client-version": VERSION}) if TOR: tor = TorProxy(keep_alive=True) - tor.wait_until_startup() + tor.wait_until_startup(verbose=True) socks_host, socks_port = "localhost", 9050 else: socks_host, socks_port = SOCKS_HOST, SOCKS_PORT @@ -77,7 +76,6 @@ class LedgerAPI: } s.proxies.update(proxies) s.headers.update({"User-Agent": scrts.token_urlsafe(8)}) - return s def _construct_proofs( @@ -174,6 +172,7 @@ class LedgerAPI: """ async def _get_keys(self, url): + self.s = self._set_requests() resp = self.s.get( url + "/keys", ) @@ -188,6 +187,7 @@ class LedgerAPI: return keyset async def _get_keysets(self, url): + self.s = self._set_requests() resp = self.s.get( url + "/keysets", ) @@ -198,6 +198,7 @@ class LedgerAPI: def request_mint(self, amount): """Requests a mint from the server and returns Lightning invoice.""" + self.s = self._set_requests() resp = self.s.get(self.url + "/mint", params={"amount": amount}) resp.raise_for_status() return_dict = resp.json() @@ -209,7 +210,7 @@ class LedgerAPI: secrets = [self._generate_secret() for s in range(len(amounts))] await self._check_used_secrets(secrets) payloads, rs = self._construct_outputs(amounts, secrets) - + self.s = self._set_requests() resp = self.s.post( self.url + "/mint", json=payloads.dict(), @@ -265,6 +266,7 @@ class LedgerAPI: "proofs": {i: proofs_include for i in range(len(proofs))}, } + self.s = self._set_requests() resp = self.s.post( self.url + "/split", json=split_payload.dict(include=_splitrequest_include_fields(proofs)), @@ -297,6 +299,7 @@ class LedgerAPI: "proofs": {i: {"secret"} for i in range(len(proofs))}, } + self.s = self._set_requests() resp = self.s.post( self.url + "/check", json=payload.dict(include=_check_spendable_include_fields(proofs)), @@ -309,6 +312,7 @@ class LedgerAPI: async def check_fees(self, payment_request: str): """Checks whether the Lightning payment is internal.""" payload = CheckFeesRequest(pr=payment_request) + self.s = self._set_requests() resp = self.s.post( self.url + "/checkfees", json=payload.dict(), @@ -333,6 +337,7 @@ class LedgerAPI: "proofs": {i: proofs_include for i in range(len(proofs))}, } + self.s = self._set_requests() resp = self.s.post( self.url + "/melt", json=payload.dict(include=_meltequest_include_fields(proofs)), diff --git a/pyproject.toml b/pyproject.toml index 76a35a1..9281125 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "cashu" -version = "0.4.3" +version = "0.5.0" description = "Ecash wallet and mint." authors = ["calle "] license = "MIT" diff --git a/setup.py b/setup.py index 584e59f..ee31f5f 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ entry_points = {"console_scripts": ["cashu = cashu.wallet.cli:cli"]} setuptools.setup( name="cashu", - version="0.4.3", + version="0.5.0", description="Ecash wallet and mint with Bitcoin Lightning support", long_description=long_description, long_description_content_type="text/markdown",