Compare commits
5 Commits
lash/fix-d
...
lash/docs-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a94208c68
|
||
|
|
becd6744f6
|
||
|
|
06c6b2562a
|
||
|
|
1067c8494e
|
||
|
|
39478d9c3c
|
@@ -1,4 +1,6 @@
|
||||
- 0.0.5-pending
|
||||
- 0.0.14
|
||||
* Add option to skip ssl verification on rpc
|
||||
- 0.0.5
|
||||
* Move eth code to separate package
|
||||
- 0.0.4-unreleased
|
||||
* Add pack tx from already signed tx struct
|
||||
|
||||
@@ -186,10 +186,17 @@ class ChainSpec:
|
||||
return r
|
||||
|
||||
|
||||
def __str__(self):
|
||||
def as_string(self, skip_optional=False):
|
||||
s = '{}:{}:{}'.format(self.o['arch'], self.o['fork'], self.o['network_id'])
|
||||
if skip_optional:
|
||||
return s
|
||||
|
||||
if self.o.get('common_name'):
|
||||
s += ':' + self.o['common_name']
|
||||
if self.o.get('custom'):
|
||||
s += ':' + ':'.join(self.o['custom'])
|
||||
return s
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return self.as_string()
|
||||
|
||||
@@ -144,7 +144,7 @@ class ArgumentParser(argparse.ArgumentParser):
|
||||
if arg_flags & Flag.CONFIG:
|
||||
self.add_argument('-c', '--config', type=str, default=env.get('CONFINI_DIR'), help='Configuration directory')
|
||||
self.add_argument('-n', '--namespace', type=str, help='Configuration namespace')
|
||||
self.add_argument('--dumpconfig', action='store_true', help='Output configuration and quit. Use with --raw to omit values and output schema only.')
|
||||
self.add_argument('--dumpconfig', type=str, choices=['env', 'ini'], help='Output configuration and quit. Use with --raw to omit values and output schema only.')
|
||||
if arg_flags & Flag.WAIT:
|
||||
self.add_argument('-w', action='store_true', help='Wait for the last transaction to be confirmed')
|
||||
self.add_argument('-ww', action='store_true', help='Wait for every transaction to be confirmed')
|
||||
|
||||
@@ -239,18 +239,26 @@ class Config(confini.Config):
|
||||
logg.debug('added {} to {}'.format(r, v))
|
||||
|
||||
if getattr(args, 'dumpconfig', None):
|
||||
config_keys = config.all()
|
||||
with_values = not config.get('_RAW')
|
||||
for k in config_keys:
|
||||
if k[0] == '_':
|
||||
continue
|
||||
s = k + '='
|
||||
if with_values:
|
||||
v = config.get(k)
|
||||
if v != None:
|
||||
s += str(v)
|
||||
s += '\n'
|
||||
dump_writer.write(s)
|
||||
if args.dumpconfig == 'ini':
|
||||
from confini.export import ConfigExporter
|
||||
exporter = ConfigExporter(config, target=sys.stdout, doc=False)
|
||||
exporter.export(exclude_sections=['config'])
|
||||
elif args.dumpconfig == 'env':
|
||||
from confini.env import export_env
|
||||
export_env(config)
|
||||
|
||||
# config_keys = config.all()
|
||||
# with_values = not config.get('_RAW')
|
||||
# for k in config_keys:
|
||||
# if k[0] == '_':
|
||||
# continue
|
||||
# s = k + '='
|
||||
# if with_values:
|
||||
# v = config.get(k)
|
||||
# if v != None:
|
||||
# s += str(v)
|
||||
# s += '\n'
|
||||
# dump_writer.write(s)
|
||||
sys.exit(0)
|
||||
|
||||
if load_callback != None:
|
||||
|
||||
@@ -61,7 +61,7 @@ class Rpc:
|
||||
self.id_generator = IntSequenceGenerator()
|
||||
|
||||
self.chain_spec = config.get('CHAIN_SPEC')
|
||||
self.conn = self.constructor(url=config.get('RPC_PROVIDER'), chain_spec=self.chain_spec, auth=auth)
|
||||
self.conn = self.constructor(url=config.get('RPC_PROVIDER'), chain_spec=self.chain_spec, auth=auth, verify_identity=config.true('RPC_VERIFY'))
|
||||
|
||||
return self.conn
|
||||
|
||||
|
||||
@@ -102,10 +102,13 @@ class RPCConnection:
|
||||
}
|
||||
__constructors_for_chains = {}
|
||||
|
||||
def __init__(self, url=None, chain_spec=None, auth=None):
|
||||
def __init__(self, url=None, chain_spec=None, auth=None, verify_identity=True):
|
||||
self.chain_spec = chain_spec
|
||||
self.location = None
|
||||
self.basic = None
|
||||
self.verify_identity = verify_identity
|
||||
if not self.verify_identity:
|
||||
logg.warning('RPC host identity verification is OFF. Beware, you will be easy to cheat')
|
||||
if url == None:
|
||||
return
|
||||
self.auth = auth
|
||||
@@ -287,6 +290,11 @@ class JSONRPCHTTPConnection(HTTPConnection):
|
||||
:returns: Result value part of JSON RPC response
|
||||
:todo: Invalid response exception from invalid json response
|
||||
"""
|
||||
ssl_ctx = None
|
||||
if not self.verify_identity:
|
||||
import ssl
|
||||
ssl_ctx = ssl.SSLContext()
|
||||
ssl_ctx.verify_mode = ssl.CERT_NONE
|
||||
req = Request(
|
||||
self.location,
|
||||
method='POST',
|
||||
@@ -313,7 +321,11 @@ class JSONRPCHTTPConnection(HTTPConnection):
|
||||
install_opener(ho)
|
||||
|
||||
try:
|
||||
r = urlopen(req, data=data.encode('utf-8'))
|
||||
r = urlopen(
|
||||
req,
|
||||
data=data.encode('utf-8'),
|
||||
context=ssl_ctx,
|
||||
)
|
||||
except URLError as e:
|
||||
raise RPCException(e)
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ auth =
|
||||
credentials =
|
||||
dialect = default
|
||||
scheme = http
|
||||
verify = 1
|
||||
|
||||
[chain]
|
||||
spec =
|
||||
|
||||
29
setup.cfg
29
setup.cfg
@@ -1,10 +1,16 @@
|
||||
; Config::Simple 4.59
|
||||
; Mon Nov 8 05:19:17 2021
|
||||
|
||||
[metadata]
|
||||
name = chainlib
|
||||
version = 0.0.10
|
||||
description = Generic blockchain access library and tooling
|
||||
author = Louis Holbrook
|
||||
author_email = dev@holbrook.no
|
||||
url = https://gitlab.com/chaintools/chainlib
|
||||
name=chainlib
|
||||
license=WTFPL2
|
||||
author_email=dev@holbrook.no
|
||||
description=Generic blockchain access library and tooling
|
||||
version=0.0.14
|
||||
url=https://gitlab.com/chaintools/chainlib
|
||||
author=Louis Holbrook
|
||||
|
||||
|
||||
keywords =
|
||||
dlt
|
||||
blockchain
|
||||
@@ -18,14 +24,3 @@ classifiers =
|
||||
Intended Audience :: Developers
|
||||
License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
|
||||
Topic :: Internet
|
||||
license = GPL3
|
||||
licence_files =
|
||||
LICENSE.txt
|
||||
|
||||
|
||||
[options]
|
||||
python_requires = >= 3.6
|
||||
include_package_data = True
|
||||
packages =
|
||||
chainlib
|
||||
chainlib.cli
|
||||
|
||||
Reference in New Issue
Block a user