|
|
|
@ -1,3 +1,4 @@
|
|
|
|
|
from ubinascii import hexlify
|
|
|
|
|
from trezor import ui
|
|
|
|
|
from trezor.utils import chunks, format_amount
|
|
|
|
|
from trezor.ui.text import Text
|
|
|
|
@ -15,26 +16,39 @@ def split_address(address):
|
|
|
|
|
return chunks(address, 17)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def split_op_return(data):
|
|
|
|
|
return chunks(data, 18)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def confirm_output(ctx, output, coin):
|
|
|
|
|
if output.script_type == OutputScriptType.PAYTOOPRETURN:
|
|
|
|
|
address = 'OP_RETURN' # TODO: handle OP_RETURN correctly
|
|
|
|
|
data = hexlify(output.op_return_data).decode()
|
|
|
|
|
if len(data) >= 18 * 5:
|
|
|
|
|
data = data[:(18 * 5 - 3)] + '...'
|
|
|
|
|
content = Text('OP_RETURN', ui.ICON_DEFAULT,
|
|
|
|
|
ui.MONO, *split_op_return(data))
|
|
|
|
|
else:
|
|
|
|
|
address = output.address
|
|
|
|
|
content = Text('Confirm output', ui.ICON_DEFAULT,
|
|
|
|
|
ui.BOLD, format_coin_amount(output.amount, coin),
|
|
|
|
|
ui.NORMAL, 'to',
|
|
|
|
|
ui.MONO, *split_address(address))
|
|
|
|
|
content = Text('Confirm sending', ui.ICON_DEFAULT,
|
|
|
|
|
ui.NORMAL, format_coin_amount(output.amount, coin) + ' to',
|
|
|
|
|
ui.MONO, *split_address(address))
|
|
|
|
|
return await confirm(ctx, content, ButtonRequestType.ConfirmOutput)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def confirm_total(ctx, spending, fee, coin):
|
|
|
|
|
content = Text('Confirm transaction', ui.ICON_DEFAULT,
|
|
|
|
|
'Sending: %s' % format_coin_amount(spending, coin),
|
|
|
|
|
'Fee: %s' % format_coin_amount(fee, coin))
|
|
|
|
|
'Total amount:',
|
|
|
|
|
ui.BOLD, format_coin_amount(spending, coin),
|
|
|
|
|
ui.NORMAL, 'including fee:',
|
|
|
|
|
ui.BOLD, format_coin_amount(fee, coin))
|
|
|
|
|
return await hold_to_confirm(ctx, content, ButtonRequestType.SignTx)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def confirm_feeoverthreshold(ctx, fee, coin):
|
|
|
|
|
content = Text('Confirm high fee:', ui.ICON_DEFAULT,
|
|
|
|
|
ui.BOLD, format_coin_amount(fee, coin))
|
|
|
|
|
content = Text('High fee', ui.ICON_DEFAULT,
|
|
|
|
|
'The fee of',
|
|
|
|
|
ui.BOLD, format_coin_amount(fee, coin),
|
|
|
|
|
ui.NORMAL, 'is unexpectedly high.',
|
|
|
|
|
'Continue?')
|
|
|
|
|
|
|
|
|
|
return await confirm(ctx, content, ButtonRequestType.FeeOverThreshold)
|
|
|
|
|