8000 Merge petertodd/python-bitcoinlib#300: Add HTTPS to supported RPC Pro… · petertodd/python-bitcoinlib@101bde5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 101bde5

Browse files
committed
Merge #300: Add HTTPS to supported RPC Proxy protocols
2fabb36 Add HTTPS to supported RPC Proxy protocols (mhh) Pull request description: Allows using HTTPS URLs when configuring a Bitcoin proxy: ```python import bitcoin.rpc btc_proxy = bitcoin.rpc.Proxy( service_url="https://<some-rpc-id>.btc.quiknode.pro/<api-secret>" ) ``` Top commit has no ACKs. Tree-SHA512: 190dd5ce30e4a31da81c5a06161739b10e34279458821fa0c4be952033d6aaf7a0380e3edecd49c6b9f0984f6d62488e9f5be1efe50f683bab5edca0c2d13752
2 parents 173a73e + 2fabb36 commit 101bde5

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

bitcoin/rpc.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,14 @@ def __init__(self,
205205
self.__service_url = service_url
206206
self.__url = urlparse.urlparse(service_url)
207207

208-
if self.__url.scheme not in ('http',):
208+
if self.__url.scheme not in ('http', 'https'):
209209
raise ValueError('Unsupported URL scheme %r' % self.__url.scheme)
210210

211211
if self.__url.port is None:
212-
port = httplib.HTTP_PORT
212+
if self.__url.scheme == 'https':
213+
port = httplib.HTTPS_PORT
214+
else:
215+
port = httplib.HTTP_PORT
213216
else:
214217
port = self.__url.port
215218
self.__id_count = 0
@@ -223,8 +226,12 @@ def __init__(self,
223226
if connection:
224227
self.__conn = connection
225228
else:
226-
self.__conn = httplib.HTTPConnection(self.__url.hostname, port=port,
227-
timeout=timeout)
229+
if self.__url.scheme == 'https':
230+
self.__conn = httplib.HTTPSConnection(self.__url.hostname, port=port,
231+
timeout=timeout)
232+
else:
233+
self.__conn = httplib.HTTPConnection(self.__url.hostname, port=port,
234+
timeout=timeout)
228235

229236
def _call(self, service_name, *args):
230237
self.__id_count += 1

0 commit comments

Comments
 (0)
0