bitcoinwatcher 2.8__tar.gz → 2.10__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/PKG-INFO +2 -1
  2. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoin/tx_extractors/bitcoin_rpc.py +6 -2
  3. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoin/utils/context_aware_logging.py +15 -6
  4. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoinwatcher.egg-info/PKG-INFO +2 -1
  5. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoinwatcher.egg-info/requires.txt +1 -0
  6. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/pyproject.toml +2 -1
  7. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/LICENSE +0 -0
  8. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/README.md +0 -0
  9. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoin/__init__.py +0 -0
  10. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoin/address_listener/__init__.py +0 -0
  11. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoin/address_listener/address_listener.py +0 -0
  12. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoin/address_listener/simple_address_listener.py +0 -0
  13. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoin/models/__init__.py +0 -0
  14. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoin/models/address_tx_data.py +0 -0
  15. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoin/tests/__init__.py +0 -0
  16. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoin/tests/data/__init__.py +0 -0
  17. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoin/tests/data/transactions.py +0 -0
  18. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoin/tests/test_address_listener.py +0 -0
  19. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoin/tests/test_bitcoin_rpc.py +0 -0
  20. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoin/tests/test_bitcoin_utils.py +0 -0
  21. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoin/tx_extractors/__init__.py +0 -0
  22. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoin/tx_extractors/abstract_extractor.py +0 -0
  23. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoin/tx_extractors/default.py +0 -0
  24. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoin/tx_extractors/mempool.py +0 -0
  25. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoin/tx_listener/__init__.py +0 -0
  26. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoin/tx_listener/abstract_tx_listener.py +0 -0
  27. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoin/tx_listener/zmq_listener.py +0 -0
  28. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoin/utils/__init__.py +0 -0
  29. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoin/utils/benchmark.py +0 -0
  30. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoin/utils/bitcoin_rpc.py +0 -0
  31. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoin/utils/bitcoin_utils.py +0 -0
  32. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoin/utils/constants.py +0 -0
  33. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoin/utils/inscription_utils.py +0 -0
  34. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoinwatcher.egg-info/SOURCES.txt +0 -0
  35. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoinwatcher.egg-info/dependency_links.txt +0 -0
  36. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/bitcoinwatcher.egg-info/top_level.txt +0 -0
  37. {bitcoinwatcher-2.8 → bitcoinwatcher-2.10}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bitcoinwatcher
3
- Version: 2.8
3
+ Version: 2.10
4
4
  Summary: bitcoinwatcher is a Python library that implements a ZMQ subscriber and provides abstractions to build custom address watchers. This library is designed to make it easy for developers to monitor Bitcoin addresses and react to changes in their state.
5
5
  Author: twosatsmaxi
6
6
  License: Apache License
@@ -229,6 +229,7 @@ Requires-Dist: ordipool==1.2.0
229
229
  Requires-Dist: pyzmq==25.1.2
230
230
  Requires-Dist: python-bitcoinrpc==1.0
231
231
  Requires-Dist: pytz~=2024.2
232
+ Requires-Dist: colorlog~=6.9.0
232
233
 
233
234
  # bitcoinwatcher
234
235
 
@@ -18,11 +18,15 @@ class BitcoinRPCAddressDataExtractor(AbstractTxAddressDataExtractor):
18
18
  self.bitcoinrpc = BitcoinRPC()
19
19
 
20
20
  def fetch_all_inputs(self, inputs):
21
- rpc_calls = [["getrawtransaction", input.prev_txid.hex(), True] for input in inputs]
21
+ unique_txids = list(set([input.prev_txid.hex() for input in inputs]))
22
+ rpc_calls = [["getrawtransaction", tx_id, True] for tx_id in unique_txids]
22
23
  data = self.bitcoinrpc.rpc_connection.batch_(rpc_calls)
24
+ tx_id_to_data = {tx_id: current_tx for tx_id, current_tx in zip(unique_txids, data)}
23
25
  list_of_vouts = []
24
26
  for input in inputs:
25
- vout = data.pop(0)["vout"][input.output_n_int]
27
+ tx_id = input.prev_txid.hex()
28
+ current_tx = tx_id_to_data[tx_id]
29
+ vout = current_tx["vout"][input.output_n_int]
26
30
  list_of_vouts.append(vout)
27
31
  return list_of_vouts
28
32
 
@@ -1,6 +1,8 @@
1
1
  import logging
