async def dispatch(self, ctx, ins, p1, p2, input): """ Main message dispatcher :param ctx: :param ins: :param p1: :param p2: :param input: :return: """ self.c_p1 = p1 self.c_p2 = p2 self.c_msg = input self.c_offset = 0 self.r_len = 0 from apps.monero.controller import iface self.ctx = ctx self.iface = iface.get_iface(ctx) sw = 0x6F01 try: log.debug(__name__, "Ins: %s, %s %s", ins, p1, p2) sw = await self._sub_dispatch(ins, p1) except Exception as e: log.error(__name__, "Exception dispatching: %s", e) raise gc.collect() return sw, self.r_msg[:self.r_len]
def __init__(self): from apps.monero.controller import iface self.ctx = None self.err_ctr = 0 self.tsx_obj = None # type: TTransactionBuilder self.creds = None # type: apps.monero.xmr.sub.creds.AccountCreds self.iface = iface.get_iface() self.debug = True self.purge = False
async def sign(self, ctx, state, msg, iface=None): """ Main multiplex point :param ctx: :param state: :param msg: :param iface: :return: """ from apps.monero.controller import iface as mod_iface self.ctx = ctx self.iface = mod_iface.get_iface(ctx) if not iface else iface gc.collect() log.debug(__name__, "sign()") log.debug( __name__, "Mem Free: {} Allocated: {}".format(gc.mem_free(), gc.mem_alloc())) if msg.init: log.debug(__name__, "setup") await self.setup(msg.init) await self.restore(state if not msg.init else None) if msg.init: log.debug(__name__, "sign_init") return await self.tsx_init(msg.init.tsx_data) elif msg.set_input: log.debug(__name__, "sign_inp") return await self.tsx_set_input(msg.set_input) elif msg.input_permutation: log.debug(__name__, "sign_perm") return await self.tsx_inputs_permutation(msg.input_permutation) elif msg.input_vini: log.debug(__name__, "sign_vin") return await self.tsx_input_vini(msg.input_vini) elif msg.set_output: log.debug(__name__, "sign_out") return await self.tsx_set_output1(msg.set_output) elif msg.all_out_set: log.debug(__name__, "sign_out_set") return await self.tsx_all_out1_set(msg.all_out_set) elif msg.mlsag_done: log.debug(__name__, "sign_done") return await self.tsx_mlsag_done() elif msg.sign_input: log.debug(__name__, "sign_sinp") return await self.tsx_sign_input(msg.sign_input) elif msg.final_msg: log.debug(__name__, "sign_final") return await self.tsx_sign_final(msg.final_msg) else: raise ValueError("Unknown message")
async def wake_up(self, ctx, state, msg, iface=None): """ Restore from the stored state :param state: :return: """ from apps.monero.controller import iface as mod_iface self.ctx = ctx self.iface = mod_iface.get_iface(ctx) if not iface else iface gc.collect() self._log_trace("wake_up()", True) if msg.MESSAGE_WIRE_TYPE == MessageType.MoneroTransactionInitRequest: self._log_trace("init") await self.setup(msg) await self.restore(state if msg.MESSAGE_WIRE_TYPE != MessageType. MoneroTransactionInitRequest else None) self._log_trace("wake_up() end", True)