bitcoinwatcher 2.6__tar.gz → 2.6.1__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.6 → bitcoinwatcher-2.6.1}/PKG-INFO +1 -1
  2. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoin/address_listener/address_listener.py +2 -1
  3. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoin/address_listener/simple_address_listener.py +2 -2
  4. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoin/tx_extractors/bitcoin_rpc.py +4 -2
  5. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoin/tx_extractors/default.py +2 -0
  6. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoin/tx_listener/zmq_listener.py +1 -1
  7. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoin/utils/context_aware_logging.py +6 -1
  8. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoinwatcher.egg-info/PKG-INFO +1 -1
  9. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/pyproject.toml +1 -1
  10. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/LICENSE +0 -0
  11. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/README.md +0 -0
  12. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoin/__init__.py +0 -0
  13. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoin/address_listener/__init__.py +0 -0
  14. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoin/models/__init__.py +0 -0
  15. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoin/models/address_tx_data.py +0 -0
  16. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoin/tests/__init__.py +0 -0
  17. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoin/tests/data/__init__.py +0 -0
  18. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoin/tests/data/transactions.py +0 -0
  19. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoin/tests/test_address_listener.py +0 -0
  20. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoin/tests/test_bitcoin_rpc.py +0 -0
  21. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoin/tests/test_bitcoin_utils.py +0 -0
  22. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoin/tx_extractors/__init__.py +0 -0
  23. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoin/tx_extractors/abstract_extractor.py +0 -0
  24. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoin/tx_extractors/mempool.py +0 -0
  25. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoin/tx_listener/__init__.py +0 -0
  26. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoin/tx_listener/abstract_tx_listener.py +0 -0
  27. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoin/utils/__init__.py +0 -0
  28. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoin/utils/benchmark.py +0 -0
  29. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoin/utils/bitcoin_rpc.py +0 -0
  30. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoin/utils/bitcoin_utils.py +0 -0
  31. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoin/utils/constants.py +0 -0
  32. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoin/utils/inscription_utils.py +0 -0
  33. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoinwatcher.egg-info/SOURCES.txt +0 -0
  34. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoinwatcher.egg-info/dependency_links.txt +0 -0
  35. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoinwatcher.egg-info/requires.txt +0 -0
  36. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/bitcoinwatcher.egg-info/top_level.txt +0 -0
  37. {bitcoinwatcher-2.6 → bitcoinwatcher-2.6.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bitcoinwatcher
3
- Version: 2.6
3
+ Version: 2.6.1
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
@@ -37,6 +37,7 @@ class AbstractAddressListener(AbstractTxListener, ABC):
37
37
  # get all address in the inputs and outputs along with the amount
38
38
  if tx.coinbase:
39
39
  return
40
+ logger.debug(f"Extracting default tx data")
40
41
  address_tx_data = self.default_tx_extractor.extract(tx)
41
42
  # filter the address we are interested in
42
43
  addresses_for_events = self.filter_address_tx_data(address_tx_data)
@@ -47,7 +48,7 @@ class AbstractAddressListener(AbstractTxListener, ABC):
47
48
  logger.info(f"Extracting rpc tx data")
48
49
  address_tx_data = self.rpc_tx_extractor.extract(tx)
49
50
  except Exception as e:
50
- logger.error(f"Error in getting rpc tx data, taking defaults",e, exc_info=True)
51
+ logger.error(f"Error in getting rpc tx data, taking defaults", exc_info=True)
51
52
  address_tx_data = address_tx_data
52
53
 
53
54
  for address in addresses_for_events:
@@ -12,7 +12,7 @@ class SimpleAddressListener(AbstractAddressListener):
12
12
  address_tx_data))
13
13
  total_amount_in_input = sum(map(lambda x: x.amount_in_btc(), all_input))
14
14
  # scale ito 4 decimal places
15
- print("Transaction status: ", address_tx_data[0].tx_status)
15
+ print("Transaction status: ", address_tx_data[0].is_confirmed)
16
16
  total_amount_in_output = round(total_amount_in_output, self.DECIMAL_SCALE)
17
17
  print(f"Address {subscribed_address} received {total_amount_in_output} BTC in tx {address_tx_data[0].tx_id}")
18
18
  print(f"Address {subscribed_address} spent {total_amount_in_input} BTC in tx {address_tx_data[0].tx_id}")
@@ -23,7 +23,7 @@ class SimpleAddressListener(AbstractAddressListener):
23
23
 
24
24
 
25
25
  if __name__ == '__main__':
26
- address = ["bc1qcq2uv5nk6hec6kvag3wyevp6574qmsm9scjxc2"]
26
+ address = ["bc1qp8j9sx6609h7llqufurxjgrwsqwt020tqzn0gs", "bc1qcq2uv5nk6hec6kvag3wyevp6574qmsm9scjxc2"]
27
27
  address_watcher = SimpleAddressListener(address)
28
28
  zmq_listener = ZMQTXListener(address_watcher)
29
29
  zmq_listener.start()