2
+ import sys
2
3
  from contextvars import ContextVar
3
4
  from datetime import datetime
5
+ import colorlog
4
6
 
5
7
  import pytz
6
8
 
@@ -8,9 +10,9 @@ logger = logging.getLogger(__name__)
8
10
  root = logging.getLogger()
9
11
  root.setLevel(logging.INFO)
10
12
 
11
- class TimezoneFormatter(logging.Formatter):
12
- def __init__(self, fmt=None, datefmt=None, tz=None):
13
- super().__init__(fmt, datefmt)
13
+ class TimezoneFormatter(colorlog.ColoredFormatter):
14
+ def __init__(self, fmt=None, datefmt=None, tz=None, log_colors=None):
15
+ super().__init__(fmt, datefmt, log_colors=log_colors)
14
16
  self.tz = tz
15
17
 
16
18
  def formatTime(self, record, datefmt=None):
@@ -19,12 +21,19 @@ class TimezoneFormatter(logging.Formatter):
19
21
  s = dt.strftime(datefmt)
20
22
  else:
21
23
  s = dt.isoformat()
22
- return s # Adding blue color to the date
24
+ return f"\033[94m{s}\033[0m" # Adding blue color to the date
23
25
 
24
26
  formatter = TimezoneFormatter(
25
- ' %(asctime)s %(levelname)s txid= %(tx_id)s tx_status=%(tx_status)s [%(module)s:%(lineno)d] %(message)s',
27
+ ' %(asctime)s %(log_color)s%(levelname)s txid=%(tx_id)s tx_status=%(tx_status)s [%(module)s:%(lineno)d] %(message)s',
26
28
  datefmt='%Y-%m-%d %H:%M:%S',
27
29
  tz=pytz.timezone('Asia/Kolkata'),
30
+ log_colors={
31
+ 'DEBUG': 'cyan',
32
+ 'INFO': 'green',
33
+ 'WARNING': 'yellow',
34
+ 'ERROR': 'red',
35
+ 'CRITICAL': 'bold_red',
36
+ }
28
37
  )
29
38
 
30
39
 
@@ -47,7 +56,7 @@ class TXContextFilter(logging.Filter):
47
56
  record.tx_status = tx_status
48
57
  return True
49
58
 
50
- ch = logging.StreamHandler()
59
+ ch = logging.StreamHandler(sys.stdout)
51
60
  f = TXContextFilter()
52
61
  ch.setFormatter(formatter)
53
62
  ch.addFilter(f)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bitcoinwatcher
3
- Version: 2.8
3
+ Version: 2.10
4
4
  Summary: bitcoinwatcher is a Python library that implements a ZMQ subscriber and provides abstractions to build custom address watchers. This library is designed to make it easy for developers to monitor Bitcoin addresses and react to changes in their state.
5
5
  Author: twosatsmaxi
6
6
  License: Apache License
@@ -229,6 +229,7 @@ Requires-Dist: ordipool==1.2.0
229
229
  Requires-Dist: pyzmq==25.1.2
230
230
  Requires-Dist: python-bitcoinrpc==1.0
231
231
  Requires-Dist: pytz~=2024.2
232
+ Requires-Dist: colorlog~=6.9.0
232
233
 
233
234
  # bitcoinwatcher
234
235
 
@@ -10,3 +10,4 @@ ordipool==1.2.0
10
10
  pyzmq==25.1.2
11
11
  python-bitcoinrpc==1.0
12
12
  pytz~=2024.2
13
+ colorlog~=6.9.0
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
 
6
6
  [project]
7
7
  name = "bitcoinwatcher"
8
- version = "2.8"
8
+ version = "2.10"
9
9
  description = "bitcoinwatcher is a Python library that implements a ZMQ subscriber and provides abstractions to build custom address watchers. This library is designed to make it easy for developers to monitor Bitcoin addresses and react to changes in their state."
10
10
  readme = "README.md"
11
11
  authors = [{name = "twosatsmaxi"}]
@@ -35,6 +35,7 @@ dependencies = [
35
35
  "pyzmq==25.1.2",
36
36
  "python-bitcoinrpc==1.0",
37
37
  "pytz~=2024.2",
38
+ "colorlog~=6.9.0"
38
39
  ]
39
40
  requires-python = ">=3.10"
40
41
  [project.urls]
File without changes
File without changes
File without changes