feat(core): implement amount_unit for AuthorizeCoinJoin and SignTx

pull/1426/head
Pavol Rusnak 4 years ago committed by Tomas Susanka
parent 345ef52949
commit 7f0e939359

@ -13,6 +13,7 @@ from apps.common.paths import validate_path
from .authorization import FEE_PER_ANONYMITY_DECIMALS, CoinJoinAuthorization
from .common import BIP32_WALLET_DEPTH
from .keychain import get_keychain_for_coin, validate_path_against_script_type
from .sign_tx.layout import format_coin_amount
if False:
from trezor import wire
@ -62,8 +63,10 @@ async def authorize_coinjoin(ctx: wire.Context, msg: AuthorizeCoinJoin) -> Succe
)
text.normal("Maximum total fees:")
text.bold(
"{} {}".format(
format_amount(msg.max_total_fee, coin.decimals), coin.coin_shortcut
format_coin_amount(
msg.max_total_fee,
coin,
msg.amount_unit,
)
)
await require_hold_to_confirm(ctx, text)

@ -42,6 +42,8 @@ class Approver:
self.orig_total_out = 0 # sum of original output amounts
self.orig_change_out = 0 # sum of original change output amounts
self.amount_unit = tx.amount_unit
async def add_internal_input(self, txi: TxInput) -> None:
self.weight.add_input(txi)
self.total_in += txi.amount
@ -121,7 +123,7 @@ class BasicApprover(Approver):
"Adding new OP_RETURN outputs in replacement transactions is not supported."
)
else:
await helpers.confirm_output(txo, self.coin)
await helpers.confirm_output(txo, self.coin, self.amount_unit)
async def approve_tx(self, tx_info: TxInfo, orig_txs: List[OriginalTxInfo]) -> None:
fee = self.total_in - self.total_out
@ -139,7 +141,7 @@ class BasicApprover(Approver):
if fee > fee_threshold:
if fee > 10 * fee_threshold and safety_checks.is_strict():
raise wire.DataError("The fee is unexpectedly large")
await helpers.confirm_feeoverthreshold(fee, self.coin)
await helpers.confirm_feeoverthreshold(fee, self.coin, self.amount_unit)
if self.change_count > self.MAX_SILENT_CHANGE_COUNT:
await helpers.confirm_change_count_over_threshold(self.change_count)
@ -195,7 +197,7 @@ class BasicApprover(Approver):
# what it's worth, see PR #1292.
if spending > orig_spending or self.external_in == self.orig_external_in:
await helpers.confirm_modify_fee(
spending - orig_spending, fee, self.coin
spending - orig_spending, fee, self.coin, self.amount_unit
)
else:
# Standard transaction.
@ -205,9 +207,11 @@ class BasicApprover(Approver):
)
if not self.external_in:
await helpers.confirm_total(total, fee, self.coin)
await helpers.confirm_total(total, fee, self.coin, self.amount_unit)
else:
await helpers.confirm_joint_total(spending, total, self.coin)
await helpers.confirm_joint_total(
spending, total, self.coin, self.amount_unit
)
class CoinJoinApprover(Approver):

