Skip to content

Commit

Permalink
xmr: sign_tx unimport
Browse files Browse the repository at this point in the history
  • Loading branch information
ph4r05 committed Sep 13, 2018
1 parent a570ecb commit 92736fa
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/apps/monero/sign_tx.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
import gc

from trezor import utils, wire
from trezor import log, utils
from trezor.messages import MessageType


async def sign_tx(ctx, msg):
state = None
gc.collect()
mods = utils.unimport_begin()

while True:
if __debug__:
log.debug(__name__, "#### F: %s, A: %s", gc.mem_free(), gc.mem_alloc())
res, state = await sign_tx_step(ctx, msg, state)
if msg.final_msg:
break
msg = await ctx.call(res, MessageType.MoneroTransactionSignRequest)

await ctx.write(res)
del (res, msg)
utils.unimport_end(mods)

msg = await ctx.read((MessageType.MoneroTransactionSignRequest,))
gc.collect()

utils.unimport_end(mods)
return res


Expand All @@ -30,7 +41,6 @@ async def sign_tx_step(ctx, msg, state):
else:
creds = None

mods = utils.unimport_begin()
tsx = TTransactionBuilder(iface.get_iface(ctx), creds, state)
del creds
del state
Expand All @@ -45,7 +55,6 @@ async def sign_tx_step(ctx, msg, state):
state = tsx.state_save()

gc.collect()
utils.unimport_end(mods)
return res, state


Expand All @@ -71,6 +80,8 @@ async def sign_tx_dispatch(tsx, msg):
elif msg.final_msg:
return await tsx_sign_final(tsx)
else:
from trezor import wire

raise wire.DataError("Unknown message")


Expand Down Expand Up @@ -138,6 +149,8 @@ async def tsx_all_out1_set(tsx, msg):
try:
return await tsx.all_out1_set()
except TrezorTxPrefixHashNotMatchingError as e:
from trezor import wire

raise wire.NotEnoughFunds(e.message)


Expand Down

0 comments on commit 92736fa

Please sign in to comment.