Cap excessive Dogecoin fee rates to prevent overcharging

The estimatesmartfee RPC was returning inflated fee rates (3+ DOGE/KB)
causing fees of ~/bin/bash.20 instead of expected ~/bin/bash.024.

Added fee rate cap of 0.1 DOGE/KB which results in:
- Max fee: 0.1 * 0.25KB * 2 = 0.05 DOGE (~/bin/bash.011)
- Much closer to wallet estimates of ~0.102 DOGE (~/bin/bash.024)
- Still covers inbound + outbound transaction costs

This prevents customers from being overcharged due to temporary
network fee spikes or misconfigured fee estimation.
This commit is contained in:
Russell Ballestrini 2025-09-28 16:31:45 -04:00
parent b46b387460
commit 830ff7fc48

View file

@ -1105,6 +1105,14 @@ def estimate_dogecoin_fee_for_quote(settings):
# feerate is in DOGE per KB, estimate transaction size as ~0.25KB (more realistic)
# Typical DOGE transaction is ~225 bytes, not 500 bytes
network_feerate = float(fee_estimate_result["feerate"])
# Cap fee rate at reasonable maximum (0.1 DOGE/KB = ~$0.025/KB)
# Dogecoin fees should never exceed this under normal conditions
max_reasonable_feerate = 0.1
if network_feerate > max_reasonable_feerate:
logger.warning(f"Network fee rate {network_feerate} DOGE/KB is excessive, capping at {max_reasonable_feerate} DOGE/KB")
network_feerate = max_reasonable_feerate
estimated_fee_doge = network_feerate * 0.25
# Double the fee to cover both inbound (customer) and outbound (sweep) transactions
total_fee_doge = estimated_fee_doge * 2
@ -1195,10 +1203,7 @@ def crypto_debug_wallet_scan(request):
for processor in processors:
# Show processor info but mask shop IDs for security
shop_id_str = str(processor.shop_id)
shop_id_masked = (
shop_id_str[:8] + "***" if len(shop_id_str) > 8 else "***"
)
shop_id_masked = processor.shop_id.uuid_str[:8] + "***"
debug_output.append(
f" - {processor.coin_type} processor (shop {shop_id_masked})"
)