Add tor-client support (#15)

* Add tor-client support

* Class Method
This commit is contained in:
Amp 2020-10-03 09:51:51 -05:00 committed by GitHub
parent 240ec70845
commit 1c695e19c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -142,6 +142,24 @@ class BTCPayClient:
token = client.pair_client(code)
return BTCPayClient(host=host, pem=pem, tokens=token)
@classmethod
def create_tor_client(cls, code, host, proxy='socks5://127.0.0.1:9050'):
""" Useful for .onion services, the `proxy` input assumes the default
proxy header
"""
pem = crypto.generate_privkey()
client = BTCPayClient(host=host, pem=pem)
client.s.proxies = {
'http': proxy,
'https': proxy}
token = client.pair_client(code)
final_client = BTCPayClient(host=host, pem=pem, tokens=token)
final_client.s.proxies = {
'http': proxy,
'https': proxy}
return final_client
def __repr__(self):
return '{}({})'.format(
type(self).__name__,