electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 2174fc0676aa24797fc5a5c635c14d9d285a5374
parent 38ab7ee554b89b96c5ac7ea1b83d275d6cdb3cad
Author: SomberNight <somber.night@protonmail.com>
Date:   Tue, 12 Feb 2019 18:38:35 +0100

cli history: add option to filter by block height

Diffstat:
Melectrum/commands.py | 11+++++++++--
Melectrum/wallet.py | 13+++++++++++--
2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/electrum/commands.py b/electrum/commands.py @@ -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, diff --git a/electrum/wallet.py b/electrum/wallet.py @@ -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,