[spesmilo/electrum] Add minimum confirmations for balance (#4391)

SomberNight requested changes on this pull request.

Do you want this mostly for the GUI? Because the GUI already visually distinguishes txns based on the number of confirmations.

> local_height = self.get_local_height()
for txo, (tx_height, v, is_cb) in received.items():
if is_cb and tx_height + COINBASE_MATURITY > local_height:
x += v
— elif tx_height > 0:

tx_height is a block height where the tx was included. 0 and -1 have special meanings signalling the tx is unconfirmed. your change won’t do what you want.

> @@ -322,7 +322,8 @@ def getaddressbalance(self, address):
server query, results are not checked by SPV.
sh = bitcoin.address_to_scripthash(address)
— out = self.network.synchronous_get((‘blockchain.scripthash.get_balance’, [sh]))
+ minconf = self.config.get(‘minconf’, 1)
+ out = self.network.synchronous_get((‘blockchain.scripthash.get_balance’, [sh, int(minconf)]))

This change, as it affects the protocol, should probably be done separately from the rest. In most cases, the client can just filter transactions based on confirmations and calculate whatever, but not if you outsource the request to the server. :)

Добавить комментарий