def approve_sign_tx(self, msg: SignTx, fee: int) -> bool: if self.params.max_total_fee < fee or msg.coin_name != self.params.coin_name: return False self.params.max_total_fee -= fee authorization.set(self.params) return True
def approve_sign_tx(self, msg: SignTx) -> bool: if self.params.max_rounds < 1 or msg.coin_name != self.params.coin_name: return False self.params.max_rounds -= 1 authorization.set(self.params) return True
async def authorize_coinjoin(ctx: wire.Context, msg: AuthorizeCoinJoin, keychain: Keychain, coin: CoinInfo) -> Success: if len(msg.coordinator) > _MAX_COORDINATOR_LEN or not all( 32 <= ord(x) <= 126 for x in msg.coordinator): raise wire.DataError("Invalid coordinator name.") if msg.max_rounds > _MAX_ROUNDS and safety_checks.is_strict(): raise wire.DataError("The number of rounds is unexpectedly large.") if (msg.max_coordinator_fee_rate > _MAX_COORDINATOR_FEE_RATE and safety_checks.is_strict()): raise wire.DataError( "The coordination fee rate is unexpectedly large.") if msg.max_fee_per_kvbyte > 10 * coin.maxfee_kb and safety_checks.is_strict( ): raise wire.DataError("The fee per vbyte is unexpectedly large.") if not msg.address_n: raise wire.DataError("Empty path not allowed.") await confirm_action( ctx, "coinjoin_coordinator", title="Authorize CoinJoin", description= "Do you really want to take part in a CoinJoin transaction at:\n{}", description_param=msg.coordinator, description_param_font=ui.MONO, icon=ui.ICON_RECOVERY, ) max_fee_per_vbyte = format_amount(msg.max_fee_per_kvbyte, 3) await confirm_coinjoin(ctx, coin.coin_name, msg.max_rounds, max_fee_per_vbyte) validation_path = msg.address_n + [0] * BIP32_WALLET_DEPTH await validate_path( ctx, keychain, validation_path, validate_path_against_script_type(coin, address_n=validation_path, script_type=msg.script_type), ) if msg.max_fee_per_kvbyte > coin.maxfee_kb: await confirm_metadata( ctx, "fee_over_threshold", "High mining fee", "The mining fee of\n{} sats/vbyte\nis unexpectedly high.", max_fee_per_vbyte, ButtonRequestType.FeeOverThreshold, ) authorization.set(msg) return Success(message="CoinJoin authorized")
async def authorize_coinjoin(ctx: wire.Context, msg: AuthorizeCoinJoin, keychain: Keychain, coin: CoinInfo) -> Success: if len(msg.coordinator) > _MAX_COORDINATOR_LEN or not all( 32 <= ord(x) <= 126 for x in msg.coordinator): raise wire.DataError("Invalid coordinator name.") if not msg.address_n: raise wire.DataError("Empty path not allowed.") validation_path = msg.address_n + [0] * BIP32_WALLET_DEPTH await validate_path( ctx, keychain, validation_path, validate_path_against_script_type(coin, address_n=validation_path, script_type=msg.script_type), ) await confirm_action( ctx, "coinjoin_coordinator", title="Authorize CoinJoin", description= "Do you really want to take part in a CoinJoin transaction at:\n{}", description_param=msg.coordinator, description_param_font=ui.MONO, icon=ui.ICON_RECOVERY, ) if msg.fee_per_anonymity: fee_per_anonymity: str | None = format_amount( msg.fee_per_anonymity, FEE_PER_ANONYMITY_DECIMALS) else: fee_per_anonymity = None await confirm_coinjoin( ctx, fee_per_anonymity, format_coin_amount(msg.max_total_fee, coin, msg.amount_unit), ) authorization.set(msg) return Success(message="CoinJoin authorized")