mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-22 06:18:07 +00:00
fix(core): Fix CoinJoin approval check.
After fixing the TxWeightCalculator the approver needs to account for the weight of the coordinator's output.
This commit is contained in:
parent
56ac799626
commit
ef2ad57ec8
@ -257,6 +257,8 @@ class BasicApprover(Approver):
|
||||
|
||||
|
||||
class CoinJoinApprover(Approver):
|
||||
MAX_OUTPUT_WEIGHT = const(4 * 43)
|
||||
|
||||
def __init__(
|
||||
self, tx: SignTx, coin: CoinInfo, authorization: CoinJoinAuthorization
|
||||
) -> None:
|
||||
@ -319,9 +321,12 @@ class CoinJoinApprover(Approver):
|
||||
if mining_fee > (self.coin.maxfee_kb / 1000) * (self.weight.get_total() / 4):
|
||||
raise wire.ProcessError("Mining fee over threshold")
|
||||
|
||||
# The maximum mining fee that the user should be paying.
|
||||
# The maximum mining fee that the user should be paying assuming that participants share
|
||||
# the fees for the coordinator's output.
|
||||
our_max_mining_fee = (
|
||||
mining_fee * self.our_weight.get_total() / self.weight.get_total()
|
||||
mining_fee
|
||||
* self.our_weight.get_total()
|
||||
/ (self.weight.get_total() - self.MAX_OUTPUT_WEIGHT)
|
||||
)
|
||||
|
||||
# The coordinator fee for the user's outputs.
|
||||
|
Loading…
Reference in New Issue
Block a user