bitcoinwatcher 2.3__tar.gz → 2.5__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 (36) hide show
  1. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/PKG-INFO +2 -2
  2. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoin/address_listener/address_listener.py +3 -3
  3. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoin/models/address_tx_data.py +1 -1
  4. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoin/tx_extractors/bitcoin_rpc.py +5 -5
  5. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoin/tx_extractors/default.py +3 -3
  6. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoin/utils/bitcoin_rpc.py +10 -3
  7. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoinwatcher.egg-info/PKG-INFO +2 -2
  8. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoinwatcher.egg-info/requires.txt +1 -1
  9. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/pyproject.toml +2 -2
  10. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/LICENSE +0 -0
  11. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/README.md +0 -0
  12. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoin/__init__.py +0 -0
  13. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoin/address_listener/__init__.py +0 -0
  14. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoin/address_listener/simple_address_listener.py +0 -0
  15. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoin/models/__init__.py +0 -0
  16. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoin/tests/__init__.py +0 -0
  17. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoin/tests/data/__init__.py +0 -0
  18. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoin/tests/data/transactions.py +0 -0
  19. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoin/tests/test_address_listener.py +0 -0
  20. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoin/tests/test_bitcoin_rpc.py +0 -0
  21. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoin/tests/test_bitcoin_utils.py +0 -0
  22. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoin/tx_extractors/__init__.py +0 -0
  23. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoin/tx_extractors/abstract_extractor.py +0 -0
  24. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoin/tx_extractors/mempool.py +0 -0
  25. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoin/tx_listener/__init__.py +0 -0
  26. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoin/tx_listener/abstract_tx_listener.py +0 -0
  27. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoin/tx_listener/zmq_listener.py +0 -0
  28. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoin/utils/__init__.py +0 -0
  29. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoin/utils/benchmark.py +0 -0
  30. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoin/utils/bitcoin_utils.py +0 -0
  31. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoin/utils/constants.py +0 -0
  32. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoin/utils/inscription_utils.py +0 -0
  33. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoinwatcher.egg-info/SOURCES.txt +0 -0
  34. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoinwatcher.egg-info/dependency_links.txt +0 -0
  35. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/bitcoinwatcher.egg-info/top_level.txt +0 -0
  36. {bitcoinwatcher-2.3 → bitcoinwatcher-2.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bitcoinwatcher
3
- Version: 2.3
3
+ Version: 2.5
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
@@ -220,7 +220,7 @@ License-File: LICENSE
220
220
  Requires-Dist: requests~=2.31.0
221
221
  Requires-Dist: certifi==2024.2.2
222
222
  Requires-Dist: charset-normalizer==3.3.2
223
- Requires-Dist: idna==3.6
223
+ Requires-Dist: idna==3.7
224
224
  Requires-Dist: pyzmq==25.1.2
225
225
  Requires-Dist: requests==2.31.0
226
226
  Requires-Dist: six==1.16.0
@@ -18,7 +18,7 @@ class AbstractAddressListener(AbstractTxListener, ABC):
18
18
  base_url = f"http://{host}:3006/api"
19
19
  mempool = Mempool(base_url=base_url)
20
20
  default_tx_extractor = DefaultTxAddressDataExtractor()
21
- mempool_tx_extractor = BitcoinRPCAddressDataExtractor()
21
+ rpc_tx_extractor = BitcoinRPCAddressDataExtractor()
22
22
 
23
23
  def __init__(self, addresses_to_listen: {str}):
24
24
  self.addresses_to_listen = addresses_to_listen
@@ -44,9 +44,9 @@ class AbstractAddressListener(AbstractTxListener, ABC):
44
44
  return
45
45
  # get the address tx data from mempool for full details if any address matches
46
46
  try:
47
- address_tx_data = self.mempool_tx_extractor.extract(tx)
47
+ address_tx_data = self.rpc_tx_extractor.extract(tx)
48
48
  except Exception as e:
49
- print(f"Error in getting mempool tx data, taking defaults: {e}")
49
+ print(f"Error in getting rpc tx data, taking defaults: {e}")
50
50
  address_tx_data = address_tx_data
51
51
 
52
52
  for address in addresses_for_events:
@@ -24,7 +24,7 @@ class AddressTxData:
24
24
  type: AddressTxType
25
25
  # figure out the way to get amount in vin
26
26
  _amount: int = 0
27
- tx_status: str = "unconfirmed"
27
+ is_confirmed: bool = False
28
28
  is_reveal_tx: bool = False
29
29
 
30
30
  def get_amount(self):
@@ -28,7 +28,7 @@ class BitcoinRPCAddressDataExtractor(AbstractTxAddressDataExtractor):
28
28
  def get_address_tx_from_inputdata(self, tx_id, tx_status, input_data):
29
29
  address = input_data["scriptPubKey"]["address"]
30
30
  amount = int(input_data.get("value", 0).real * 100000000)
31
- return AddressTxData(tx_id=tx_id, tx_status=tx_status, address=address, _amount=amount,
31
+ return AddressTxData(tx_id=tx_id, is_confirmed=tx_status, address=address, _amount=amount,
32
32
  type=AddressTxType.INPUT)
33
33
 
34
34
  def extract(self, tx: Transaction) -> [AddressTxData]:
@@ -38,23 +38,23 @@ class BitcoinRPCAddressDataExtractor(AbstractTxAddressDataExtractor):
38
38
  inputs = tx.inputs
39
39
  # bulk get all the inputs from BitcoinRPC using thread pool
40
40
  inputs_data = self.fetch_all_inputs(inputs)
41
- tx_status = tx.status
41
+ is_confirmed = self.bitcoinrpc.is_confirmed(tx_id)
42
42
  for input in inputs:
43
43
  address = input.address
44
44
  amount = 0
45
45
  if len(inputs_data) > 0:
46
46
  input_data = inputs_data.pop(0)
47
- input_tx_data = self.get_address_tx_from_inputdata(tx_id, tx_status, input_data)
47
+ input_tx_data = self.get_address_tx_from_inputdata(tx_id, is_confirmed, input_data)
48
48
  address_tx_data.append(input_tx_data)
49
49
  else:
50
- address_tx_data.append(AddressTxData(tx_status=tx_status,
50
+ address_tx_data.append(AddressTxData(is_confirmed=is_confirmed,
51
51
  address=address,
52
52
  type=AddressTxType.INPUT,
53
53
  _amount=amount,
54
54
  tx_id=tx.txid))
55
55
  for output in outputs:
56
56
  amount = output.value
57
- address_tx_data.append(AddressTxData(tx_status=tx_status,
57
+ address_tx_data.append(AddressTxData(is_confirmed=is_confirmed,
58
58
  address=output.address,
59
59
  _amount=amount,
60
60
  type=AddressTxType.OUTPUT,
@@ -10,18 +10,18 @@ class DefaultTxAddressDataExtractor(AbstractTxAddressDataExtractor):
10
10
  outputs = tx.outputs
11
11
  address_tx_data = []
12
12
  inputs = tx.inputs
13
- tx_status = tx.status
13
+ is_confirmed = tx.status == "confirmed"
14
14
  for input in inputs:
15
15
  address = input.address
16
16
  amount = 0
17
- address_tx_data.append(AddressTxData(tx_status=tx_status,
17
+ address_tx_data.append(AddressTxData(is_confirmed=is_confirmed,
18
18
  address=address,
19
19
  type=AddressTxType.INPUT,
20
20
  _amount=amount,
21
21
  tx_id=tx.txid))
22
22
  for output in outputs:
23
23
  amount = output.value
24
- address_tx_data.append(AddressTxData(tx_status=tx_status,
24
+ address_tx_data.append(AddressTxData(is_confirmed=is_confirmed,
25
25
  address=output.address,
26
26
  _amount=amount,
27
27
  type=AddressTxType.OUTPUT,
@@ -18,12 +18,19 @@ class BitcoinRPC:
18
18
  def get_transaction(self, txid: str) -> dict:
19
19
  return self.rpc_connection.getrawtransaction(txid, True)
20
20
 
21
+ def is_confirmed(self, txid: str) -> bool:
22
+ try:
23
+ self.rpc_connection.getmempoolentry(txid)
24
+ return False
25
+ except JSONRPCException as e:
26
+ return True
27
+
21
28
 
22
29
  if __name__ == '__main__':
23
30
  rpc = BitcoinRPC()
24
- txid = '8dc035d6816cf61074d12148777b28d28aa2f76b0f45ceafd310a85b1518aab8'
31
+ txid = '686d025f16d9f20353665a9d865e575e3e4d14214f6f7045149a17dd6bf0fac6'
25
32
  try:
26
- transaction = rpc.get_transaction(txid)
33
+ transaction = rpc.is_confirmed(txid)
27
34
  print(transaction)
28
35
  except JSONRPCException as e:
29
- print(f"An error occurred: {e}")
36
+ print(f"An error occurred: {e}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bitcoinwatcher
3
- Version: 2.3
3
+ Version: 2.5
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
@@ -220,7 +220,7 @@ License-File: LICENSE
220
220
  Requires-Dist: requests~=2.31.0
221
221
  Requires-Dist: certifi==2024.2.2
222
222
  Requires-Dist: charset-normalizer==3.3.2
223
- Requires-Dist: idna==3.6
223
+ Requires-Dist: idna==3.7
224
224
  Requires-Dist: pyzmq==25.1.2
225
225
  Requires-Dist: requests==2.31.0
226
226
  Requires-Dist: six==1.16.0
@@ -1,7 +1,7 @@
1
1
  requests~=2.31.0
2
2
  certifi==2024.2.2
3
3
  charset-normalizer==3.3.2
4
- idna==3.6
4
+ idna==3.7
5
5
  pyzmq==25.1.2
6
6
  requests==2.31.0
7
7
  six==1.16.0
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
 
6
6
  [project]
7
7
  name = "bitcoinwatcher"
8
- version = "2.3"
8
+ version = "2.5"
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"}]
@@ -26,7 +26,7 @@ dependencies = [
26
26
  "requests~=2.31.0",
27
27
  "certifi==2024.2.2",
28
28
  "charset-normalizer==3.3.2",
29
- "idna==3.6",
29
+ "idna==3.7",
30
30
  "pyzmq==25.1.2",
31
31
  "requests==2.31.0",
32
32
  "six==1.16.0",
File without changes
File without changes
File without changes