cli history: add option to filter by block height
This commit is contained in:
parent
38ab7ee554
commit
2174fc0676
@ -537,11 +537,14 @@ class Commands:
|
||||
return tx.as_dict()
|
||||
|
||||
@command('w')
|
||||
def history(self, year=None, show_addresses=False, show_fiat=False, show_fees=False):
|
||||
def history(self, year=None, show_addresses=False, show_fiat=False, show_fees=False,
|
||||
from_height=None, to_height=None):
|
||||
"""Wallet history. Returns the transaction history of your wallet."""
|
||||
kwargs = {
|
||||
'show_addresses': show_addresses,
|
||||
'show_fees': show_fees,
|
||||
'from_height': from_height,
|
||||
'to_height': to_height,
|
||||
}
|
||||
if year:
|
||||
import time
|
||||
@ -831,7 +834,9 @@ command_options = {
|
||||
'show_fees': (None, "Show miner fees paid by transactions"),
|
||||
'year': (None, "Show history for a given year"),
|
||||
'fee_method': (None, "Fee estimation method to use"),
|
||||
'fee_level': (None, "Float between 0.0 and 1.0, representing fee slider position")
|
||||
'fee_level': (None, "Float between 0.0 and 1.0, representing fee slider position"),
|
||||
'from_height': (None, "Only show transactions that confirmed after given block height"),
|
||||
'to_height': (None, "Only show transactions that confirmed before given block height"),
|
||||
}
|
||||
|
||||
|
||||
@ -843,6 +848,8 @@ arg_types = {
|
||||
'nbits': int,
|
||||
'imax': int,
|
||||
'year': int,
|
||||
'from_height': int,
|
||||
'to_height': int,
|
||||
'tx': tx_from_str,
|
||||
'pubkeys': json_loads,
|
||||
'jsontx': json_loads,
|
||||
|
||||
@ -422,7 +422,11 @@ class Abstract_Wallet(AddressSynchronizer):
|
||||
|
||||
@profiler
|
||||
def get_full_history(self, domain=None, from_timestamp=None, to_timestamp=None,
|
||||
fx=None, show_addresses=False, show_fees=False):
|
||||
fx=None, show_addresses=False, show_fees=False,
|
||||
from_height=None, to_height=None):
|
||||
if (from_timestamp is not None or to_timestamp is not None) \
|
||||
and (from_height is not None or to_height is not None):
|
||||
raise Exception('timestamp and block height based filtering cannot be used together')
|
||||
out = []
|
||||
income = 0
|
||||
expenditures = 0
|
||||
@ -437,10 +441,15 @@ class Abstract_Wallet(AddressSynchronizer):
|
||||
continue
|
||||
if to_timestamp and (timestamp or now) >= to_timestamp:
|
||||
continue
|
||||
height = tx_mined_status.height
|
||||
if from_height is not None and height < from_height:
|
||||
continue
|
||||
if to_height is not None and height >= to_height:
|
||||
continue
|
||||
tx = self.transactions.get(tx_hash)
|
||||
item = {
|
||||
'txid': tx_hash,
|
||||
'height': tx_mined_status.height,
|
||||
'height': height,
|
||||
'confirmations': tx_mined_status.conf,
|
||||
'timestamp': timestamp,
|
||||
'incoming': True if value>0 else False,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user