Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #957 +/- ##
========================================
Coverage 97.60% 97.61%
========================================
Files 84 84
Lines 11001 11005 +4
========================================
+ Hits 10738 10742 +4
Misses 263 263 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
While the top example is obviously a high fee, I'll argue that so are the other 3 relative to their abnormally low spend amounts. Personally, I don't mind being warned about high fees in cases where I'm making a spend that is so small that I already know the fee is a significant part of it (in my head "why not lightning?"); I'd be expecting it or it wouldn't surprise me. |
|
I was working on something very similar (joaozinhom#8) and reviewing AI-generated translations; I'll take a look at this PR and suggest some changes, if that's okay... |
| return prefix + BTC_SYMBOL + THIN_SPACE + "%s" % format_btc(amount) | ||
|
|
||
| def _get_resume_fee(self, inp_amount, out_amount, output_policy_count): | ||
| def _get_resume_fee( |
There was a problem hiding this comment.
The inspiration for this feature came from Sparrow Wallet. So it would be worth checking how Sparrow handles it before making any changes on the Krux side. In my tests, Krux behaved the same way as Sparrow, but I may have missed some scenarios. -tadeubas
Copied by jdlcdl from a post in krux-devs tg group by tadeu
I agree with this too. Breaking a large utxo into a spend and a few smaller self-transfer utxos is part of the amount being moved (user actively created these outputs); fee percentage arguable can be calculated off the sum of all spend and self-xfers. |
c7a5442 to
4e4ae2b
Compare
|
Thanks @notTanveer and @jdlcdl, applied: the fee percent is now based on spends plus self transfers, and on change only when nothing else is sent. On the Sparrow check from @tadeubas: Sparrow divides the fee by all outputs including change, so this now differs from Sparrow on purpose, so a large change output no longer hides a high fee. |
|
I think the feature should follow Sparrow's implementation. Sparrow has a wider user base, and people are already used to its behavior. It would be strange to see one behavior in Sparrow and another in Krux, as it could make it seem like either Sparrow or Krux is misbehaving. So I think this discussion should happen in Sparrow first, and only if the behavior changes there should we make the corresponding change in Krux |
|
Fair point, but I'd rather not wait on Sparrow. Krux's own fee warning is meant to be "10% of what is spent", so a large change output shouldn't hide a high fee. Krux's percentage can only come out higher than Sparrow's, and as the last check before signing, it's safer for Krux to warn when Sparrow doesn't. |
|
It’s not just about the warning; it’s also about what the user sees in the transaction summary. Both Sparrow and Krux display a fee percentage, but if they calculate it using different bases, the same percentage label represents different things in each wallet. That can confuse users and make them think one of the wallets is behaving incorrectly. |
4e4ae2b to
da5629e
Compare
|
Updated: the summary percentage is now unchanged from develop, so it matches Sparrow, and only the high fee warning uses the amount sent. |
HarshPopat23
left a comment
There was a problem hiding this comment.
I tested da5629e against 2937a29 with the same P2WPKH PSBT: 0.10 BTC to the recipient, 0.89 BTC change, and a 0.01 BTC fee. The base skipped the warning; this PR warns at 10.0%. Both show 1.1% in the summary and the same recipient, change, and fee. Declining stopped before the signing menu, and retrying and accepting reached it.
The full host suite had 1,198 passes and 1 expected failure. The new large-change test failed as expected on the base. I also confirmed the documented limitation: removing the change output’s derivation metadata makes Krux label it as a spend and skip the warning. No hardware testing.
One non-blocking suggestion: could the warning say “of the amount sent” when there’s a payment or self-transfer? Seeing “10.0% of the amount” followed by a 1.1% summary is hard to reconcile without knowing what each percentage includes.
|
thanks for testing it. changing the wording means a new string in all 11 translations, so I'd keep this PR to the fix and change the text in a follow up if the maintainers want it. |
|
cACK da5629e (tACK in software, not in devices yet, while it could solve a issue found with krux-integration-tests) |
|
Quick check before I clean things up: is the diff in kkdao#4 (suggestions with translations) still useful for this PR? If it's not relevant anymore, I'll close the sub-PR. |
Made a check on that and LGTM, i wthink it's worth |
|
thanks, it's a good idea. it adds a new warning and 11 translations, so I'd prefer it as its own PR after this one, but I'm happy to merge it here if the maintainers would rather have it in one. |
The high fee warning divided the fee by every output, change included, so a payment made from a large coin hid a high fee. In the existing test data, paying 1,000 sat and sending 1,000 sat to the wallet itself with a 373 sat fee is 18.7% of what is sent, yet it showed 3.9% and never warned. Measure the warning against what is sent instead: spends plus transfers to the wallet's own receive addresses, since the user chose to create both. Change is the base only when nothing else is sent. The summary still divides by all outputs, so its percentage keeps matching coordinators like Sparrow.
da5629e to
666bc7b
Compare
| out_amount = self_amount + change_amount + spend_amount | ||
| resume_fee_str, _ = self._get_resume_fee( |
There was a problem hiding this comment.
nothing reads the second return value of _get_resume_fee anymore, only test_psbt.py:2306 does. could it return just resume_fee_str, with that test calling _fee_percent directly?
also the fee gets computed twice now, in there and again as inp_amount - out_amount at the warn_percent line. compute it once in outputs() and pass it to both so they can't drift.
edit: i tried, the change in my editor and didn't like it. FWIW, keep it as is.
There was a problem hiding this comment.
good catch, the fix is what left that second value unused, but since jdlcdl ACK'd 666bc7b I'd rather leave it and clean it up in a follow up.
There was a problem hiding this comment.
No rush to merge kkdao, if you push another commit, I'll just edit my ack, as i do.
|
ACK at 666bc7b (as well as the next if it resolves tanveers comments), while hoping for more reviews/acks/approval. Thank you kkdao, tanveer, joaozinho, tadeu and harshpopat for this proposal and the feedback. I think it's a great compromise to show what Sparrow sees while having an alternate warning. |
|
ACK at 666bc7b |

What is this PR for?
The 10% high fee warning divides the fee by every output, change included. A large change output can therefore suppress the warning even when the fee is high compared with what is sent.
Krux's own test data already shows it. In
test_outputs_singlesig, paying 1,000 sat and sending 1,000 sat to the wallet itself with a 373 sat fee is 18.7% of what is sent, but Krux shows 3.9% and doesn't warn. Intest_outputs_multisig, paying 100,000 sat and sending 200,000 sat to the wallet itself with a 61,592 sat fee is 20.6%, shown as 6.6% with no warning.This PR measures the warning against what is sent: spends plus self transfers to the wallet's own receive addresses, since the user chose to create both, as suggested in review. Change is the base only when nothing else is sent. The fee percentage on the summary screen is unchanged and still divides by all outputs, so it keeps matching coordinators like Sparrow. #390 first divided by the spend, as the warning describes ("Warn if fees greater than 10% of what is spent" in
home.py), and #392 switched to all outputs.Only the warning's base changes. The summary, the absolute fee, the sat/vB estimate, the 10% threshold and the warning text are unchanged. Spends plus self transfers are never larger than all outputs, so the warning can only fire more often. Outputs count as change or self transfer only when the wallet descriptor owns them, which rebuilds and compares the full output script, so a coordinator cannot move a payment into the change or the self transfers. Single-sig wallets always have a descriptor. Multisig and miniscript wallets without a loaded descriptor count every output as spend, as before. Missing change derivation data can dilute the new percentage, but cannot make it lower than the previous all output calculation.
New tests cover a payment with a large change output, where the summary shows 1.1% and the warning uses 10.0%, the
test_outputs_singlesigpayment next to a self transfer, where the summary shows 3.9% and the warning uses 18.7%, a change only transaction, and a self transfer with and without change. No existing expectation changes. All tests pass (1198 passed, 1 xfailed).Not changed here: the rounding is not a strict ceiling despite its comment (0.4086% shows as 0.4%).
Changes made to:
Did you build the code and tested on device?
Not tested on device: only the number the warning divides by changes. The warning screen, its text and its threshold are the same ones develop already shows for any fee of 10% or more. An earlier revision of this PR was built for M5StickV, this one was not.
What is the purpose of this pull request?