@ -32,6 +32,7 @@ from . import layout
if False:
from typing import Any, Awaitable, Optional
from trezor.messages.SignTx import EnumTypeAmountUnit
# Machine instructions
@ -44,12 +45,15 @@ class UiConfirm:
class UiConfirmOutput(UiConfirm):
def __init__(self, output: TxOutput, coin: CoinInfo):
def __init__(
self, output: TxOutput, coin: CoinInfo, amount_unit: EnumTypeAmountUnit
):
self.output = output
self.coin = coin
self.amount_unit = amount_unit
def confirm_dialog(self, ctx: wire.Context) -> Awaitable[Any]:
return layout.confirm_output(ctx, self.output, self.coin)
return layout.confirm_output(ctx, self.output, self.coin, self.amount_unit)
__eq__ = utils.obj_eq
@ -66,50 +70,70 @@ class UiConfirmReplacement(UiConfirm):
class UiConfirmModifyFee(UiConfirm):
def __init__(self, user_fee_change: int, total_fee_new: int, coin: CoinInfo):
def __init__(
self,
user_fee_change: int,
total_fee_new: int,
coin: CoinInfo,
amount_unit: EnumTypeAmountUnit,
):
self.user_fee_change = user_fee_change
self.total_fee_new = total_fee_new
self.coin = coin
self.amount_unit = amount_unit
def confirm_dialog(self, ctx: wire.Context) -> Awaitable[Any]:
return layout.confirm_modify_fee(
ctx, self.user_fee_change, self.total_fee_new, self.coin
ctx, self.user_fee_change, self.total_fee_new, self.coin, self.amount_unit
)
__eq__ = utils.obj_eq
class UiConfirmTotal(UiConfirm):
def __init__(self, spending: int, fee: int, coin: CoinInfo):
def __init__(
self, spending: int, fee: int, coin: CoinInfo, amount_unit: EnumTypeAmountUnit
):
self.spending = spending
self.fee = fee
self.coin = coin
self.amount_unit = amount_unit
def confirm_dialog(self, ctx: wire.Context) -> Awaitable[Any]:
return layout.confirm_total(ctx, self.spending, self.fee, self.coin)
return layout.confirm_total(
ctx, self.spending, self.fee, self.coin, self.amount_unit
)
__eq__ = utils.obj_eq
class UiConfirmJointTotal(UiConfirm):
def __init__(self, spending: int, total: int, coin: CoinInfo):
def __init__(
self, spending: int, total: int, coin: CoinInfo, amount_unit: EnumTypeAmountUnit
):
self.spending = spending
self.total = total
self.coin = coin
self.amount_unit = amount_unit
def confirm_dialog(self, ctx: wire.Context) -> Awaitable[Any]:
return layout.confirm_joint_total(ctx, self.spending, self.total, self.coin)
return layout.confirm_joint_total(
ctx, self.spending, self.total, self.coin, self.amount_unit
)
__eq__ = utils.obj_eq
class UiConfirmFeeOverThreshold(UiConfirm):
def __init__(self, fee: int, coin: CoinInfo):
def __init__(self, fee: int, coin: CoinInfo, amount_unit: EnumTypeAmountUnit):
self.fee = fee
self.coin = coin
self.amount_unit = amount_unit
def confirm_dialog(self, ctx: wire.Context) -> Awaitable[Any]:
return layout.confirm_feeoverthreshold(ctx, self.fee, self.coin)
return layout.confirm_feeoverthreshold(
ctx, self.fee, self.coin, self.amount_unit
)
__eq__ = utils.obj_eq
@ -147,28 +171,28 @@ class UiConfirmNonDefaultLocktime(UiConfirm):
__eq__ = utils.obj_eq
def confirm_output(output: TxOutput, coin: CoinInfo) -> Awaitable[None]: # type: ignore
return (yield UiConfirmOutput(output, coin))
def confirm_output(output: TxOutput, coin: CoinInfo, amount_unit: EnumTypeAmountUnit) -> Awaitable[None]: # type: ignore
return (yield UiConfirmOutput(output, coin, amount_unit))
def confirm_replacement(description: str, txid: bytes) -> Awaitable[Any]: # type: ignore
return (yield UiConfirmReplacement(description, txid))
def confirm_modify_fee(user_fee_change: int, total_fee_new: int, coin: CoinInfo) -> Awaitable[Any]: # type: ignore
return (yield UiConfirmModifyFee(user_fee_change, total_fee_new, coin))
def confirm_modify_fee(user_fee_change: int, total_fee_new: int, coin: CoinInfo, amount_unit: EnumTypeAmountUnit) -> Awaitable[Any]: # type: ignore
return (yield UiConfirmModifyFee(user_fee_change, total_fee_new, coin, amount_unit))
def confirm_total(spending: int, fee: int, coin: CoinInfo) -> Awaitable[None]: # type: ignore
return (yield UiConfirmTotal(spending, fee, coin))
def confirm_total(spending: int, fee: int, coin: CoinInfo, amount_unit: EnumTypeAmountUnit) -> Awaitable[None]: # type: ignore
return (yield UiConfirmTotal(spending, fee, coin, amount_unit))
def confirm_joint_total(spending: int, total: int, coin: CoinInfo) -> Awaitable[Any]: # type: ignore
return (yield UiConfirmJointTotal(spending, total, coin))
def confirm_joint_total(spending: int, total: int, coin: CoinInfo, amount_unit: EnumTypeAmountUnit) -> Awaitable[Any]: # type: ignore
return (yield UiConfirmJointTotal(spending, total, coin, amount_unit))
def confirm_feeoverthreshold(fee: int, coin: CoinInfo) -> Awaitable[Any]: # type: ignore
return (yield UiConfirmFeeOverThreshold(fee, coin))
def confirm_feeoverthreshold(fee: int, coin: CoinInfo, amount_unit: EnumTypeAmountUnit) -> Awaitable[Any]: # type: ignore
return (yield UiConfirmFeeOverThreshold(fee, coin, amount_unit))
def confirm_change_count_over_threshold(change_count: int) -> Awaitable[Any]: # type: ignore

