mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 09:21:39 +00:00
more accurate computation of transaction fees.
This commit is contained in:
parent
f3a1a57a78
commit
a5168cc09f
5 changed files with 34 additions and 7 deletions
2
electrum
2
electrum
|
@ -72,7 +72,7 @@ def arg_parser():
|
|||
parser.add_option("-a", "--all", action="store_true", dest="show_all", default=False, help="show all addresses")
|
||||
parser.add_option("-b", "--balance", action="store_true", dest="show_balance", default=False, help="show the balance of listed addresses")
|
||||
parser.add_option("-l", "--labels", action="store_true", dest="show_labels", default=False, help="show the labels of listed addresses")
|
||||
parser.add_option("-f", "--fee", dest="tx_fee", default="0.005", help="set tx fee")
|
||||
parser.add_option("-f", "--fee", dest="tx_fee", default=None, help="set tx fee")
|
||||
parser.add_option("-F", "--fromaddr", dest="from_addr", default=None, help="set source address for payto/mktx. if it isn't in the wallet, it will ask for the private key unless supplied in the format public_key:private_key. It's not saved in the wallet.")
|
||||
parser.add_option("-c", "--changeaddr", dest="change_addr", default=None, help="set the change address for payto/mktx. default is a spare address, or the source address if it's not in the wallet")
|
||||
parser.add_option("-s", "--server", dest="server", default=None, help="set server host:port:protocol, where protocol is t or h")
|
||||
|
|
|
@ -795,6 +795,10 @@ 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'))
|
||||
return
|
||||
|
||||
self.run_hook('send_tx', tx)
|
||||
|
||||
if label:
|
||||
|
@ -1928,8 +1932,8 @@ class ElectrumWindow(QMainWindow):
|
|||
fee_e = QLineEdit()
|
||||
fee_e.setText("%s"% str( Decimal( self.wallet.fee)/100000000 ) )
|
||||
grid_wallet.addWidget(fee_e, 0, 2)
|
||||
msg = _('Fee per transaction input. Transactions involving multiple inputs tend to require a higher fee.') + ' ' \
|
||||
+ _('Recommended value') + ': 0.001'
|
||||
msg = _('Fee per kilobyte of transaction.') + ' ' \
|
||||
+ _('Recommended value') + ': 0.0001'
|
||||
grid_wallet.addWidget(HelpButton(msg), 0, 3)
|
||||
fee_e.textChanged.connect(lambda: numbify(fee_e,False))
|
||||
if not self.config.is_modifiable('fee'):
|
||||
|
|
|
@ -198,7 +198,7 @@ def run_settings_dialog(wallet, parent):
|
|||
fee_entry.connect('changed', numbify, False)
|
||||
fee_entry.show()
|
||||
fee.pack_start(fee_entry,False,False, 10)
|
||||
add_help_button(fee, 'Fee per transaction input. Transactions involving multiple inputs tend to have a higher fee. Recommended value:0.0005')
|
||||
add_help_button(fee, 'Fee per kilobyte of transaction. Recommended value:0.0001')
|
||||
fee.show()
|
||||
vbox.pack_start(fee, False,False, 5)
|
||||
|
||||
|
@ -843,6 +843,11 @@ class ElectrumWindow:
|
|||
except BaseException, e:
|
||||
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." )
|
||||
return
|
||||
|
||||
|
||||
if label:
|
||||
self.wallet.labels[tx.hash()] = label
|
||||
|
|
|
@ -876,6 +876,18 @@ class Transaction:
|
|||
return out
|
||||
|
||||
|
||||
def requires_fee(self, verifier):
|
||||
threshold = 57600000
|
||||
size = len(self.raw)/2
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
def test_bip32():
|
||||
|
|
|
@ -74,7 +74,7 @@ class Wallet:
|
|||
self.seed_version = config.get('seed_version', SEED_VERSION)
|
||||
self.gap_limit = config.get('gap_limit', 5)
|
||||
self.use_change = config.get('use_change',True)
|
||||
self.fee = int(config.get('fee',100000))
|
||||
self.fee = int(config.get('fee',10000))
|
||||
self.num_zeros = int(config.get('num_zeros',0))
|
||||
self.use_encryption = config.get('use_encryption', False)
|
||||
self.seed = config.get('seed', '') # encrypted
|
||||
|
@ -565,14 +565,20 @@ class Wallet:
|
|||
total += v
|
||||
|
||||
inputs.append( item )
|
||||
fee = self.fee*len(inputs) if fixed_fee is None else fixed_fee
|
||||
if fixed_fee is None:
|
||||
estimated_size = len(inputs) * 180 + 80 # this assumes non-compressed keys
|
||||
fee = self.fee * round(estimated_size/1024.)
|
||||
if fee == 0: fee = self.fee
|
||||
else:
|
||||
fee = fixed_fee
|
||||
if total >= amount + fee: break
|
||||
else:
|
||||
#print "not enough funds: %s %s"%(format_satoshis(total), format_satoshis(fee))
|
||||
inputs = []
|
||||
|
||||
return inputs, total, fee
|
||||
|
||||
|
||||
|
||||
def add_tx_change( self, outputs, amount, fee, total, change_addr=None ):
|
||||
change_amount = total - ( amount + fee )
|
||||
if change_amount != 0:
|
||||
|
|
Loading…
Add table
Reference in a new issue