fix dogecoin transaction size calculation (#2570)
What changed, and why it matters
This commit fixes how Dogecoin transaction fees are calculated in Cake Wallet. Previously, the app likely relied on a Bitcoin-style size estimate that doesn't match Dogecoin's typical transaction structure. The change adds a Dogecoin-specific formula to estimate transaction size (and therefore fee) more accurately. An incorrect size estimate could lead to users paying too much or too little in fees, which in extreme cases can cause transactions to get stuck or be delayed.
Treat as a routine correctness fix. Review whether the new constants (180 bytes/input, 34 bytes/output, 10 bytes overhead) are accurate for the Dogecoin transaction types the wallet produces (P2PKH, P2SH, etc.) and verify fee edge cases through testing. No immediate security response is indicated by the diff alone.
Security signals we found
Incorrect transaction-size estimation can cause overpayment or underpayment of miner fees
Underpayment of fees can lead to transaction stuck/mempool eviction, degrading wallet reliability
No explicit security framing, CVE, or exploit code present in the commit
No vendor-authored security advisory or researcher attribution in the commit
Evidence from the diff
The patch introduces estimatedDogeCoinTransactionSize(int inputsCount, int outputsCounts) returning inputsCount * 180 + outputsCounts * 34 + 10, and overrides feeAmountForPriority and feeAmountWithFeeRate in DogeCoinWalletBase to use this estimator instead of any inherited Bitcoin-based default. This aligns fee calculation with Dogecoin’s larger signatures/transaction structure. The commit does not contain any explicit security disclosure or attribution.
Changed components
cw_dogecoin/lib/src/dogecoin_wallet.dartDogecoin fee estimation logicTransaction priority/fee rate handlingInspect captured patch +14 / −0
diff --git a/cw_dogecoin/lib/src/dogecoin_wallet.dart b/cw_dogecoin/lib/src/dogecoin_wallet.dart
index bd7fe069..7e0b61a9 100644
--- a/cw_dogecoin/lib/src/dogecoin_wallet.dart
+++ b/cw_dogecoin/lib/src/dogecoin_wallet.dart
@@ -7,6 +7,7 @@ import 'package:cw_bitcoin/electrum_wallet.dart';
import 'package:cw_bitcoin/electrum_wallet_snapshot.dart';
import 'package:cw_core/crypto_currency.dart';
import 'package:cw_core/encryption_file_utils.dart';
+import 'package:cw_core/transaction_priority.dart';
import 'package:cw_core/unspent_coins_info.dart';
import 'package:cw_core/wallet_info.dart';
import 'package:cw_core/wallet_keys_file.dart';
@@ -65,6 +66,19 @@ abstract class DogeCoinWalletBase extends ElectrumWallet with Store {
@override
int get networkDustAmount => 100000000; // 1 DOGE = 1e8 koinu
+ static int estimatedDogeCoinTransactionSize(int inputsCount, int outputsCounts) =>
+ inputsCount * 180 + outputsCounts * 34 + 10;
+
+ @override
+ int feeAmountForPriority(TransactionPriority priority, int inputsCount, int outputsCount,
+ {int? size}) =>
+ feeRate(priority) * (size ?? estimatedDogeCoinTransactionSize(inputsCount, outputsCount));
+
+ @override
+ int feeAmountWithFeeRate(int feeRate, int inputsCount, int outputsCount, {int? size}) =>
+ feeRate * (size ?? estimatedDogeCoinTransactionSize(inputsCount, outputsCount));
+
+
static Future<DogeCoinWallet> create(
{required String mnemonic,
required String password,
Why this scored 34/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.