@ -2,7 +2,7 @@ from micropython import const
from ubinascii import hexlify
from trezor import ui
from trezor.messages import ButtonRequestType, OutputScriptType
from trezor.messages import AmountUnit, ButtonRequestType, OutputScriptType
from trezor.strings import format_amount
from trezor.ui.text import Text
from trezor.utils import chunks
@ -15,6 +15,7 @@ from . import omni
if False:
from typing import Iterator
from trezor import wire
from trezor.messages.SignTx import EnumTypeAmountUnit
from trezor.messages.TxOutput import TxOutput
from apps.common.coininfo import CoinInfo
@ -22,8 +23,21 @@ if False:
_LOCKTIME_TIMESTAMP_MIN_VALUE = const(500_000_000)
def format_coin_amount(amount: int, coin: CoinInfo) -> str:
return "%s %s" % (format_amount(amount, coin.decimals), coin.coin_shortcut)
def format_coin_amount(
amount: int, coin: CoinInfo, amount_unit: EnumTypeAmountUnit
) -> str:
decimals, shortcut = coin.decimals, coin.coin_shortcut
if amount_unit == AmountUnit.SATOSHI:
decimals = 0
shortcut = "sat " + shortcut
elif amount_unit == AmountUnit.MICROBITCOIN and decimals >= 6:
decimals -= 6
shortcut = "u" + shortcut
elif amount_unit == AmountUnit.MILLIBITCOIN and decimals >= 3:
decimals -= 3
shortcut = "m" + shortcut
# we don't need to do anything for AmountUnit.BITCOIN
return "%s %s" % (format_amount(amount, decimals), shortcut)
def split_address(address: str) -> Iterator[str]:
@ -34,7 +48,9 @@ def split_op_return(data: str) -> Iterator[str]:
return chunks(data, 18)
async def confirm_output(ctx: wire.Context, output: TxOutput, coin: CoinInfo) -> None:
async def confirm_output(
ctx: wire.Context, output: TxOutput, coin: CoinInfo, amount_unit: EnumTypeAmountUnit
) -> None:
if output.script_type == OutputScriptType.PAYTOOPRETURN:
data = output.op_return_data
assert data is not None
@ -54,7 +70,7 @@ async def confirm_output(ctx: wire.Context, output: TxOutput, coin: CoinInfo) ->
assert address is not None
address_short = addresses.address_short(coin, address)
text = Text("Confirm sending", ui.ICON_SEND, ui.GREEN)
text.normal(format_coin_amount(output.amount, coin) + " to")
text.normal(format_coin_amount(output.amount, coin, amount_unit) + " to")
text.mono(*split_address(address_short))
await require_confirm(ctx, text, ButtonRequestType.ConfirmOutput)
@ -70,7 +86,11 @@ async def confirm_replacement(ctx: wire.Context, description: str, txid: bytes)
async def confirm_modify_fee(
ctx: wire.Context, user_fee_change: int, total_fee_new: int, coin: CoinInfo
ctx: wire.Context,
user_fee_change: int,
total_fee_new: int,
coin: CoinInfo,
amount_unit: EnumTypeAmountUnit,
) -> None:
text = Text("Fee modification", ui.ICON_SEND, ui.GREEN)
if user_fee_change == 0:
@ -80,39 +100,49 @@ async def confirm_modify_fee(
text.normal("Decrease your fee by:")
else:
text.normal("Increase your fee by:")
text.bold(format_coin_amount(abs(user_fee_change), coin))
text.bold(format_coin_amount(abs(user_fee_change), coin, amount_unit))
text.br_half()
text.normal("Transaction fee:")
text.bold(format_coin_amount(total_fee_new, coin))
text.bold(format_coin_amount(total_fee_new, coin, amount_unit))
await require_hold_to_confirm(ctx, text, ButtonRequestType.SignTx)
async def confirm_joint_total(
ctx: wire.Context, spending: int, total: int, coin: CoinInfo
ctx: wire.Context,
spending: int,
total: int,
coin: CoinInfo,
amount_unit: EnumTypeAmountUnit,
) -> None:
text = Text("Joint transaction", ui.ICON_SEND, ui.GREEN)
text.normal("You are contributing:")
text.bold(format_coin_amount(spending, coin))
text.bold(format_coin_amount(spending, coin, amount_unit))
text.normal("to the total amount:")
text.bold(format_coin_amount(total, coin))
text.bold(format_coin_amount(total, coin, amount_unit))
await require_hold_to_confirm(ctx, text, ButtonRequestType.SignTx)
async def confirm_total(
ctx: wire.Context, spending: int, fee: int, coin: CoinInfo
ctx: wire.Context,
spending: int,
fee: int,
coin: CoinInfo,
amount_unit: EnumTypeAmountUnit,
) -> None:
text = Text("Confirm transaction", ui.ICON_SEND, ui.GREEN)
text.normal("Total amount:")
text.bold(format_coin_amount(spending, coin))
text.bold(format_coin_amount(spending, coin, amount_unit))
text.normal("including fee:")
text.bold(format_coin_amount(fee, coin))
text.bold(format_coin_amount(fee, coin, amount_unit))
await require_hold_to_confirm(ctx, text, ButtonRequestType.SignTx)
async def confirm_feeoverthreshold(ctx: wire.Context, fee: int, coin: CoinInfo) -> None:
async def confirm_feeoverthreshold(
ctx: wire.Context, fee: int, coin: CoinInfo, amount_unit: EnumTypeAmountUnit
) -> None:
text = Text("High fee", ui.ICON_SEND, ui.GREEN)
text.normal("The fee of")
text.bold(format_coin_amount(fee, coin))
text.bold(format_coin_amount(fee, coin, amount_unit))
text.normal("is unexpectedly high.", "Continue?")
await require_confirm(ctx, text, ButtonRequestType.FeeOverThreshold)

@ -21,6 +21,7 @@ from trezor.messages.TxRequest import TxRequest
from trezor.messages.RequestType import TXINPUT, TXMETA, TXOUTPUT, TXFINISHED
from trezor.messages.TxRequestDetailsType import TxRequestDetailsType
from trezor.messages.TxRequestSerializedType import TxRequestSerializedType
from trezor.messages import AmountUnit
from trezor.messages import InputScriptType
from trezor.messages import OutputScriptType
from trezor import wire
@ -92,16 +93,16 @@ class TestSignSegwitTxNativeP2WPKH(unittest.TestCase):
TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None), serialized=EMPTY_SERIALIZED),
TxAckOutput(tx=TxAckOutputWrapper(output=out1)),
helpers.UiConfirmOutput(out1, coin),
helpers.UiConfirmOutput(out1, coin, AmountUnit.BITCOIN),
True,
TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=1, tx_hash=None), serialized=EMPTY_SERIALIZED),
TxAckOutput(tx=TxAckOutputWrapper(output=out2)),
helpers.UiConfirmOutput(out2, coin),
helpers.UiConfirmOutput(out2, coin, AmountUnit.BITCOIN),
True,
helpers.UiConfirmTotal(12300000, 11000, coin),
helpers.UiConfirmTotal(12300000, 11000, coin, AmountUnit.BITCOIN),
True,
# check prev tx
@ -223,13 +224,13 @@ class TestSignSegwitTxNativeP2WPKH(unittest.TestCase):
TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None), serialized=EMPTY_SERIALIZED),
TxAckOutput(tx=TxAckOutputWrapper(output=out1)),
helpers.UiConfirmOutput(out1, coin),
helpers.UiConfirmOutput(out1, coin, AmountUnit.BITCOIN),
True,
TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=1, tx_hash=None), serialized=EMPTY_SERIALIZED),
TxAckOutput(tx=TxAckOutputWrapper(output=out2)),
helpers.UiConfirmTotal(5000000 + 11000, 11000, coin),
helpers.UiConfirmTotal(5000000 + 11000, 11000, coin, AmountUnit.BITCOIN),
True,
# check prev tx

