From ef2ad57ec82cc842ee438e18e4595c17711b2046 Mon Sep 17 00:00:00 2001 From: Andrew Kozlik Date: Tue, 2 Nov 2021 00:25:30 +0100 Subject: [PATCH] fix(core): Fix CoinJoin approval check. After fixing the TxWeightCalculator the approver needs to account for the weight of the coordinator's output. --- core/src/apps/bitcoin/sign_tx/approvers.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/src/apps/bitcoin/sign_tx/approvers.py b/core/src/apps/bitcoin/sign_tx/approvers.py index 7187c59cd..03e97a4f1 100644 --- a/core/src/apps/bitcoin/sign_tx/approvers.py +++ b/core/src/apps/bitcoin/sign_tx/approvers.py @@ -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.