bitcoinwatcher 2.4__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.
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/PKG-INFO +1 -1
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoin/address_listener/address_listener.py +3 -3
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoin/models/address_tx_data.py +1 -1
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoin/tx_extractors/bitcoin_rpc.py +5 -5
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoin/tx_extractors/default.py +3 -3
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoin/utils/bitcoin_rpc.py +10 -3
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoinwatcher.egg-info/PKG-INFO +1 -1
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/pyproject.toml +1 -1
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/LICENSE +0 -0
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/README.md +0 -0
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoin/__init__.py +0 -0
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoin/address_listener/__init__.py +0 -0
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoin/address_listener/simple_address_listener.py +0 -0
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoin/models/__init__.py +0 -0
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoin/tests/__init__.py +0 -0
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoin/tests/data/__init__.py +0 -0
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoin/tests/data/transactions.py +0 -0
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoin/tests/test_address_listener.py +0 -0
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoin/tests/test_bitcoin_rpc.py +0 -0
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoin/tests/test_bitcoin_utils.py +0 -0
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoin/tx_extractors/__init__.py +0 -0
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoin/tx_extractors/abstract_extractor.py +0 -0
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoin/tx_extractors/mempool.py +0 -0
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoin/tx_listener/__init__.py +0 -0
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoin/tx_listener/abstract_tx_listener.py +0 -0
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoin/tx_listener/zmq_listener.py +0 -0
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoin/utils/__init__.py +0 -0
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoin/utils/benchmark.py +0 -0
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoin/utils/bitcoin_utils.py +0 -0
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoin/utils/constants.py +0 -0
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoin/utils/inscription_utils.py +0 -0
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoinwatcher.egg-info/SOURCES.txt +0 -0
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoinwatcher.egg-info/dependency_links.txt +0 -0
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoinwatcher.egg-info/requires.txt +0 -0
- {bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoinwatcher.egg-info/top_level.txt +0 -0
- {bitcoinwatcher-2.4 → 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
|
+
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
|
@@ -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
|
-
|
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.
|
47
|
+
address_tx_data = self.rpc_tx_extractor.extract(tx)
|
48
48
|
except Exception as e:
|
49
|
-
print(f"Error in getting
|
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:
|
@@ -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,
|
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
|
-
|
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,
|
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(
|
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(
|
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
|
-
|
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(
|
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(
|
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 = '
|
31
|
+
txid = '686d025f16d9f20353665a9d865e575e3e4d14214f6f7045149a17dd6bf0fac6'
|
25
32
|
try:
|
26
|
-
transaction = rpc.
|
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
|
+
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
|
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
|
|
5
5
|
|
6
6
|
[project]
|
7
7
|
name = "bitcoinwatcher"
|
8
|
-
version = "2.
|
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"}]
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{bitcoinwatcher-2.4 → bitcoinwatcher-2.5}/bitcoin/address_listener/simple_address_listener.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|