mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-11 16:00:57 +00:00
nem: aggregate modification
This commit is contained in:
parent
2e6587ec6c
commit
48c6686dca
@ -1,7 +1,6 @@
|
||||
|
||||
from .helpers import *
|
||||
from .writers import *
|
||||
from ubinascii import hexlify
|
||||
|
||||
|
||||
def nem_transaction_create_transfer(network: int, timestamp: int, signer_public_key: bytes, fee: int, deadline: int,
|
||||
@ -126,6 +125,31 @@ def nem_transaction_create_mosaic_supply_change(network: int, timestamp: int, si
|
||||
return w
|
||||
|
||||
|
||||
def nem_transaction_create_aggregate_modification(network: int, timestamp: int, signer_public_key: bytes, fee: int,
|
||||
deadline: int, modifications: int, relative_change: bool):
|
||||
|
||||
w = _nem_transaction_write_common(NEM_TRANSACTION_TYPE_AGGREGATE_MODIFICATION,
|
||||
_nem_get_version(network, relative_change),
|
||||
timestamp,
|
||||
signer_public_key,
|
||||
fee,
|
||||
deadline)
|
||||
write_uint32(w, modifications)
|
||||
return w
|
||||
|
||||
|
||||
def nem_transaction_write_cosignatory_modification(w: bytearray, type: int, cosignatory: bytes):
|
||||
write_uint32(w, 4 + 4 + len(cosignatory))
|
||||
write_uint32(w, type)
|
||||
write_bytes_with_length(w, bytearray(cosignatory))
|
||||
return w
|
||||
|
||||
|
||||
def nem_transaction_write_minimum_cosignatories(w: bytearray, relative_change: int):
|
||||
write_uint32(w, 4)
|
||||
write_uint32(w, relative_change)
|
||||
|
||||
|
||||
def nem_write_mosaic(w: bytearray, name: str, value):
|
||||
if type(value) == bool:
|
||||
if value:
|
||||
|
75
tests/test_apps.nem.transaction.aggregate_modification.py
Normal file
75
tests/test_apps.nem.transaction.aggregate_modification.py
Normal file
@ -0,0 +1,75 @@
|
||||
from common import *
|
||||
|
||||
from apps.nem.transaction import *
|
||||
from trezor.crypto import hashlib
|
||||
|
||||
|
||||
class TestNemTransactionMosaicCreation(unittest.TestCase):
|
||||
|
||||
def test_nem_transaction_aggregate_modification(self):
|
||||
# http://bob.nem.ninja:8765/#/aggregate/6a55471b17159e5b6cd579c421e95a4e39d92e3f78b0a55ee337e785a601d3a2
|
||||
t = nem_transaction_create_aggregate_modification(NEM_NETWORK_TESTNET,
|
||||
0,
|
||||
unhexlify("462ee976890916e54fa825d26bdd0235f5eb5b6a143c199ab0ae5ee9328e08ce"),
|
||||
22000000,
|
||||
0,
|
||||
2,
|
||||
False)
|
||||
|
||||
nem_transaction_write_cosignatory_modification(t, 1, unhexlify(
|
||||
"994793ba1c789fa9bdea918afc9b06e2d0309beb1081ac5b6952991e4defd324"))
|
||||
nem_transaction_write_cosignatory_modification(t, 1, unhexlify(
|
||||
"c54d6e33ed1446eedd7f7a80a588dd01857f723687a09200c1917d5524752f8b"))
|
||||
|
||||
self.assertEqual(hashlib.sha3_256(t).digest(True),
|
||||
unhexlify("6a55471b17159e5b6cd579c421e95a4e39d92e3f78b0a55ee337e785a601d3a2"))
|
||||
|
||||
# http://chain.nem.ninja/#/aggregate/cc64ca69bfa95db2ff7ac1e21fe6d27ece189c603200ebc9778d8bb80ca25c3c
|
||||
t = nem_transaction_create_aggregate_modification(NEM_NETWORK_MAINNET,
|
||||
0,
|
||||
unhexlify("f41b99320549741c5cce42d9e4bb836d98c50ed5415d0c3c2912d1bb50e6a0e5"),
|
||||
40000000,
|
||||
0,
|
||||
5,
|
||||
False)
|
||||
|
||||
nem_transaction_write_cosignatory_modification(t, 1, unhexlify(
|
||||
"1fbdbdde28daf828245e4533765726f0b7790e0b7146e2ce205df3e86366980b"))
|
||||
nem_transaction_write_cosignatory_modification(t, 1, unhexlify(
|
||||
"f94e8702eb1943b23570b1b83be1b81536df35538978820e98bfce8f999e2d37"))
|
||||
nem_transaction_write_cosignatory_modification(t, 1, unhexlify(
|
||||
"826cedee421ff66e708858c17815fcd831a4bb68e3d8956299334e9e24380ba8"))
|
||||
nem_transaction_write_cosignatory_modification(t, 1, unhexlify(
|
||||
"719862cd7d0f4e875a6a0274c9a1738f38f40ad9944179006a54c34724c1274d"))
|
||||
nem_transaction_write_cosignatory_modification(t, 1, unhexlify(
|
||||
"43aa69177018fc3e2bdbeb259c81cddf24be50eef9c5386db51d82386c41475a"))
|
||||
|
||||
self.assertEqual(hashlib.sha3_256(t).digest(True),
|
||||
unhexlify("cc64ca69bfa95db2ff7ac1e21fe6d27ece189c603200ebc9778d8bb80ca25c3c"))
|
||||
|
||||
def test_nem_transaction_aggregate_modification_relative_change(self):
|
||||
# http://bob.nem.ninja:8765/#/aggregate/1fbdae5ba753e68af270930413ae90f671eb8ab58988116684bac0abd5726584
|
||||
t = nem_transaction_create_aggregate_modification(NEM_NETWORK_TESTNET,
|
||||
6542254,
|
||||
unhexlify("6bf7849c1eec6a2002995cc457dc00c4e29bad5c88de63f51e42dfdcd7b2131d"),
|
||||
40000000,
|
||||
6545854,
|
||||
4,
|
||||
True)
|
||||
|
||||
nem_transaction_write_cosignatory_modification(t, 1, unhexlify(
|
||||
"5f53d076c8c3ec3110b98364bc423092c3ec2be2b1b3c40fd8ab68d54fa39295"))
|
||||
nem_transaction_write_cosignatory_modification(t, 1, unhexlify(
|
||||
"9eb199c2b4d406f64cb7aa5b2b0815264b56ba8fe44d558a6cb423a31a33c4c2"))
|
||||
nem_transaction_write_cosignatory_modification(t, 1, unhexlify(
|
||||
"94b2323dab23a3faba24fa6ddda0ece4fbb06acfedd74e76ad9fae38d006882b"))
|
||||
nem_transaction_write_cosignatory_modification(t, 1, unhexlify(
|
||||
"d88c6ee2a2cd3929d0d76b6b14ecb549d21296ab196a2b3a4cb2536bcce32e87"))
|
||||
nem_transaction_write_minimum_cosignatories(t, 2)
|
||||
|
||||
self.assertEqual(hashlib.sha3_256(t).digest(True),
|
||||
unhexlify("1fbdae5ba753e68af270930413ae90f671eb8ab58988116684bac0abd5726584"))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Loading…
Reference in New Issue
Block a user