mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-03-23 19:45:46 +00:00
src/apps/wallet/sign_tx: op_return ui
This commit is contained in:
parent
9f48e3d471
commit
f9b16cfa34
@ -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)
|
||||
|
@ -70,7 +70,7 @@ def multisig_pubkey_index(multisig: MultisigRedeemScriptType, pubkey: bytes) ->
|
||||
if multisig_get_pubkey(hd) == pubkey:
|
||||
return i
|
||||
raise MultisigError(FailureType.DataError,
|
||||
'Pubkey not found in multisig script')
|
||||
'Pubkey not found in multisig script')
|
||||
|
||||
|
||||
def multisig_get_pubkey(hd: HDNodePathType) -> bytes:
|
||||
|
@ -1,12 +1,10 @@
|
||||
from trezor import ui, wire
|
||||
from trezor.crypto import base58
|
||||
from trezor.crypto.curve import secp256k1
|
||||
from trezor.crypto.hashlib import ripemd160, sha256
|
||||
from trezor.messages.InputScriptType import SPENDADDRESS, SPENDP2SHWITNESS, SPENDWITNESS
|
||||
from trezor.messages.FailureType import ProcessError
|
||||
from trezor.messages.Success import Success
|
||||
from trezor.ui.text import Text
|
||||
from apps.common import address_type, coins
|
||||
from apps.common import coins
|
||||
from apps.common.confirm import require_confirm
|
||||
from apps.common.signverify import message_digest, split_message
|
||||
from apps.wallet.sign_tx.addresses import address_pkh, address_p2wpkh_in_p2sh, address_p2wpkh
|
||||
|
Loading…
Reference in New Issue
Block a user