firo private send vsize check

This commit is contained in:
julian 2022-09-24 10:16:56 -06:00
parent b0aed63b18
commit 5653bf173d

View file

@ -623,6 +623,7 @@ Future<dynamic> isolateCreateJoinSplitTransaction(
"value": amount, "value": amount,
"fees": Format.satoshisToAmount(fee).toDouble(), "fees": Format.satoshisToAmount(fee).toDouble(),
"fee": fee, "fee": fee,
"vSize": extTx.virtualSize(),
"jmintValue": changeToMint, "jmintValue": changeToMint,
"publicCoin": "jmintData.publicCoin", "publicCoin": "jmintData.publicCoin",
"spendCoinIndexes": spendCoinIndexes, "spendCoinIndexes": spendCoinIndexes,
@ -1142,6 +1143,17 @@ class FiroWallet extends CoinServiceAPI {
throw Exception("Error Creating Transaction!"); throw Exception("Error Creating Transaction!");
} }
} else { } else {
final fee = txHexOrError["fee"] as int;
final vSize = txHexOrError["vSize"] as int;
Logging.instance.log("prepared fee: $fee", level: LogLevel.Info);
Logging.instance.log("prepared vSize: $vSize", level: LogLevel.Info);
// fee should never be less than vSize sanity check
if (fee < vSize) {
throw Exception(
"Error in fee calculation: Transaction fee cannot be less than vSize");
}
return txHexOrError as Map<String, dynamic>; return txHexOrError as Map<String, dynamic>;
} }
} catch (e, s) { } catch (e, s) {