easybitcoinrpc 1.1.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.
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2018 The Python Packaging Authority
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ recursive-include tests *.py
@@ -0,0 +1,221 @@
1
+ Metadata-Version: 2.4
2
+ Name: easybitcoinrpc
3
+ Version: 1.1.1
4
+ Summary: Simple and easy to use library for Bitcoin RPC
5
+ Author-email: Dorian Kucharski <dorian.kucharski1@gmail.com>
6
+ License: Copyright (c) 2018 The Python Packaging Authority
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in all
16
+ copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.
25
+ Project-URL: Homepage, https://github.com/DorianKucharski/easybitcoinrpc
26
+ Classifier: Programming Language :: Python :: 3
27
+ Classifier: License :: OSI Approved :: MIT License
28
+ Classifier: Operating System :: OS Independent
29
+ Requires-Python: >=3.6
30
+ Description-Content-Type: text/markdown
31
+ License-File: LICENSE
32
+ Requires-Dist: python-bitcoinrpc
33
+ Requires-Dist: cryptocompare
34
+ Dynamic: license-file
35
+
36
+ # Easy Bitcoin RPC
37
+
38
+ Easy Bitcoin RPC is a simple and easy to use Python library for Bitcoin RPC
39
+
40
+ ## Installation
41
+
42
+ Use the package manager [pip](https://pip.pypa.io/en/stable/) to install.
43
+
44
+ ```bash
45
+ pip install easybitcoinrpc
46
+ ```
47
+
48
+ ## Usage
49
+
50
+ ### Connecting
51
+
52
+ ```python
53
+ from easybitcoinrpc import RPC
54
+
55
+ # RPC() returns connection object
56
+
57
+ rpc = RPC() # defaults: ip=127.0.0.1, port="8332", user="user", password="password", wallet=None
58
+
59
+ rpc = RPC(user="rpcuser", password="rpcpassword")
60
+
61
+ rpc = RPC(ip="192.168.1.1", port=9999, user="rpcuser", password="rpcpassword")
62
+
63
+ rpc = RPC(wallet="Wallet")
64
+
65
+ ```
66
+
67
+ Specifing wallet when connection is made is prefered method to get access to wallet, loading wallet after connecting sometimes dosn't work.
68
+
69
+ ### RPC methods
70
+
71
+ RPC object has methods for all Bitcoins RPC calls and those methods are seperated into sections as on [Bitcoin RPC API Reference](https://developer.bitcoin.org/reference/rpc/)
72
+
73
+
74
+ ```python
75
+ from easybitcoinrpc import RPC
76
+ rpc = RPC()
77
+
78
+ rpc.blockchain # returns object which has all methods from blockchain category
79
+ rpc.wallet # returns object which has all methods from wallet category
80
+ rpc.util # returns object which has all methods from util category
81
+ rpc.mining # returns object which has all methods from mining category
82
+ rpc.network # returns object which has all methods from network category
83
+ rpc.generating # returns object which has all methods from generating category
84
+ rpc.control # returns object which has all methods from control category
85
+ rpc.transactions # returns object which has all methods from transactions category
86
+
87
+ rpc.batch(["getbestblockhash"]) # batch method also can be used to made requests
88
+ rpc.batch(["getblock", 1000]) # parameters are passed in list, where first parameter is RPC command
89
+ ```
90
+
91
+ All methods have documentation copied from [Bitcoin RPC API Reference](https://developer.bitcoin.org/reference/rpc/),
92
+ they also have parameters specified with their types and their default values.
93
+
94
+ ### Data
95
+ Methods which implements blocks and transactions related calls, returns custom data objects like Block, Transaction, Vin, ScriptSig and etc.
96
+
97
+ ```python
98
+ from easybitcoinrpc import RPC
99
+ rpc = RPC()
100
+
101
+ block = rpc.blockchain.get_best_block()
102
+ transactions = block.get_transactions()
103
+ vins = transactions[0].get_vins()
104
+ script_sig = vins[0].get_script_sig()
105
+ r = script_sig.get_r()
106
+ ```
107
+
108
+ Those data objects have getters for all values.
109
+
110
+ ```python
111
+ from easybitcoinrpc import RPC
112
+ rpc = RPC()
113
+
114
+ block = rpc.blockchain.get_best_block()
115
+
116
+ block.get_time()
117
+ block.get_previous_block()
118
+ block.get_hash()
119
+ ```
120
+
121
+ Objects have special methods, not provided by Bitcoin RPC, like for example checking if transaction is
122
+ segwit or getting ECDSA values.
123
+
124
+
125
+ ```python
126
+ from easybitcoinrpc import RPC
127
+ rpc = RPC()
128
+
129
+ block = rpc.blockchain.get_best_block()
130
+
131
+ for t in block.get_transactions():
132
+ if t.is_segwit():
133
+ print(t.get_txid())
134
+ else:
135
+ for v in t.get_vins():
136
+ print(t.get_txid(), v.get_sequence(), v.get_script_sig().get_r())
137
+ ```
138
+
139
+ Objects have overridden str methods for better visualisation of data.
140
+
141
+ ```python
142
+ from easybitcoinrpc import RPC
143
+ rpc = RPC()
144
+
145
+ block = rpc.blockchain.get_best_block()
146
+ print(block)
147
+
148
+ # Returns
149
+ # hash: 0000000000000000000a307d7eefb6ddebdd8a2737ad627f8f6d9964aeb2c29f
150
+ # confirmations: 1
151
+ # strippedsize: 977645
152
+ # size: 1066449
153
+ # weight: 3999384
154
+ # height: 669376
155
+ # version: 1073733632
156
+ # versionHex: 3fffe000
157
+ # merkleroot: 24f11777dbd32dd74ea0040dce9a12765be2683b19e05d36cd3317f0b8d1a36c
158
+ # time: 1612612936
159
+ # mediantime: 1612611893
160
+ # nonce: 1200025529
161
+ # bits: 170d21b9
162
+ # difficulty: 21434395961348.92
163
+ # chainwork: 00000000000000000000000000000000000000001910b793231a7d36bec2cf03
164
+ # nTx: 537
165
+ # previousblockhash: 00000000000000000004c1761fcc1799f11362dfdcfa3ad4ff4dbb2557dda85a
166
+ ```
167
+
168
+ Transaction object has TransactionSummary object for presenting transaction like on blockchain.com.
169
+ ```python
170
+ from easybitcoinrpc import RPC
171
+ rpc = RPC()
172
+
173
+ t = rpc.transactions.get_transaction('9c38bd04960abf7a77d1ce132f9ae62b37fd4509954f87b19b408141fc0cdcd6')
174
+ print(t.get_summary())
175
+
176
+ # txid: 9c38bd04960abf7a77d1ce132f9ae62b37fd4509954f87b19b408141fc0cdcd6
177
+ # hash: 6fac396e18cc20e78c9122e97c7a20e771cf754592c23cb957c9ea86a0167cd3
178
+ # inputs:
179
+ # 37Dynkc7bEyGkUSSWCDzKDNR2kgan2SHBw 0.00500000
180
+ # outputs:
181
+ # 1CrwSmssxrrXEzhx3xkK3rkYFKMoMRJkkG 0.00100000
182
+ # 35WVXNKNswS5poxZdmbrKqPktg14iqFRNS 0.00383133
183
+ # total input: 0.00500000
184
+ # total output: 0.00483133
185
+ # fee: 0.00016867
186
+ # value now: $195.3267102094
187
+ # confirmed: True
188
+ # coinbase: False
189
+ # segwit: True
190
+ # size: 249
191
+ # vsize: 168
192
+ # weight: 669
193
+ # locktime: 0
194
+ # hex: 01000000000101df3088baec96e27ad7a597d13bcb3be0e3308824a112f1b4ced5aa1471de1c5
195
+ # 5050000001716001461f566997fabed1fccda69b37dd6ad046601d00cffffffff02a08601000000000
196
+ # 01976a914821b36b01b37d67dfb2cd405f41c9fe552ca22eb88ac9dd805000000000017a91429e2f79
197
+ # c546d089c7972da1a9754b13d0d22e164870247304402202100113c72a11389c62d8bf2a6fa612b24e
198
+ # 8582a94ad39517ab3c13ced265740022000c0a037bb72eaf447906760bb52bc4f0913e2088b4374bf5
199
+ # f1596584edcb10b0121020e6508ab2d6bcfcbce1cf1317429e5c37aa42a975319827a85fa2e0c0088f
200
+ # 62600000000
201
+ # blockhash: 000000000000000000094245acb071335f547ce5a1dba9ee47c2639d0b6d52a3
202
+ # block_height: 669377
203
+ # confirmations: 1
204
+ # time: 1612613544
205
+ # blocktime: 1612613544
206
+ # date: 2021-02-06 13:12:24
207
+
208
+ t.get_summary().get_date()
209
+ t.get_summary().get_usd_value()
210
+ t.get_summary().get_block_height()
211
+ t.get_summary().get_total_output()
212
+ ```
213
+
214
+
215
+ ## Contributing
216
+ Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
217
+
218
+ Please make sure to update tests as appropriate.
219
+
220
+ ## License
221
+ [MIT](https://choosealicense.com/licenses/mit/)
@@ -0,0 +1,186 @@
1
+ # Easy Bitcoin RPC
2
+
3
+ Easy Bitcoin RPC is a simple and easy to use Python library for Bitcoin RPC
4
+
5
+ ## Installation
6
+
7
+ Use the package manager [pip](https://pip.pypa.io/en/stable/) to install.
8
+
9
+ ```bash
10
+ pip install easybitcoinrpc
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ### Connecting
16
+
17
+ ```python
18
+ from easybitcoinrpc import RPC
19
+
20
+ # RPC() returns connection object
21
+
22
+ rpc = RPC() # defaults: ip=127.0.0.1, port="8332", user="user", password="password", wallet=None
23
+
24
+ rpc = RPC(user="rpcuser", password="rpcpassword")
25
+
26
+ rpc = RPC(ip="192.168.1.1", port=9999, user="rpcuser", password="rpcpassword")
27
+
28
+ rpc = RPC(wallet="Wallet")
29
+
30
+ ```
31
+
32
+ Specifing wallet when connection is made is prefered method to get access to wallet, loading wallet after connecting sometimes dosn't work.
33
+
34
+ ### RPC methods
35
+
36
+ RPC object has methods for all Bitcoins RPC calls and those methods are seperated into sections as on [Bitcoin RPC API Reference](https://developer.bitcoin.org/reference/rpc/)
37
+
38
+
39
+ ```python
40
+ from easybitcoinrpc import RPC
41
+ rpc = RPC()
42
+
43
+ rpc.blockchain # returns object which has all methods from blockchain category
44
+ rpc.wallet # returns object which has all methods from wallet category
45
+ rpc.util # returns object which has all methods from util category
46
+ rpc.mining # returns object which has all methods from mining category
47
+ rpc.network # returns object which has all methods from network category
48
+ rpc.generating # returns object which has all methods from generating category
49
+ rpc.control # returns object which has all methods from control category
50
+ rpc.transactions # returns object which has all methods from transactions category
51
+
52
+ rpc.batch(["getbestblockhash"]) # batch method also can be used to made requests
53
+ rpc.batch(["getblock", 1000]) # parameters are passed in list, where first parameter is RPC command
54
+ ```
55
+
56
+ All methods have documentation copied from [Bitcoin RPC API Reference](https://developer.bitcoin.org/reference/rpc/),
57
+ they also have parameters specified with their types and their default values.
58
+
59
+ ### Data
60
+ Methods which implements blocks and transactions related calls, returns custom data objects like Block, Transaction, Vin, ScriptSig and etc.
61
+
62
+ ```python
63
+ from easybitcoinrpc import RPC
64
+ rpc = RPC()
65
+
66
+ block = rpc.blockchain.get_best_block()
67
+ transactions = block.get_transactions()
68
+ vins = transactions[0].get_vins()
69
+ script_sig = vins[0].get_script_sig()
70
+ r = script_sig.get_r()
71
+ ```
72
+
73
+ Those data objects have getters for all values.
74
+
75
+ ```python
76
+ from easybitcoinrpc import RPC
77
+ rpc = RPC()
78
+
79
+ block = rpc.blockchain.get_best_block()
80
+
81
+ block.get_time()
82
+ block.get_previous_block()
83
+ block.get_hash()
84
+ ```
85
+
86
+ Objects have special methods, not provided by Bitcoin RPC, like for example checking if transaction is
87
+ segwit or getting ECDSA values.
88
+
89
+
90
+ ```python
91
+ from easybitcoinrpc import RPC
92
+ rpc = RPC()
93
+
94
+ block = rpc.blockchain.get_best_block()
95
+
96
+ for t in block.get_transactions():
97
+ if t.is_segwit():
98
+ print(t.get_txid())
99
+ else:
100
+ for v in t.get_vins():
101
+ print(t.get_txid(), v.get_sequence(), v.get_script_sig().get_r())
102
+ ```
103
+
104
+ Objects have overridden str methods for better visualisation of data.
105
+
106
+ ```python
107
+ from easybitcoinrpc import RPC
108
+ rpc = RPC()
109
+
110
+ block = rpc.blockchain.get_best_block()
111
+ print(block)
112
+
113
+ # Returns
114
+ # hash: 0000000000000000000a307d7eefb6ddebdd8a2737ad627f8f6d9964aeb2c29f
115
+ # confirmations: 1
116
+ # strippedsize: 977645
117
+ # size: 1066449
118
+ # weight: 3999384
119
+ # height: 669376
120
+ # version: 1073733632
121
+ # versionHex: 3fffe000
122
+ # merkleroot: 24f11777dbd32dd74ea0040dce9a12765be2683b19e05d36cd3317f0b8d1a36c
123
+ # time: 1612612936
124
+ # mediantime: 1612611893
125
+ # nonce: 1200025529
126
+ # bits: 170d21b9
127
+ # difficulty: 21434395961348.92
128
+ # chainwork: 00000000000000000000000000000000000000001910b793231a7d36bec2cf03
129
+ # nTx: 537
130
+ # previousblockhash: 00000000000000000004c1761fcc1799f11362dfdcfa3ad4ff4dbb2557dda85a
131
+ ```
132
+
133
+ Transaction object has TransactionSummary object for presenting transaction like on blockchain.com.
134
+ ```python
135
+ from easybitcoinrpc import RPC
136
+ rpc = RPC()
137
+
138
+ t = rpc.transactions.get_transaction('9c38bd04960abf7a77d1ce132f9ae62b37fd4509954f87b19b408141fc0cdcd6')
139
+ print(t.get_summary())
140
+
141
+ # txid: 9c38bd04960abf7a77d1ce132f9ae62b37fd4509954f87b19b408141fc0cdcd6
142
+ # hash: 6fac396e18cc20e78c9122e97c7a20e771cf754592c23cb957c9ea86a0167cd3
143
+ # inputs:
144
+ # 37Dynkc7bEyGkUSSWCDzKDNR2kgan2SHBw 0.00500000
145
+ # outputs:
146
+ # 1CrwSmssxrrXEzhx3xkK3rkYFKMoMRJkkG 0.00100000
147
+ # 35WVXNKNswS5poxZdmbrKqPktg14iqFRNS 0.00383133
148
+ # total input: 0.00500000
149
+ # total output: 0.00483133
150
+ # fee: 0.00016867
151
+ # value now: $195.3267102094
152
+ # confirmed: True
153
+ # coinbase: False
154
+ # segwit: True
155
+ # size: 249
156
+ # vsize: 168
157
+ # weight: 669
158
+ # locktime: 0
159
+ # hex: 01000000000101df3088baec96e27ad7a597d13bcb3be0e3308824a112f1b4ced5aa1471de1c5
160
+ # 5050000001716001461f566997fabed1fccda69b37dd6ad046601d00cffffffff02a08601000000000
161
+ # 01976a914821b36b01b37d67dfb2cd405f41c9fe552ca22eb88ac9dd805000000000017a91429e2f79
162
+ # c546d089c7972da1a9754b13d0d22e164870247304402202100113c72a11389c62d8bf2a6fa612b24e
163
+ # 8582a94ad39517ab3c13ced265740022000c0a037bb72eaf447906760bb52bc4f0913e2088b4374bf5
164
+ # f1596584edcb10b0121020e6508ab2d6bcfcbce1cf1317429e5c37aa42a975319827a85fa2e0c0088f
165
+ # 62600000000
166
+ # blockhash: 000000000000000000094245acb071335f547ce5a1dba9ee47c2639d0b6d52a3
167
+ # block_height: 669377
168
+ # confirmations: 1
169
+ # time: 1612613544
170
+ # blocktime: 1612613544
171
+ # date: 2021-02-06 13:12:24
172
+
173
+ t.get_summary().get_date()
174
+ t.get_summary().get_usd_value()
175
+ t.get_summary().get_block_height()
176
+ t.get_summary().get_total_output()
177
+ ```
178
+
179
+
180
+ ## Contributing
181
+ Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
182
+
183
+ Please make sure to update tests as appropriate.
184
+
185
+ ## License
186
+ [MIT](https://choosealicense.com/licenses/mit/)
@@ -0,0 +1,2 @@
1
+ from easybitcoinrpc.rpc import RPC
2
+ from easybitcoinrpc.data import Block, Transaction, TransactionSummary