@ -21,6 +21,7 @@ from trezor.messages.TxRequest import TxRequest
from trezor.messages.RequestType import TXINPUT, TXMETA, TXOUTPUT, TXFINISHED
from trezor.messages.TxRequestDetailsType import TxRequestDetailsType
from trezor.messages.TxRequestSerializedType import TxRequestSerializedType
from trezor.messages import AmountUnit
from trezor.messages import InputScriptType
from trezor.messages import OutputScriptType
@ -90,19 +91,19 @@ class TestSignSegwitTxNativeP2WPKH_GRS(unittest.TestCase):
TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None), serialized=EMPTY_SERIALIZED),
TxAckOutput(tx=TxAckOutputWrapper(output=out1)),
helpers.UiConfirmOutput(out1, coin),
helpers.UiConfirmOutput(out1, coin, AmountUnit.BITCOIN),
True,
TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=1, tx_hash=None), serialized=EMPTY_SERIALIZED),
TxAckOutput(tx=TxAckOutputWrapper(output=out2)),
helpers.UiConfirmOutput(out2, coin),
helpers.UiConfirmOutput(out2, coin, AmountUnit.BITCOIN),
True,
helpers.UiConfirmNonDefaultLocktime(tx.lock_time, lock_time_disabled=False),
True,
helpers.UiConfirmTotal(12300000, 11000, coin),
helpers.UiConfirmTotal(12300000, 11000, coin, AmountUnit.BITCOIN),
True,
# check prev tx
@ -221,7 +222,7 @@ class TestSignSegwitTxNativeP2WPKH_GRS(unittest.TestCase):
TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None), serialized=EMPTY_SERIALIZED),
TxAckOutput(tx=TxAckOutputWrapper(output=out1)),
helpers.UiConfirmOutput(out1, coin),
helpers.UiConfirmOutput(out1, coin, AmountUnit.BITCOIN),
True,
TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=1, tx_hash=None), serialized=EMPTY_SERIALIZED),
@ -230,7 +231,7 @@ class TestSignSegwitTxNativeP2WPKH_GRS(unittest.TestCase):
helpers.UiConfirmNonDefaultLocktime(tx.lock_time, lock_time_disabled=False),
True,
helpers.UiConfirmTotal(5000000 + 11000, 11000, coin),
helpers.UiConfirmTotal(5000000 + 11000, 11000, coin, AmountUnit.BITCOIN),
True,
# check prev tx