@@ -7,7 +7,7 @@ from bitcoin.address_listener.address_listener import AddressTxData
7
7
  from bitcoin.models.address_tx_data import AddressTxType
8
8
  from bitcoin.utils.bitcoin_rpc import BitcoinRPC
9
9
  from bitcoin.tx_extractors.abstract_extractor import AbstractTxAddressDataExtractor
10
- from bitcoin.utils.context_aware_logging import logger
10
+ from bitcoin.utils.context_aware_logging import logger, ctx_tx_status
11
11
 
12
12
 
13
13
  class BitcoinRPCAddressDataExtractor(AbstractTxAddressDataExtractor):
@@ -33,6 +33,7 @@ class BitcoinRPCAddressDataExtractor(AbstractTxAddressDataExtractor):
33
33
  type=AddressTxType.INPUT)
34
34
 
35
35
  def extract(self, tx: Transaction) -> [AddressTxData]:
36
+ logger.info("Extracting rpc tx data")
36
37
  outputs = tx.outputs
37
38
  tx_id = tx.txid
38
39
  address_tx_data = []
@@ -40,7 +41,8 @@ class BitcoinRPCAddressDataExtractor(AbstractTxAddressDataExtractor):
40
41
  # bulk get all the inputs from BitcoinRPC using thread pool
41
42
  inputs_data = self.fetch_all_inputs(inputs)
42
43
  is_confirmed = self.bitcoinrpc.is_confirmed(tx_id)
43
- logger.info("Transaction is_confirmed: ", is_confirmed)
44
+ ctx_tx_status.set(is_confirmed)
45
+ logger.info("Transaction is_confirmed: %s", is_confirmed)
44
46
  for input in inputs:
45
47
  address = input.address
46
48
  amount = 0
@@ -3,6 +3,7 @@ from bitcoinlib.transactions import Transaction
3
3
  from bitcoin.address_listener.address_listener import AddressTxData
4
4
  from bitcoin.models.address_tx_data import AddressTxType
5
5
  from bitcoin.tx_extractors.abstract_extractor import AbstractTxAddressDataExtractor
6
+ from bitcoin.utils.context_aware_logging import ctx_tx_status
6
7
 
7
8
 
8
9
  class DefaultTxAddressDataExtractor(AbstractTxAddressDataExtractor):
@@ -11,6 +12,7 @@ class DefaultTxAddressDataExtractor(AbstractTxAddressDataExtractor):
11
12
  address_tx_data = []
12
13
  inputs = tx.inputs
13
14
  is_confirmed = tx.status == "confirmed"
15
+ ctx_tx_status.set(is_confirmed)
14
16
  for input in inputs:
15
17
  address = input.address
16
18
  amount = 0
@@ -30,7 +30,7 @@ class ZMQTXListener:
30
30
  ctx_tx.set(tx.txid)
31
31
  self.tx_listener.on_tx(tx)
32
32
  except Exception as e:
33
- print(f"Error in parsing tx: {e}")
33
+ logger.error(f"Error in parsing tx: {e}", exc_info=True)
34
34
 
35
35
  def stop(self):
36
36
  self.socket.close()
@@ -23,7 +23,7 @@ class TimezoneFormatter(logging.Formatter):
23
23
 
24
24
 
25
25
  formatter = TimezoneFormatter(
26
- ' %(asctime)s %(name)s txid=%(tx_id)s [%(module)s:%(lineno)d] %(message)s',
26
+ ' %(asctime)s %(levelname)s txid=%(tx_id)s tx_status=%(tx_status)s [%(module)s:%(lineno)d] %(funcName)s: %(message)s',
27
27
  datefmt='%Y-%m-%d %H:%M:%S',
28
28
  tz=pytz.timezone('Asia/Kolkata')
29
29
  )
@@ -32,6 +32,10 @@ formatter = TimezoneFormatter(
32
32
  ctx_tx = ContextVar('tx_id', default='')
33
33
  ctx_tx_status = ContextVar('tx_status', default='')
34
34
 
35
+ class ExcludeModuleFilter(logging.Filter):
36
+ def filter(self, record):
37
+ return not (record.name.startswith('bitcoinlib.transactions') or record.name.startswith('bitcoinlib.scripts'))
38
+
35
39
  class TXContextFilter(logging.Filter):
36
40
 
37
41
  def __init__(self):
@@ -48,6 +52,7 @@ ch = logging.StreamHandler()
48
52
  f = TXContextFilter()
49
53
  ch.setFormatter(formatter)
50
54
  ch.addFilter(f)
55
+ ch.addFilter(ExcludeModuleFilter())
51
56
  root.addHandler(ch)
52
57
 
53
58
  def get_logger(name):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bitcoinwatcher
3
- Version: 2.6
3
+ Version: 2.6.1
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
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
 
6
6
  [project]
7
7
  name = "bitcoinwatcher"
8
- version = "2.6"
8
+ version = "2.6.1"
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"}]
File without changes
File without changes
File without changes