def register_account(key_data, stub) -> AccountData: # Generate an account key from this root entropy if 'mnemonic' in key_data: resp = stub.GetAccountKeyFromMnemonic( mobilecoind_api_pb2.GetAccountKeyFromMnemonicRequest( mnemonic=key_data['mnemonic'])) elif 'root_entropy' in key_data: resp = stub.GetAccountKeyFromRootEntropy( mobilecoind_api_pb2.GetAccountKeyFromRootEntropyRequest( root_entropy=bytes(key_data['root_entropy']))) else: raise Exception('unknown key format') account_key = resp.account_key # Add this account to the wallet resp = stub.AddMonitor( mobilecoind_api_pb2.AddMonitorRequest(account_key=account_key, first_subaddress=0, num_subaddresses=1)) monitor_id = resp.monitor_id resp = stub.GetPublicAddress( mobilecoind_api_pb2.GetPublicAddressRequest(monitor_id=monitor_id, subaddress_index=0)) public_address = resp.public_address return AccountData(account_key, monitor_id, public_address)
def add_monitor(self, account_key, first_subaddress=0, num_subaddresses=100000, first_block=0): """ Create a process that watches the ledger for tx outputs belonging to a set of subaddresses, each specified by account_key and an index. """ request = api.AddMonitorRequest(account_key=account_key, first_subaddress=first_subaddress, num_subaddresses=num_subaddresses, first_block=first_block) return self.stub.AddMonitor(request).monitor_id
def register_account(key_data, stub) -> AccountData: # Generate an account key from this root entropy resp = stub.GetAccountKeyFromRootEntropy( mobilecoind_api_pb2.GetAccountKeyFromRootEntropyRequest( root_entropy=bytes(key_data['root_entropy']))) account_key = resp.account_key # Add this account to the wallet resp = stub.AddMonitor( mobilecoind_api_pb2.AddMonitorRequest(account_key=account_key, first_subaddress=0, num_subaddresses=1)) monitor_id = resp.monitor_id resp = stub.GetPublicAddress( mobilecoind_api_pb2.GetPublicAddressRequest(monitor_id=monitor_id, subaddress_index=0)) public_address = resp.public_address return AccountData(account_key, monitor_id, public_address)