@ -21,6 +21,7 @@ from trezor.messages.TxRequest import TxRequest
from trezor.messages.RequestType import TXINPUT, TXMETA, TXOUTPUT, TXFINISHED
from trezor.messages.TxRequestDetailsType import TxRequestDetailsType
from trezor.messages.TxRequestSerializedType import TxRequestSerializedType
from trezor.messages import AmountUnit
from trezor.messages import InputScriptType
from trezor.messages import OutputScriptType
from trezor import wire
@ -89,16 +90,16 @@ class TestSignSegwitTxP2WPKHInP2SH(unittest.TestCase):
TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None), serialized=EMPTY_SERIALIZED),
TxAckOutput(tx=TxAckOutputWrapper(output=out1)),
helpers.UiConfirmOutput(out1, coin),
helpers.UiConfirmOutput(out1, coin, AmountUnit.BITCOIN),
True,
TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=1, tx_hash=None), serialized=EMPTY_SERIALIZED),
TxAckOutput(tx=TxAckOutputWrapper(output=out2)),
helpers.UiConfirmOutput(out2, coin),
helpers.UiConfirmOutput(out2, coin, AmountUnit.BITCOIN),
True,
helpers.UiConfirmTotal(123445789 + 11000, 11000, coin),
helpers.UiConfirmTotal(123445789 + 11000, 11000, coin, AmountUnit.BITCOIN),
True,
# check prev tx
@ -218,13 +219,13 @@ class TestSignSegwitTxP2WPKHInP2SH(unittest.TestCase):
TxAckOutput(tx=TxAckOutputWrapper(output=out1)),
helpers.UiConfirmOutput(out1, coin),
helpers.UiConfirmOutput(out1, coin, AmountUnit.BITCOIN),
True,
TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=1, tx_hash=None), serialized=EMPTY_SERIALIZED),
TxAckOutput(tx=TxAckOutputWrapper(output=out2)),
helpers.UiConfirmTotal(12300000 + 11000, 11000, coin),
helpers.UiConfirmTotal(12300000 + 11000, 11000, coin, AmountUnit.BITCOIN),
True,
# check prev tx
@ -364,13 +365,13 @@ class TestSignSegwitTxP2WPKHInP2SH(unittest.TestCase):
TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None), serialized=EMPTY_SERIALIZED),
TxAckOutput(tx=TxAckOutputWrapper(output=out1)),
helpers.UiConfirmOutput(out1, coin),
helpers.UiConfirmOutput(out1, coin, AmountUnit.BITCOIN),
True,
TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=1, tx_hash=None), serialized=EMPTY_SERIALIZED),
TxAckOutput(tx=TxAckOutputWrapper(output=out2)),
helpers.UiConfirmTotal(9 - 1, 9 - 8 - 1, coin),
helpers.UiConfirmTotal(9 - 1, 9 - 8 - 1, coin, AmountUnit.BITCOIN),
True,
# check prev tx

