From 52d26ded5ff2b86d203d87113b7e47235e923c98 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Mon, 28 Sep 2020 09:04:13 +0000 Subject: [PATCH] rpc.py: support Bitcoin Core v0.20.1; tx.py: minor fix, cleanups --- mmgen/rpc.py | 18 ++++++++++++++---- mmgen/tx.py | 13 +++++++------ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/mmgen/rpc.py b/mmgen/rpc.py index 98c474f3..4d5b8aca 100755 --- a/mmgen/rpc.py +++ b/mmgen/rpc.py @@ -425,12 +425,22 @@ class BitcoinRPCClient(RPCClient,metaclass=aInitMeta): d = self.cached['blockchaininfo'] if d['chain'] == 'regtest': return True - if ( 'bip9_softforks' in d - and 'segwit' in d['bip9_softforks'] - and d['bip9_softforks']['segwit']['status'] == 'active'): - return True + + try: + if d['softforks']['segwit']['active'] == True: + return True + except: + pass + + try: + if d['bip9_softforks']['segwit']['status'] == 'active': + return True + except: + pass + if g.test_suite: return True + return False return locals()[info_id]() diff --git a/mmgen/tx.py b/mmgen/tx.py index fe8fbc1d..54aa5503 100755 --- a/mmgen/tx.py +++ b/mmgen/tx.py @@ -704,7 +704,7 @@ class MMGenTX: die(2,( 'ERROR: No change output specified', self.msg_no_change_output.format(self.dcoin))[len(self.outputs) == 1]) - if not self.rpc.info('segwit_is_active') and self.has_segwit_outputs(): + if self.has_segwit_outputs() and not self.rpc.info('segwit_is_active'): rdie(2,f'{g.proj_name} Segwit address requested on the command line, ' + 'but Segwit is not active on this chain') @@ -1399,9 +1399,10 @@ class MMGenTX: self.check_pubkey_scripts() self.check_hex_tx_matches_mmgen_tx(DeserializedTX(self.proto,self.hex)) - if self.has_segwit_outputs() and not self.rpc.info('segwit_is_active') and not g.bogus_send: - die(2,'Transaction has Segwit outputs, but this blockchain does not support Segwit' - + ' at the current height') + if not g.bogus_send: + if self.has_segwit_outputs() and not self.rpc.info('segwit_is_active'): + die(2,'Transaction has Segwit outputs, but this blockchain does not support Segwit' + + ' at the current height') if self.get_fee() > self.proto.max_tx_fee: die(2,'Transaction fee ({}) greater than {} max_tx_fee ({} {})!'.format( @@ -1421,10 +1422,10 @@ class MMGenTX: try: ret = await self.rpc.call('sendrawtransaction',self.hex) except Exception as e: + errmsg = e ret = False - if ret == False: - errmsg = e + if ret == False: # TODO: test send errors if 'Signature must use SIGHASH_FORKID' in errmsg: m = ('The Aug. 1 2017 UAHF has activated on this chain.\n' + 'Re-run the script with the --coin=bch option.' )