Add min_relay_fee option.

This commit is contained in:
tecnovert 2023-12-01 19:16:28 +02:00
parent a4c79fb7aa
commit 0be5a4fca7
No known key found for this signature in database
GPG key ID: 8ED6D8750C4E3F93
4 changed files with 25 additions and 29 deletions

View file

@ -472,6 +472,8 @@ class BasicSwap(BaseApp):
if coin == Coins.FIRO:
self.coin_clients[coin]['use_csv'] = False
if 'min_relay_fee' not in self.coin_clients[coin]:
self.coin_clients[coin]['min_relay_fee'] = 0.00001
if coin == Coins.PART:
self.coin_clients[coin]['anon_tx_ring_size'] = chain_client_settings.get('anon_tx_ring_size', 12)
@ -1792,12 +1794,6 @@ class BasicSwap(BaseApp):
return self.callcoinrpc(coin_type, 'getnetworkinfo')['relayfee']
def getFeeRateForCoin(self, coin_type, conf_target: int = 2):
chain_client_settings = self.getChainClientSettings(coin_type)
override_feerate = chain_client_settings.get('override_feerate', None)
if override_feerate:
self.log.debug('Fee rate override used for %s: %f', Coins(coin_type).name, override_feerate)
return override_feerate, 'override_feerate'
return self.ci(coin_type).get_fee_rate(conf_target)
def estimateWithdrawFee(self, coin_type, fee_rate):

View file

@ -358,7 +358,15 @@ class BTCInterface(CoinInterface):
if self.sc._restrict_unknown_seed_wallets:
ensure(addr_info['hdseedid'] == self._expect_seedid_hex, 'unexpected seedid')
def get_fee_rate(self, conf_target: int = 2):
def get_fee_rate(self, conf_target: int = 2) -> (float, str):
chain_client_settings = self._sc.getChainClientSettings(self.coin_type())
override_feerate = chain_client_settings.get('override_feerate', None)
if override_feerate:
self._log.debug('Fee rate override used for %s: %f', self.coin_name(), override_feerate)
return override_feerate, 'override_feerate'
min_relay_fee = chain_client_settings.get('min_relay_fee', None)
def try_get_fee_rate(self, conf_target):
try:
fee_rate = self.rpc_callback('estimatesmartfee', [conf_target])['feerate']
assert (fee_rate > 0.0), 'Non positive feerate'
@ -371,6 +379,11 @@ class BTCInterface(CoinInterface):
except Exception:
return self.rpc_callback('getnetworkinfo')['relayfee'], 'relayfee'
fee_rate, rate_src = try_get_fee_rate(self, conf_target)
if min_relay_fee and min_relay_fee > fee_rate:
return min_relay_fee, 'min_relay_fee'
return fee_rate, rate_src
def isSegwitAddress(self, address: str) -> bool:
return address.startswith(self.chainparams_network()['hrp'] + '1')

View file

@ -727,17 +727,3 @@ class NAVInterface(BTCInterface):
i2h(tx.sha256), tx_fee_rate, vsize, pay_fee)
return tx.serialize()
def get_fee_rate(self, conf_target: int = 2):
try:
fee_rate = self.rpc_callback('estimatesmartfee', [conf_target])['feerate']
assert (fee_rate > 0.0), 'Non positive feerate'
return fee_rate, 'estimatesmartfee'
except Exception:
try:
fee_rate = self.rpc_callback('getwalletinfo')['paytxfee']
assert (fee_rate > 0.0), 'Non positive feerate'
return fee_rate, 'paytxfee'
except Exception:
return self.rpc_callback('getnetworkinfo')['relayfee'], 'relayfee'

View file

@ -1590,6 +1590,7 @@ def main():
'blocks_confirmed': 1,
'conf_target': 2,
'core_version_group': 14,
'min_relay_fee': 0.00001,
'chain_lookups': 'local',
},
'navcoin': {