@ -21,6 +21,7 @@ from trezor.messages.TxRequest import TxRequest
from trezor.messages.RequestType import TXINPUT, TXMETA, TXOUTPUT, TXFINISHED
from trezor.messages.TxRequestDetailsType import TxRequestDetailsType
from trezor.messages.TxRequestSerializedType import TxRequestSerializedType
from trezor.messages import AmountUnit
from trezor.messages import InputScriptType
from trezor.messages import OutputScriptType
@ -90,19 +91,19 @@ class TestSignSegwitTxP2WPKHInP2SH_GRS(unittest.TestCase):
TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None), serialized=EMPTY_SERIALIZED),
TxAckOutput(tx=TxAckOutputWrapper(output=out1)),
helpers.UiConfirmOutput(out1, coin),
helpers.UiConfirmOutput(out1, coin, AmountUnit.BITCOIN),
True,
TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=1, tx_hash=None), serialized=EMPTY_SERIALIZED),
TxAckOutput(tx=TxAckOutputWrapper(output=out2)),
helpers.UiConfirmOutput(out2, coin),
helpers.UiConfirmOutput(out2, coin, AmountUnit.BITCOIN),
True,
helpers.UiConfirmNonDefaultLocktime(tx.lock_time, lock_time_disabled=False),
True,
helpers.UiConfirmTotal(123445789 + 11000, 11000, coin),
helpers.UiConfirmTotal(123445789 + 11000, 11000, coin, AmountUnit.BITCOIN),
True,
# check prev tx
@ -221,7 +222,7 @@ class TestSignSegwitTxP2WPKHInP2SH_GRS(unittest.TestCase):
TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None), serialized=EMPTY_SERIALIZED),
TxAckOutput(tx=TxAckOutputWrapper(output=out1)),
helpers.UiConfirmOutput(out1, coin),
helpers.UiConfirmOutput(out1, coin, AmountUnit.BITCOIN),
True,
TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=1, tx_hash=None), serialized=EMPTY_SERIALIZED),
@ -230,7 +231,7 @@ class TestSignSegwitTxP2WPKHInP2SH_GRS(unittest.TestCase):
helpers.UiConfirmNonDefaultLocktime(tx.lock_time, lock_time_disabled=False),
True,
helpers.UiConfirmTotal(12300000 + 11000, 11000, coin),
helpers.UiConfirmTotal(12300000 + 11000, 11000, coin, AmountUnit.BITCOIN),
True,
# check prev tx

@ -21,6 +21,7 @@ from trezor.messages.TxRequest import TxRequest
from trezor.messages.RequestType import TXINPUT, TXOUTPUT, TXMETA
from trezor.messages.TxRequestDetailsType import TxRequestDetailsType
from trezor.messages.TxRequestSerializedType import TxRequestSerializedType
from trezor.messages import AmountUnit
from trezor.messages import OutputScriptType
from apps.common import coins
@ -85,11 +86,11 @@ class TestSignTxFeeThreshold(unittest.TestCase):
TxAckPrevOutput(tx=TxAckPrevOutputWrapper(output=pout1)),
TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None), serialized=None),
TxAckOutput(tx=TxAckOutputWrapper(output=out1)),
helpers.UiConfirmOutput(out1, coin_bitcoin),
helpers.UiConfirmOutput(out1, coin_bitcoin, AmountUnit.BITCOIN),
True,
helpers.UiConfirmFeeOverThreshold(100000, coin_bitcoin),
True,
helpers.UiConfirmTotal(290000 + 100000, 100000, coin_bitcoin),
helpers.UiConfirmTotal(290000 + 100000, 100000, coin_bitcoin, AmountUnit.BITCOIN),
True,
TxRequest(request_type=TXINPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None), serialized=None),
]
@ -143,9 +144,9 @@ class TestSignTxFeeThreshold(unittest.TestCase):
True,
TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None), serialized=EMPTY_SERIALIZED),
TxAckOutput(tx=TxAckOutputWrapper(output=out1)),
helpers.UiConfirmOutput(out1, coin_bitcoin),
helpers.UiConfirmOutput(out1, coin_bitcoin, AmountUnit.BITCOIN),
True,
helpers.UiConfirmTotal(300000 + 90000, 90000, coin_bitcoin),
helpers.UiConfirmTotal(300000 + 90000, 90000, coin_bitcoin, AmountUnit.BITCOIN),
True,
TxRequest(request_type=TXINPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None), serialized=EMPTY_SERIALIZED),
TxAckInput(tx=TxAckInputWrapper(input=inp1)),

