Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(legacy,core): use sat/vB only for segwit and sat/B otherwise #2294

Merged
merged 1 commit into from
May 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/apps/bitcoin/sign_tx/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ async def confirm_total(
fee_rate_str: str | None = None

if fee_rate >= 0:
fee_rate_str = f"({fee_rate:.1f} sat/vB)"
fee_rate_str = f"({fee_rate:.1f} sat/{'v' if coin.segwit else ''}B)"

await layouts.confirm_total(
ctx,
Expand Down
9 changes: 5 additions & 4 deletions legacy/firmware/layout2.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,14 +504,15 @@ static bool formatAmountDifference(const CoinInfo *coin, AmountUnit amount_unit,
}

static bool formatFeeRate(uint64_t fee, uint64_t tx_weight, char *output,
size_t output_length) {
size_t output_length, bool segwit) {
// Compute fee rate and modify it in place for `bn_format_uint64` function -
// multiply by 10, because we only want to display 1 decimal digit
// and then get whole number by leaving it in `uint64_t`.
uint64_t fee_rate_multiplied = (fee * 10) / (tx_weight / 4);

return bn_format_uint64(fee_rate_multiplied, "(", " sat/vB)", 1, 0, false,
output, output_length) != 0;
return bn_format_uint64(fee_rate_multiplied, "(",
segwit ? " sat/vB)" : " sat/B)", 1, 0, false, output,
output_length) != 0;
}

void layoutConfirmTx(const CoinInfo *coin, AmountUnit amount_unit,
Expand All @@ -530,7 +531,7 @@ void layoutConfirmTx(const CoinInfo *coin, AmountUnit amount_unit,

if (show_fee_rate) {
formatFeeRate(total_in - total_out, tx_weight, str_fee_rate,
sizeof(str_fee_rate));
sizeof(str_fee_rate), coin->has_segwit);
}

layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), NULL,
Expand Down
Loading