From 621aff47969761014e0a6c4e699cb637d5687ab3 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Mon, 8 Jan 2024 20:30:17 -0600 Subject: [PATCH] fee estimation --- .../coins/namecoin/namecoin_wallet.dart | 22 +++++++++---------- lib/wallets/wallet/impl/namecoin_wallet.dart | 12 ++++++---- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/lib/services/coins/namecoin/namecoin_wallet.dart b/lib/services/coins/namecoin/namecoin_wallet.dart index 44a16c802..a51ecd808 100644 --- a/lib/services/coins/namecoin/namecoin_wallet.dart +++ b/lib/services/coins/namecoin/namecoin_wallet.dart @@ -2329,9 +2329,9 @@ class NamecoinWallet extends CoinServiceAPI } } - int estimateTxFee({required int vSize, required int feeRatePerKB}) { - return vSize * (feeRatePerKB / 1000).ceil(); - } + // int estimateTxFee({required int vSize, required int feeRatePerKB}) { + // return vSize * (feeRatePerKB / 1000).ceil(); + // } /// The coinselection algorithm decides whether or not the user is eligible to make the transaction /// with [satoshiAmountToSend] and [selectedTxFeeRate]. If so, it will call buildTrasaction() and return @@ -3405,14 +3405,14 @@ class NamecoinWallet extends CoinServiceAPI } // TODO: Check if this is the correct formula for namecoin - Amount roughFeeEstimate(int inputCount, int outputCount, int feeRatePerKB) { - return Amount( - rawValue: BigInt.from( - ((42 + (272 * inputCount) + (128 * outputCount)) / 4).ceil() * - (feeRatePerKB / 1000).ceil()), - fractionDigits: coin.decimals, - ); - } + // Amount roughFeeEstimate(int inputCount, int outputCount, int feeRatePerKB) { + // return Amount( + // rawValue: BigInt.from( + // ((42 + (272 * inputCount) + (128 * outputCount)) / 4).ceil() * + // (feeRatePerKB / 1000).ceil()), + // fractionDigits: coin.decimals, + // ); + // } Future sweepAllEstimate(int feeRate) async { int available = 0; diff --git a/lib/wallets/wallet/impl/namecoin_wallet.dart b/lib/wallets/wallet/impl/namecoin_wallet.dart index 7ee1d233f..5bc2410b3 100644 --- a/lib/wallets/wallet/impl/namecoin_wallet.dart +++ b/lib/wallets/wallet/impl/namecoin_wallet.dart @@ -53,14 +53,18 @@ class NamecoinWallet extends Bip39HDWallet @override int estimateTxFee({required int vSize, required int feeRatePerKB}) { - // TODO: implement estimateTxFee - throw UnimplementedError(); + return vSize * (feeRatePerKB / 1000).ceil(); } + // TODO: [prio=low] Check if this is the correct formula for namecoin. ECF @override Amount roughFeeEstimate(int inputCount, int outputCount, int feeRatePerKB) { - // TODO: implement roughFeeEstimate - throw UnimplementedError(); + return Amount( + rawValue: BigInt.from( + ((42 + (272 * inputCount) + (128 * outputCount)) / 4).ceil() * + (feeRatePerKB / 1000).ceil()), + fractionDigits: cryptoCurrency.fractionDigits, + ); } @override