mmgen-{swaptxcreate,swaptxdo,txsend}: support --proxy=env param

Allow use of the *_PROXY environment vars when connecting to the THORNode
and Etherscan HTTPS servers
This commit is contained in:
The MMGen Project 2025-05-10 10:43:28 +00:00
commit 5dd358a851
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
6 changed files with 16 additions and 6 deletions

View file

@ -1 +1 @@
15.1.dev35
15.1.dev36

View file

@ -80,7 +80,9 @@ opts_data = {
-s -S, --list-assets List available swap assets
-- -v, --verbose Produce more verbose output
b- -V, --vsize-adj= f Adjust transaction's estimated vsize by factor 'f'
-s -x, --proxy=P Fetch the swap quote via SOCKS5 proxy P (host:port)
-s -x, --proxy=P Fetch the swap quote via SOCKS5 proxy P (host:port).
+ Use special value env to honor *_PROXY environment
+ vars instead.
-- -y, --yes Answer 'yes' to prompts, suppress non-essential output
e- -X, --cached-balances Use cached balances
""",

View file

@ -106,7 +106,9 @@ opts_data = {
-- -v, --verbose Produce more verbose output
b- -V, --vsize-adj= f Adjust transaction's estimated vsize by factor 'f'
e- -w, --wait Wait for transaction confirmation
-s -x, --proxy=P Fetch the swap quote via SOCKS5 proxy P (host:port)
-s -x, --proxy=P Fetch the swap quote via SOCKS5 proxy P (host:port).
+ Use special value env to honor *_PROXY environment
+ vars instead.
e- -X, --cached-balances Use cached balances
-- -y, --yes Answer 'yes' to prompts, suppress non-essential output
-- -z, --show-hash-presets Show information on available hash presets

View file

@ -61,7 +61,9 @@ opts_data = {
begins with one.
-v, --verbose Be more verbose
-w, --wait Wait for transaction confirmation (Ethereum only)
-x, --proxy=P Connect to TX proxy via SOCKS5 proxy P (host:port)
-x, --proxy=P Connect to TX proxy via SOCKS5h proxy P (host:port).
Use special value env to honor *_PROXY environment vars
instead.
-y, --yes Answer 'yes' to prompts, suppress non-essential output
"""
},

View file

@ -43,7 +43,9 @@ class ThornodeRPCClient:
self.session = requests.Session()
self.session.trust_env = False # ignore *_PROXY environment vars
self.session.headers = self.http_hdrs
if self.cfg.proxy:
if self.cfg.proxy == 'env':
self.session.trust_env = True
elif self.cfg.proxy:
self.session.proxies.update({
'http': f'socks5h://{self.cfg.proxy}',
'https': f'socks5h://{self.cfg.proxy}'

View file

@ -30,7 +30,9 @@ class TxProxyClient:
self.session = requests.Session()
self.session.trust_env = False # ignore *_PROXY environment vars
self.session.headers = self.http_hdrs
if self.cfg.proxy:
if self.cfg.proxy == 'env':
self.session.trust_env = True
elif self.cfg.proxy:
self.session.proxies.update({
'http': f'socks5h://{self.cfg.proxy}',
'https': f'socks5h://{self.cfg.proxy}'