proto.btc.tx.online.Signed.sign(): cleanup error handling
This commit is contained in:
parent
2fa3d97c54
commit
1c5e8ad581
1 changed files with 26 additions and 29 deletions
|
|
@ -42,42 +42,39 @@ class OnlineSigned(Signed,TxBase.OnlineSigned):
|
|||
self.confirm_send()
|
||||
|
||||
if self.cfg.bogus_send:
|
||||
ret = None
|
||||
m = 'BOGUS transaction NOT sent: {}'
|
||||
else:
|
||||
m = 'Transaction sent: {}'
|
||||
try:
|
||||
ret = await self.rpc.call('sendrawtransaction',self.serialized)
|
||||
except Exception as e:
|
||||
errmsg = str(e)
|
||||
ret = False
|
||||
|
||||
if ret is False: # TODO: test send errors
|
||||
if errmsg.count('Signature must use SIGHASH_FORKID'):
|
||||
m = ('The Aug. 1 2017 UAHF has activated on this chain.\n'
|
||||
+ 'Re-run the script with the --coin=bch option.' )
|
||||
elif errmsg.count('Illegal use of SIGHASH_FORKID'):
|
||||
m = ('The Aug. 1 2017 UAHF is not yet active on this chain.\n'
|
||||
+ 'Re-run the script without the --coin=bch option.' )
|
||||
elif errmsg.count('64: non-final'):
|
||||
m = "Transaction with nLockTime {!r} can't be included in this block!".format(
|
||||
self.strfmt_locktime(self.get_serialized_locktime()) )
|
||||
if errmsg.count('Signature must use SIGHASH_FORKID'):
|
||||
m = (
|
||||
'The Aug. 1 2017 UAHF has activated on this chain.\n'
|
||||
'Re-run the script with the --coin=bch option.')
|
||||
elif errmsg.count('Illegal use of SIGHASH_FORKID'):
|
||||
m = (
|
||||
'The Aug. 1 2017 UAHF is not yet active on this chain.\n'
|
||||
'Re-run the script without the --coin=bch option.')
|
||||
elif errmsg.count('64: non-final'):
|
||||
m = "Transaction with nLockTime {!r} can't be included in this block!".format(
|
||||
self.strfmt_locktime(self.get_serialized_locktime()))
|
||||
else:
|
||||
m = errmsg
|
||||
ymsg(m)
|
||||
rmsg(f'Send of MMGen transaction {self.txid} failed')
|
||||
if exit_on_fail:
|
||||
sys.exit(1)
|
||||
return False
|
||||
else:
|
||||
m = errmsg
|
||||
ymsg(m)
|
||||
rmsg(f'Send of MMGen transaction {self.txid} failed')
|
||||
if exit_on_fail:
|
||||
sys.exit(1)
|
||||
return False
|
||||
else:
|
||||
if self.cfg.bogus_send:
|
||||
m = 'BOGUS transaction NOT sent: {}'
|
||||
else:
|
||||
m = 'Transaction sent: {}'
|
||||
assert ret == self.coin_txid, 'txid mismatch (after sending)'
|
||||
msg(m.format(self.coin_txid.hl()))
|
||||
self.add_timestamp()
|
||||
self.add_blockcount()
|
||||
self.desc = 'sent transaction'
|
||||
return True
|
||||
|
||||
msg(m.format(self.coin_txid.hl()))
|
||||
self.add_timestamp()
|
||||
self.add_blockcount()
|
||||
self.desc = 'sent transaction'
|
||||
return True
|
||||
|
||||
def print_contract_addr(self):
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue