mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-17 03:48:09 +00:00
nem: importance transfer signing
This commit is contained in:
parent
52affe2897
commit
368b979a8a
@ -12,7 +12,6 @@ from trezor.crypto import random
|
|||||||
async def nem_sign_tx(ctx, msg: NEMSignTx):
|
async def nem_sign_tx(ctx, msg: NEMSignTx):
|
||||||
validate(msg)
|
validate(msg)
|
||||||
node = await seed.derive_node(ctx, msg.transaction.address_n, NEM_CURVE)
|
node = await seed.derive_node(ctx, msg.transaction.address_n, NEM_CURVE)
|
||||||
tx = bytearray()
|
|
||||||
|
|
||||||
if msg.transfer:
|
if msg.transfer:
|
||||||
tx = await _transfer(ctx, node, msg)
|
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)
|
tx = await _supply_change(ctx, node, msg)
|
||||||
elif msg.aggregate_modification:
|
elif msg.aggregate_modification:
|
||||||
tx = await _aggregate_modification(ctx, node, msg)
|
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)
|
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
|
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):
|
async def _aggregate_modification(ctx, node, msg: NEMSignTx):
|
||||||
# todo confirms!
|
# todo confirms!
|
||||||
w = nem_transaction_create_aggregate_modification(
|
w = nem_transaction_create_aggregate_modification(
|
||||||
|
@ -137,6 +137,7 @@ def nem_transaction_create_importance_transfer(network: int, timestamp: int, sig
|
|||||||
|
|
||||||
write_uint32(w, mode)
|
write_uint32(w, mode)
|
||||||
write_bytes_with_length(w, bytearray(remote))
|
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,
|
def nem_transaction_create_aggregate_modification(network: int, timestamp: int, signer_public_key: bytes, fee: int,
|
||||||
|
@ -16,9 +16,6 @@ def validate(msg: NEMSignTx):
|
|||||||
if msg.transaction is None:
|
if msg.transaction is None:
|
||||||
raise ValueError('No common provided')
|
raise ValueError('No common provided')
|
||||||
|
|
||||||
if msg.importance_transfer:
|
|
||||||
raise ValueError('Not yet implemented') # todo
|
|
||||||
|
|
||||||
_validate_single_tx(msg)
|
_validate_single_tx(msg)
|
||||||
_validate_common(msg.transaction)
|
_validate_common(msg.transaction)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user