1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-26 17:38:39 +00:00

refactor fee computation, but keep ceil logic

This commit is contained in:
Pavol Rusnak 2017-05-15 12:08:54 +02:00
parent c8dc17341c
commit 391e3940e5
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
4 changed files with 5 additions and 11 deletions

View File

@ -153,9 +153,8 @@ void layoutConfirmTx(const CoinType *coin, uint64_t amount_out, uint64_t amount_
);
}
void layoutFeeOverThreshold(const CoinType *coin, uint64_t fee, uint32_t kb)
void layoutFeeOverThreshold(const CoinType *coin, uint64_t fee)
{
(void)kb;
const char *str_out = str_amount(fee, coin->has_coin_shortcut ? coin->coin_shortcut : NULL, buf_out, sizeof(buf_out));
layoutDialogSwipe(&bmp_icon_question,
"Cancel",

View File

@ -33,7 +33,7 @@ void layoutScreensaver(void);
void layoutHome(void);
void layoutConfirmOutput(const CoinType *coin, const TxOutputType *out);
void layoutConfirmTx(const CoinType *coin, uint64_t amount_out, uint64_t amount_fee);
void layoutFeeOverThreshold(const CoinType *coin, uint64_t fee, uint32_t kb);
void layoutFeeOverThreshold(const CoinType *coin, uint64_t fee);
void layoutSignMessage(const uint8_t *msg, uint32_t len);
void layoutVerifyAddress(const char *address);
void layoutVerifyMessage(const uint8_t *msg, uint32_t len);

View File

@ -566,9 +566,9 @@ static bool signing_check_fee(void) {
return false;
}
uint64_t fee = to_spend - spending;
uint32_t tx_est_size = transactionEstimateSizeKb(inputs_count, outputs_count);
if (fee > (uint64_t)tx_est_size * coin->maxfee_kb) {
layoutFeeOverThreshold(coin, fee, tx_est_size);
uint64_t tx_est_size_kb = (transactionEstimateSize(inputs_count, outputs_count) + 999) / 1000;
if (fee > tx_est_size_kb * coin->maxfee_kb) {
layoutFeeOverThreshold(coin, fee);
if (!protectButton(ButtonRequestType_ButtonRequest_FeeOverThreshold, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, "Fee over threshold. Signing cancelled.");
signing_abort();

View File

@ -570,8 +570,3 @@ uint32_t transactionEstimateSize(uint32_t inputs, uint32_t outputs)
{
return 10 + inputs * 149 + outputs * 35;
}
uint32_t transactionEstimateSizeKb(uint32_t inputs, uint32_t outputs)
{
return (transactionEstimateSize(inputs, outputs) + 999) / 1000;
}