From 830ff7fc4828fd3153c705c1310865e47ec082c1 Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Sun, 28 Sep 2025 16:31:45 -0400 Subject: [PATCH] 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. --- make_post_sell/views/crypto.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/make_post_sell/views/crypto.py b/make_post_sell/views/crypto.py index 140bac5..dcc2b36 100644 --- a/make_post_sell/views/crypto.py +++ b/make_post_sell/views/crypto.py @@ -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})" )