proto.btc.rpc.local: rewrite segwit_is_active()
This commit is contained in:
parent
3555ef3e54
commit
96d2c1c36c
2 changed files with 11 additions and 22 deletions
|
|
@ -1 +1 @@
|
|||
16.3.0dev21
|
||||
16.3.0dev22
|
||||
|
|
|
|||
|
|
@ -381,27 +381,16 @@ class BitcoinRPCClient(RPCClient, metaclass=AsyncInit):
|
|||
def info(self, info_id):
|
||||
|
||||
def segwit_is_active():
|
||||
|
||||
if 'deployment_info' in self.caps:
|
||||
return (
|
||||
self.cached['deploymentinfo']['deployments']['segwit']['active']
|
||||
or (self.cfg.test_suite and self.chain != 'regtest'))
|
||||
|
||||
d = self.cached['blockchaininfo']
|
||||
|
||||
try:
|
||||
if d['softforks']['segwit']['active'] is True:
|
||||
return True
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
try:
|
||||
if d['bip9_softforks']['segwit']['status'] == 'active':
|
||||
return True
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
return self.cfg.test_suite and self.chain != 'regtest'
|
||||
for test in [
|
||||
lambda: self.cfg.test_suite and self.chain != 'regtest',
|
||||
lambda: self.cached['deploymentinfo']['deployments']['segwit']['active'],
|
||||
lambda: self.cached['blockchaininfo']['softforks']['segwit']['active'],
|
||||
lambda: self.cached['blockchaininfo']['bip9_softforks']['segwit']['status'] == 'active']:
|
||||
try:
|
||||
if test():
|
||||
return True
|
||||
except (TypeError, KeyError):
|
||||
pass
|
||||
|
||||
return locals()[info_id]()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue