/** * Save specified contract to file. * * @param contract - contract for update. * @param fileName - name of file to save to. */ public static void saveContract(Contract contract, String fileName) throws IOException { saveContract(contract, fileName, false, true); }
/** * Register a specified contract. * * @param contract must be a sealed binary file. * @param waitTime - wait time for responce. */ public static void registerContract(Contract contract, int waitTime) throws IOException { registerContract(contract, waitTime, true); }
/** * Export contract to specified xml or json file. * * @param contract - contract to export. * @param fileName - name of file to export to. * @param format - format of file to export to. Can be xml or json. */ private static void exportContract(Contract contract, String fileName, String format) throws IOException { exportContract(contract, fileName, format, false); }
private static void finish(int status) { if (cliServices.isAnythingStarted()) cliServices.waitForUserInput(); // print reports if need try { if(!options.has("no-cache")) { saveSession(); } } catch (IOException e) { e.printStackTrace(); } throw new Finished(status); }
private static void doAddressMatch(String address, String keyFilePath) throws IOException { boolean bResult = false; try { PublicKey key = readKeyAndGetPublic(keyFilePath); KeyAddress keyAddress = new KeyAddress(address); bResult = keyAddress.isMatchingKey(key); } catch (Exception e) {}; report("Matching address: " + address + " with key: "+ keyFilePath); report("Matching result: " + bResult); finish(); }
/** * Load contract from specified path. * * @param fileName * * @return loaded and from loaded data created Contract. */ public static Contract loadContract(String fileName) throws IOException { return loadContract(fileName, true); }
static public void clearSession() { clearSession(true); }
public static void setNodeNumber(int number) { System.out.println("Connecting to node " + number); nodeNumber = number; clientNetwork = null; setNodeUrl("http://node-" + nodeNumber + "-com.universa.io:8080"); }
@Test public void checkStateTwoHashes1() throws Exception { callMain2("--probe", "py2GSOxgOGBPiaL9rnGm800lf1Igk3/BGU/wSawFNic7H/x0r8KPOb61iqYlDXWMtR44r5GaO/EDa5Di8c6lmQ", "G0lCqE2TPn9wiioHDy5nllWbLkRwPA97HdnhtcCn3EDAuoDBwiZcRIGjrBftGLFWOVUY8D5yPVkEj+wqb6ytrA", "--verbose"); }
/** * Export fields from specified contract. * * @param contract - contract to export. * @param fieldNames - list of field names to export. * @param fileName - name of file to export to. * @param format - format of file to export to. Can be xml or json. */ private static void exportFields(Contract contract, List<String> fieldNames, String fileName, String format) throws IOException { exportFields(contract, fieldNames, fileName, format, false); }
/** * Find contracts in the given path including all subfolders. Looking for files with .unicon extensions. * * @param path * * @return */ public static HashMap<String, Contract> findContracts(String path) { return findContracts(path, true); }
/** * Download contract from the specified url. * * @param url * * @return */ public static Contract downloadContract(String url) { // TODO: Download and check contract. report("downloading from " + url); return null; }
public boolean accept(File pathname) { String extension = getExtension(pathname); for (String unc : extensions) { if (unc.equals(extension)) { return true; } } return false; }
private static void callMain2(String... args) throws Exception { String[] argsNew = new String[args.length+1]; for(int i =0; i< args.length;i++) { argsNew[i] = args[i]; } argsNew[args.length] = "--no-exit"; CLIMain.main(argsNew); }
public static RegexMatcher matches(String regex){ return new RegexMatcher(regex); } }
protected static Contract createCoin() throws IOException { return createCoin(rootPath + "coin.yml"); }
/** * Save specified contract to file. * * @param contract - contract for update. * @param fileName - name of file to save to. * @param fromPackedTransaction - register contract with Contract.getPackedTransaction() * @param addSigners - do adding signs to contract from keysMap() or not. */ public static boolean saveContract(Contract contract, String fileName, Boolean fromPackedTransaction, Boolean addSigners) throws IOException { return saveContract(contract,fileName,fromPackedTransaction,addSigners,null); } /**
/** * Register a specified contract. * * @param contract must be a sealed binary file. */ public static void registerContract(Contract contract) throws IOException { registerContract(contract, 0, true); }
@Test public void checkStateTwoHashes4() throws Exception { callMain2("--probe", "--verbose", "py2GSOxgOGBPiaL9rnGm800lf1Igk3/BGU/wSawFNic7H/x0r8KPOb61iqYlDXWMtR44r5GaO/EDa5Di8c6lmQ" + "," + "G0lCqE2TPn9wiioHDy5nllWbLkRwPA97HdnhtcCn3EDAuoDBwiZcRIGjrBftGLFWOVUY8D5yPVkEj+wqb6ytrA"); }
@Test public void checkStateTwoHashes3() throws Exception { callMain2("--probe", "--verbose", "py2GSOxgOGBPiaL9rnGm800lf1Igk3/BGU/wSawFNic7H/x0r8KPOb61iqYlDXWMtR44r5GaO/EDa5Di8c6lmQ", "G0lCqE2TPn9wiioHDy5nllWbLkRwPA97HdnhtcCn3EDAuoDBwiZcRIGjrBftGLFWOVUY8D5yPVkEj+wqb6ytrA"); }