Skip to content

Commit

Permalink
Allow baker to choose who pays transfer fee
Browse files Browse the repository at this point in the history
  • Loading branch information
utdrmac committed Feb 1, 2019
1 parent 82e1fc4 commit 3d1d70a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions fee.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[DEFAULT]
fee=1274
delegator_pays_xfer_fee=true

[KTTX]
storage_limit=0
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 5 additions & 3 deletions src/pay/batch_payer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")):
Expand Down Expand Up @@ -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) \
Expand Down

0 comments on commit 3d1d70a

Please sign in to comment.