@ -21,6 +21,7 @@ from trezor.messages.TxRequest import TxRequest
from trezor.messages.RequestType import TXINPUT, TXOUTPUT, TXMETA, TXFINISHED
from trezor.messages.TxRequestDetailsType import TxRequestDetailsType
from trezor.messages.TxRequestSerializedType import TxRequestSerializedType
from trezor.messages import AmountUnit
from trezor.messages import OutputScriptType
from apps.common import coins
@ -74,9 +75,9 @@ class TestSignTx(unittest.TestCase):
TxAckInput(tx=TxAckInputWrapper(input=inp1)),
TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None), serialized=EMPTY_SERIALIZED),
TxAckOutput(tx=TxAckOutputWrapper(output=out1)),
helpers.UiConfirmOutput(out1, coin_bitcoin),
helpers.UiConfirmOutput(out1, coin_bitcoin, AmountUnit.BITCOIN),
True,
helpers.UiConfirmTotal(380000 + 10000, 10000, coin_bitcoin),
helpers.UiConfirmTotal(380000 + 10000, 10000, coin_bitcoin, AmountUnit.BITCOIN),
True,
# ButtonRequest(code=ButtonRequest_ConfirmOutput),
# ButtonRequest(code=ButtonRequest_SignTx),

@ -21,6 +21,7 @@ from trezor.messages.TxRequest import TxRequest
from trezor.messages.RequestType import TXINPUT, TXOUTPUT, TXMETA, TXFINISHED
from trezor.messages.TxRequestDetailsType import TxRequestDetailsType
from trezor.messages.TxRequestSerializedType import TxRequestSerializedType
from trezor.messages import AmountUnit
from trezor.messages import OutputScriptType
from apps.common import coins
@ -67,9 +68,9 @@ class TestSignTx_GRS(unittest.TestCase):
TxAckInput(tx=TxAckInputWrapper(input=inp1)),
TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None), serialized=EMPTY_SERIALIZED),
TxAckOutput(tx=TxAckOutputWrapper(output=out1)),
helpers.UiConfirmOutput(out1, coin),
helpers.UiConfirmOutput(out1, coin, AmountUnit.BITCOIN),
True,
helpers.UiConfirmTotal(210016, 192, coin),
helpers.UiConfirmTotal(210016, 192, coin, AmountUnit.BITCOIN),
True,
TxRequest(request_type=TXINPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None), serialized=EMPTY_SERIALIZED),
TxAckInput(tx=TxAckInputWrapper(input=inp1)),

@ -341,6 +341,11 @@
"test_msg_signtx.py-test_testnet_one_two_fee": "cfd5c83510c044c456622298138e222aee135a6df607bb6e5603228535f0762f",
"test_msg_signtx.py-test_two_changes": "832d4b168551c37c9e09cf2ce16fd062d6599bcd0473305f70c5175bd874a920",
"test_msg_signtx.py-test_two_two": "57707ecbcb77f670148c6076724b3da2e880d27ecf86e29135af4a5aeef6fdbc",
"test_msg_signtx_amount_unit.py::test_signtx[0]": "6e2e50b35c091b2b354f902b6870aae7d6c6d922505700ec6c2e7426e71aca5d",
"test_msg_signtx_amount_unit.py::test_signtx[1]": "042c9893993bdc7e6a3f3aaaa12c0748ce1b77c38517fb46db8f40012a502ab4",
"test_msg_signtx_amount_unit.py::test_signtx[2]": "5c152a03da99bf5c90ef67c84dd8930d10bca736d86d0ceb72c4e415baadd51f",
"test_msg_signtx_amount_unit.py::test_signtx[3]": "11d05687339364b3268b64be6f771194c64137efa8e69b8c6197f5e01c960348",
"test_msg_signtx_amount_unit.py::test_signtx[None]": "6e2e50b35c091b2b354f902b6870aae7d6c6d922505700ec6c2e7426e71aca5d",
"test_msg_signtx_bcash.py-test_attack_change_input": "a03ee0471deeb54d51b73c0fde08795ab0ba8c37daec2d43f5637e705420b435",
"test_msg_signtx_bcash.py-test_send_bch_change": "a03ee0471deeb54d51b73c0fde08795ab0ba8c37daec2d43f5637e705420b435",
"test_msg_signtx_bcash.py-test_send_bch_external_presigned": "8565118d5647934c84124cb65d34f8299a98631631666dc5b1d02595d462fee0",

Loading…
Cancel
Save