1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-16 19:38:09 +00:00

nem: importance transfer signing

This commit is contained in:
Tomas Susanka 2018-03-29 12:40:13 +02:00 committed by Jan Pochyla
parent 52affe2897
commit 368b979a8a
3 changed files with 19 additions and 4 deletions

View File

@ -12,7 +12,6 @@ from trezor.crypto import random
async def nem_sign_tx(ctx, msg: NEMSignTx):
validate(msg)
node = await seed.derive_node(ctx, msg.transaction.address_n, NEM_CURVE)
tx = bytearray()
if msg.transfer:
tx = await _transfer(ctx, node, msg)
@ -25,6 +24,10 @@ async def nem_sign_tx(ctx, msg: NEMSignTx):
tx = await _supply_change(ctx, node, msg)
elif msg.aggregate_modification:
tx = await _aggregate_modification(ctx, node, msg)
elif msg.importance_transfer:
tx = await _importance_transfer(ctx, node, msg)
else:
raise ValueError('No transaction provided')
signature = ed25519.sign(node.private_key(), tx, helpers.NEM_HASH_ALG)
@ -34,6 +37,20 @@ async def nem_sign_tx(ctx, msg: NEMSignTx):
return resp
async def _importance_transfer(ctx, node, msg: NEMSignTx):
# todo confirms!
w = nem_transaction_create_importance_transfer(
msg.transaction.network,
msg.transaction.timestamp,
_get_public_key(node),
msg.transaction.fee,
msg.transaction.deadline,
msg.importance_transfer.mode,
msg.importance_transfer.public_key
)
return w
async def _aggregate_modification(ctx, node, msg: NEMSignTx):
# todo confirms!
w = nem_transaction_create_aggregate_modification(

View File

@ -137,6 +137,7 @@ def nem_transaction_create_importance_transfer(network: int, timestamp: int, sig
write_uint32(w, mode)
write_bytes_with_length(w, bytearray(remote))
return w
def nem_transaction_create_aggregate_modification(network: int, timestamp: int, signer_public_key: bytes, fee: int,

View File

@ -16,9 +16,6 @@ def validate(msg: NEMSignTx):
if msg.transaction is None:
raise ValueError('No common provided')
if msg.importance_transfer:
raise ValueError('Not yet implemented') # todo
_validate_single_tx(msg)
_validate_common(msg.transaction)