|
@@ -1,7 +1,7 @@
|
|
|
#!/usr/bin/env python3
|
|
|
#
|
|
|
# mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
|
|
|
-# Copyright (C)2013-2020 The MMGen Project <mmgen@tuta.io>
|
|
|
+# Copyright (C)2013-2021 The MMGen Project <mmgen@tuta.io>
|
|
|
#
|
|
|
# This program is free software: you can redistribute it and/or modify it under
|
|
|
# the terms of the GNU General Public License as published by the Free Software
|
|
@@ -28,7 +28,7 @@ from decimal import Decimal
|
|
|
opts_data = {
|
|
|
'sets': [('raw_miner_info',True,'miner_info',True)],
|
|
|
'text': {
|
|
|
- 'desc': 'Display information about or find a transaction within a range of blocks',
|
|
|
+ 'desc': 'Display information about a range of blocks',
|
|
|
'usage': '[opts] +<last n blocks>|<block num>|<block num range>',
|
|
|
'options': """
|
|
|
-h, --help Print this help message
|
|
@@ -39,7 +39,6 @@ opts_data = {
|
|
|
-o, --fields= Display the specified fields
|
|
|
-s, --summary Print the summary only
|
|
|
-S, --no-summary Don't print the summary
|
|
|
--t, --transaction=t Search for transaction 't' in specified block range
|
|
|
|
|
|
If no block number is specified, the current block is assumed
|
|
|
"""
|
|
@@ -272,37 +271,6 @@ class BlocksInfoOverview(BlocksInfo):
|
|
|
self.sum_fs.format('Avg conf time:', f'{ac//60}:{ac%60:02}')
|
|
|
)
|
|
|
|
|
|
-class BlocksInfoTxFind(BlocksInfo):
|
|
|
-
|
|
|
- found_tx = False
|
|
|
-
|
|
|
- def post_init(self):
|
|
|
- if len(opt.transaction) != 64 or not is_hex_str(opt.transaction):
|
|
|
- die(2,f'{opt.transaction}: invalid transaction id')
|
|
|
-
|
|
|
- async def process_block(self,height,H):
|
|
|
- if opt.transaction in (await c.call('getblock',H))['tx']:
|
|
|
- Msg('\rRequested transaction is in block {} ({} confirmations)'.format(height,c.blockcount-height+1))
|
|
|
- return True
|
|
|
- msg_r('\rChecking block {} '.format(height))
|
|
|
-
|
|
|
- async def print_summary(self):
|
|
|
- if self.found_tx:
|
|
|
- try:
|
|
|
- await c.call('getmempoolentry',opt.transaction) # ,on_fail='silent')):
|
|
|
- except:
|
|
|
- Msg('\rTransaction not found in block range {}-{} or in mempool'.format(self.first,self.last))
|
|
|
- else:
|
|
|
- Msg('\rTransaction is in mempool')
|
|
|
-
|
|
|
- async def run(self):
|
|
|
- for height in range(self.first,self.last+1):
|
|
|
- H = await c.call('getblockhash',height)
|
|
|
- if await self.process_block(height,H): # returns True when finished
|
|
|
- break
|
|
|
- else:
|
|
|
- self.found_tx = True
|
|
|
-
|
|
|
class BlocksInfoHashes(BlocksInfo):
|
|
|
|
|
|
def print_header(self):
|
|
@@ -327,9 +295,7 @@ async def main():
|
|
|
global c
|
|
|
c = await rpc_init(proto)
|
|
|
|
|
|
- if opt.transaction:
|
|
|
- m = BlocksInfoTxFind()
|
|
|
- elif opt.hashes:
|
|
|
+ if opt.hashes:
|
|
|
m = BlocksInfoHashes()
|
|
|
else:
|
|
|
m = BlocksInfoOverview()
|