From e3b4a8562cb12e39869f427580021ac6e4166980 Mon Sep 17 00:00:00 2001 From: ronserruya Date: Tue, 26 Feb 2019 14:19:00 +0200 Subject: [PATCH 1/2] Devide fee when topping up --- kin/account.py | 4 ++-- kin/config.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/kin/account.py b/kin/account.py index d89357b..243f964 100644 --- a/kin/account.py +++ b/kin/account.py @@ -13,7 +13,7 @@ from . import errors as KinErrors from .transactions import build_memo from .blockchain.errors import TransactionResultCode, HorizonErrorType, HorizonError -from .config import SDK_USER_AGENT, APP_ID_REGEX +from .config import SDK_USER_AGENT, APP_ID_REGEX, KIN_DECIMAL_PRECISION from .blockchain.utils import is_valid_address, is_valid_secret_key import logging @@ -335,7 +335,7 @@ def _top_up(self, address): # however it is virtually impossible that this situation will occur. # TODO: let user config the amount of kin to top up - min_fee = self._client.get_minimum_fee() + min_fee = self._client.get_minimum_fee() / KIN_DECIMAL_PRECISION # Fee is in stroops builder = self.get_transaction_builder(min_fee) builder.append_payment_op(address, str(min_fee * 1000)) builder.update_sequence() diff --git a/kin/config.py b/kin/config.py index 4eca81d..910e16a 100644 --- a/kin/config.py +++ b/kin/config.py @@ -1,4 +1,5 @@ """Contains the config for the Kin SDK""" +from kin_base.operation import ONE as KIN_DECIMAL_PRECISION from .blockchain.environment import Environment From cc51b3c2585ead26e8420551b92192264ef629d4 Mon Sep 17 00:00:00 2001 From: ronserruya Date: Tue, 26 Feb 2019 14:34:10 +0200 Subject: [PATCH 2/2] Get correct fee for top up builder --- kin/account.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kin/account.py b/kin/account.py index 243f964..351b249 100644 --- a/kin/account.py +++ b/kin/account.py @@ -335,9 +335,9 @@ def _top_up(self, address): # however it is virtually impossible that this situation will occur. # TODO: let user config the amount of kin to top up - min_fee = self._client.get_minimum_fee() / KIN_DECIMAL_PRECISION # Fee is in stroops + min_fee = self._client.get_minimum_fee() builder = self.get_transaction_builder(min_fee) - builder.append_payment_op(address, str(min_fee * 1000)) + builder.append_payment_op(address, str((min_fee / KIN_DECIMAL_PRECISION) * 1000)) # Enough for 1K txs builder.update_sequence() builder.sign() builder.submit()