From 3d1d70a1764f0f9ece00184b51ad1460ef61337f Mon Sep 17 00:00:00 2001 From: vagrant Date: Fri, 1 Feb 2019 16:55:40 +0000 Subject: [PATCH] Allow baker to choose who pays transfer fee --- fee.ini | 1 + readme.md | 2 ++ src/pay/batch_payer.py | 8 +++++--- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/fee.ini b/fee.ini index e0608223..e58a0571 100644 --- a/fee.ini +++ b/fee.ini @@ -1,5 +1,6 @@ [DEFAULT] fee=1274 +delegator_pays_xfer_fee=true [KTTX] storage_limit=0 diff --git a/readme.md b/readme.md index 9c182079..65fb031d 100644 --- a/readme.md +++ b/readme.md @@ -131,6 +131,8 @@ fee.ini file contains details about transaction fees. Currently the fee value sp https://zeronet.tzscan.io/opCnDj8bpr5ACrbLSqy4BDCMsNiY8Y34bvnm2hj7MvcxaRiu5tu +`delegator_pays_xfer_fee` - Set this to 'true' if you want the transaction fee to be deducted from the delegator's reward. Set this to 'false' if the baker will pay the transfer fee. + #### Terms: - Reward: Coins rewarded by the network for the baking/endorsing operations. diff --git a/src/pay/batch_payer.py b/src/pay/batch_payer.py index 2eea854a..efb20c70 100644 --- a/src/pay/batch_payer.py +++ b/src/pay/batch_payer.py @@ -46,6 +46,7 @@ def __init__(self, node_url, client_path, key_name): self.gas_limit = kttx['gas_limit'] self.storage_limit = kttx['storage_limit'] self.default_fee = kttx['fee'] + self.delegator_pays_xfer_fee = config.getboolean('KTTX', 'delegator_pays_xfer_fee', fallback=True) # Must use getboolean otherwise parses as string # key_name has a length of 36 and starts with tz or KT then it is a public key has, else it is an alias if len(self.key_name) == PKH_LENGHT and (self.key_name.startswith("KT") or self.key_name.startswith("tz")): @@ -126,10 +127,11 @@ def pay_single_batch(self, payment_records, verbose=None, dry_run=None): for payment_item in payment_records: pymnt_amnt = int(payment_item.payment * 1e6) # expects in micro tezos - pymnt_amnt = max(pymnt_amnt - int(self.default_fee), 0) # ensure not less than 0 - if pymnt_amnt < 1e-3: # zero check - continue + if self.delegator_pays_xfer_fee: + pymnt_amnt = max(pymnt_amnt - int(self.default_fee), 0) # ensure not less than 0 + if pymnt_amnt < 1e-3: # zero check + continue counter = counter + 1 content = CONTENT.replace("%SOURCE%", self.source).replace("%DESTINATION%", payment_item.address) \