From: ecdsa Date: Sun, 24 Mar 2013 10:25:17 +0000 (+0100) Subject: implement MIN_RELAY_TX_FEE X-Git-Url: https://git.novaco.in/?a=commitdiff_plain;h=fc7122008a877587e716b537a3efa15588bfb296;p=electrum-nvc.git implement MIN_RELAY_TX_FEE --- diff --git a/gui/gui_classic.py b/gui/gui_classic.py index c536450..585c4b4 100644 --- a/gui/gui_classic.py +++ b/gui/gui_classic.py @@ -32,6 +32,7 @@ from PyQt4.QtCore import * import PyQt4.QtCore as QtCore import PyQt4.QtGui as QtGui from electrum.interface import DEFAULT_SERVERS +from electrum.bitcoin import MIN_RELAY_TX_FEE try: import icons_rc @@ -795,8 +796,8 @@ class ElectrumWindow(QMainWindow): self.show_message(str(e)) return - if tx.requires_fee(self.wallet.verifier) and fee == 0: - QMessageBox.warning(self, _('Error'), _("This transaction requires a fee, or it will not be propagated by the network."), _('OK')) + if tx.requires_fee(self.wallet.verifier) and fee < MIN_RELAY_TX_FEE: + QMessageBox.warning(self, _('Error'), _("This transaction requires a higher fee, or it will not be propagated by the network."), _('OK')) return self.run_hook('send_tx', tx) diff --git a/gui/gui_gtk.py b/gui/gui_gtk.py index d3261de..2cec19b 100644 --- a/gui/gui_gtk.py +++ b/gui/gui_gtk.py @@ -35,6 +35,7 @@ MONOSPACE_FONT = 'Lucida Console' if platform.system() == 'Windows' else 'monosp from electrum.util import format_satoshis from electrum.interface import DEFAULT_SERVERS +from electrum.bitcoin import MIN_RELAY_TX_FEE def numbify(entry, is_int = False): text = entry.get_text().strip() @@ -844,8 +845,8 @@ class ElectrumWindow: self.show_message(str(e)) return - if tx.requires_fee(self.wallet.verifier) and fee == 0: - self.show_message( "This transaction requires a fee, or it will not be propagated by the network." ) + if tx.requires_fee(self.wallet.verifier) and fee < MIN_RELAY_TX_FEE: + self.show_message( "This transaction requires a higher fee, or it will not be propagated by the network." ) return diff --git a/lib/bitcoin.py b/lib/bitcoin.py index 0b87b78..41f9395 100644 --- a/lib/bitcoin.py +++ b/lib/bitcoin.py @@ -577,6 +577,7 @@ class BIP32Sequence: ################################## transactions +MIN_RELAY_TX_FEE = 10000 class Transaction: @@ -877,15 +878,23 @@ class Transaction: def requires_fee(self, verifier): + # see https://en.bitcoin.it/wiki/Transaction_fees threshold = 57600000 size = len(self.raw)/2 + if size >= 10000: + return True + + for o in self.outputs: + value = o[1] + if value < 1000000: + return True sum = 0 for i in self.inputs: age = verifier.get_confirmations(i["tx_hash"])[0] sum += i["value"] * age priority = sum / size print_error(priority, threshold) - return priority < threshold + return priority < threshold diff --git a/lib/wallet.py b/lib/wallet.py index 2d88668..6564258 100644 --- a/lib/wallet.py +++ b/lib/wallet.py @@ -912,6 +912,7 @@ class Wallet: height = None for h in ext_h: if h == ['*']: continue + print_error(h) for item in h: if item.get('tx_hash') == tx_hash: height = item.get('height')