@Ignore @Test public void printWallets() throws Exception { System.out.println("\n\n"); callMain("-f", "/home/flint/w/uniclient-test", "--verbose"); System.out.println(output); System.out.println("\n\n"); }
private static void printWallets(List<Wallet> wallets) { reporter.message(""); List<Contract> foundContracts = new ArrayList<>(); for (Wallet wallet : wallets) { foundContracts.addAll(wallet.getContracts()); reporter.message("found wallet: " + wallet.toString()); reporter.verbose(""); HashSet<WalletValueModel> balance = new HashSet<>(); for (Contract contract : wallet.getContracts()) { try { Decimal numcoins = new Decimal(contract.getStateData().getStringOrThrow(AMOUNT_FIELD_NAME)); SplitJoinPermission sjp = (SplitJoinPermission)contract.getPermissions().get("split_join").iterator().next(); WalletValueModel walletValueModel = null; for (WalletValueModel wvm : balance) { if (sjp.validateMergeFields(contract, wvm.contract)) walletValueModel = wvm; } if (walletValueModel == null) walletValueModel = new WalletValueModel(); walletValueModel.value = walletValueModel.value.add(numcoins); String currencyTag = contract.getDefinition().getData().getString("currency_code", null); if (currencyTag == null) currencyTag = contract.getDefinition().getData().getString("unit_short_name", null); if (currencyTag == null) currencyTag = contract.getDefinition().getData().getString("short_currency", null); if (currencyTag == null) currencyTag = contract.getDefinition().getData().getString("currency", null); if (currencyTag == null) currencyTag = contract.getDefinition().getData().getString("name", null); if (currencyTag == null) currencyTag = contract.getDefinition().getData().getString("unit_name", null); if (currencyTag == null) currencyTag = contract.getOrigin().toString(); walletValueModel.tag = currencyTag; walletValueModel.contract = contract; balance.add(walletValueModel); reporter.verbose("found coins: " + contract.getOrigin().toString() + " -> " + numcoins + " (" + currencyTag + ") "); } catch (Exception e) { e.printStackTrace(); } } reporter.verbose(""); reporter.message("total in the wallet: "); for (WalletValueModel w : balance) { reporter.message(w.value + " (" + w.tag + ") "); } } }
CLIMain { private static void printWallets(List<Wallet> wallets) { reporter.message(""); List<Contract> foundContracts = new ArrayList<>(); for (Wallet wallet : wallets) { foundContracts.addAll(wallet.getContracts()); reporter.message("found wallet: " + wallet.toString()); reporter.verbose(""); HashSet<WalletValueModel> balance = new HashSet<>(); for (Contract contract : wallet.getContracts()) { try { Decimal numcoins = new Decimal(contract.getStateData().getStringOrThrow(AMOUNT_FIELD_NAME)); SplitJoinPermission sjp = (SplitJoinPermission)contract.getPermissions().get("split_join").iterator().next(); WalletValueModel walletValueModel = null; for (WalletValueModel wvm : balance) { if (sjp.validateMergeFields(contract, wvm.contract)) walletValueModel = wvm; } if (walletValueModel == null) walletValueModel = new WalletValueModel(); walletValueModel.value = walletValueModel.value.add(numcoins); String currencyTag = contract.getDefinition().getData().getString("currency_code", null); if (currencyTag == null) currencyTag = contract.getDefinition().getData().getString("unit_short_name", null); if (currencyTag == null) currencyTag = contract.getDefinition().getData().getString("short_currency", null); if (currencyTag == null) currencyTag = contract.getDefinition().getData().getString("currency", null); if (currencyTag == null) currencyTag = contract.getDefinition().getData().getString("name", null); if (currencyTag == null) currencyTag = contract.getDefinition().getData().getString("unit_name", null); if (currencyTag == null) currencyTag = contract.getOrigin().toString(); walletValueModel.tag = currencyTag; walletValueModel.contract = contract; balance.add(walletValueModel); reporter.verbose("found coins: " + contract.getOrigin().toString() + " -> " + numcoins + " (" + currencyTag + ") "); } catch (Exception e) { e.printStackTrace(); } } reporter.verbose(""); reporter.message("total in the wallet: "); for (WalletValueModel w : balance) { reporter.message(w.value + " (" + w.tag + ") "); } } } }
CLIMain { private static void printWallets(List<Wallet> wallets) { reporter.message(""); List<Contract> foundContracts = new ArrayList<>(); for (Wallet wallet : wallets) { foundContracts.addAll(wallet.getContracts()); reporter.message("found wallet: " + wallet.toString()); reporter.verbose(""); HashSet<WalletValueModel> balance = new HashSet<>(); for (Contract contract : wallet.getContracts()) { try { Decimal numcoins = new Decimal(contract.getStateData().getStringOrThrow(AMOUNT_FIELD_NAME)); SplitJoinPermission sjp = (SplitJoinPermission)contract.getPermissions().get("split_join").iterator().next(); WalletValueModel walletValueModel = null; for (WalletValueModel wvm : balance) { if (sjp.validateMergeFields(contract, wvm.contract)) walletValueModel = wvm; } if (walletValueModel == null) walletValueModel = new WalletValueModel(); walletValueModel.value = walletValueModel.value.add(numcoins); String currencyTag = contract.getDefinition().getData().getString("currency_code", null); if (currencyTag == null) currencyTag = contract.getDefinition().getData().getString("unit_short_name", null); if (currencyTag == null) currencyTag = contract.getDefinition().getData().getString("short_currency", null); if (currencyTag == null) currencyTag = contract.getDefinition().getData().getString("currency", null); if (currencyTag == null) currencyTag = contract.getDefinition().getData().getString("name", null); if (currencyTag == null) currencyTag = contract.getDefinition().getData().getString("unit_name", null); if (currencyTag == null) currencyTag = contract.getOrigin().toString(); walletValueModel.tag = currencyTag; walletValueModel.contract = contract; balance.add(walletValueModel); reporter.verbose("found coins: " + contract.getOrigin().toString() + " -> " + numcoins + " (" + currencyTag + ") "); } catch (Exception e) { e.printStackTrace(); } } reporter.verbose(""); reporter.message("total in the wallet: "); for (WalletValueModel w : balance) { reporter.message(w.value + " (" + w.tag + ") "); } } }  }
CLIMain { private static void printWallets(List<Wallet> wallets) { reporter.message(""); List<Contract> foundContracts = new ArrayList<>(); for (Wallet wallet : wallets) { foundContracts.addAll(wallet.getContracts()); reporter.message("found wallet: " + wallet.toString()); reporter.verbose(""); HashSet<WalletValueModel> balance = new HashSet<>(); for (Contract contract : wallet.getContracts()) { try { Decimal numcoins = new Decimal(contract.getStateData().getStringOrThrow(AMOUNT_FIELD_NAME)); SplitJoinPermission sjp = (SplitJoinPermission)contract.getPermissions().get("split_join").iterator().next(); WalletValueModel walletValueModel = null; for (WalletValueModel wvm : balance) { if (sjp.validateMergeFields(contract, wvm.contract)) walletValueModel = wvm; } if (walletValueModel == null) walletValueModel = new WalletValueModel(); walletValueModel.value = walletValueModel.value.add(numcoins); String currencyTag = contract.getDefinition().getData().getString("currency_code", null); if (currencyTag == null) currencyTag = contract.getDefinition().getData().getString("unit_short_name", null); if (currencyTag == null) currencyTag = contract.getDefinition().getData().getString("short_currency", null); if (currencyTag == null) currencyTag = contract.getDefinition().getData().getString("currency", null); if (currencyTag == null) currencyTag = contract.getDefinition().getData().getString("name", null); if (currencyTag == null) currencyTag = contract.getDefinition().getData().getString("unit_name", null); if (currencyTag == null) currencyTag = contract.getOrigin().toString(); walletValueModel.tag = currencyTag; walletValueModel.contract = contract; balance.add(walletValueModel); reporter.verbose("found coins: " + contract.getOrigin().toString() + " -> " + numcoins + " (" + currencyTag + ") "); } catch (Exception e) { e.printStackTrace(); } } reporter.verbose(""); reporter.message("total in the wallet: "); for (WalletValueModel w : balance) { reporter.message(w.value + " (" + w.tag + ") "); } } }  static void main(String[] args); static PrivateKey getPrivateKey(); static BasicHttpClientSession getSession(int nodeNumber); static void breakSession(int nodeNumber); static void clearSession(); static void clearSession(boolean full); static void saveSession(); static void setVerboseMode(boolean verboseMode); static Contract loadContract(String fileName, Boolean fromPackedTransaction); static Parcel loadParcel(String fileName); static Contract loadContract(String fileName); static void exportContract(Contract contract, String fileName, String format, Boolean jsonPretty); static boolean saveContract(Contract contract, String fileName, Boolean fromPackedTransaction, Boolean addSigners); static boolean saveContract(Contract contract, String fileName, Boolean fromPackedTransaction, Boolean addSigners, Set<Contract> referencedItems); static boolean saveParcel(Parcel parcel, String fileName); static void saveContract(Contract contract, String fileName); static List<Wallet> findWallets(String path); static HashMap<String, Contract> findContracts(String path); static HashMap<String, Contract> findContracts(String path, Boolean recursively); static List<File> findFiles(String path, Boolean recursively); static Contract downloadContract(String url); static Parcel revokeContract(Contract contract, Contract u, int amount, Set<PrivateKey> uKeys, boolean withTestPayment, PrivateKey... key); @Deprecated static Contract revokeContract(Contract contract, PrivateKey... key); @Deprecated static void registerContract(Contract contract, int waitTime, Boolean fromPackedTransaction); static Parcel prepareForRegisterContract(Contract contract, Contract u, int amount, Set<PrivateKey> uKeys, boolean withTestPayment); static Parcel prepareForRegisterPayingParcel(Contract contract, Contract u, int amount, int amountStorage, Set<PrivateKey> uKeys, boolean withTestPayment); static ItemResult registerParcel(Parcel parcel, int waitTime); static void registerContract(Contract contract); static void registerContract(Contract contract, int waitTime); static void setTestMode(); static void setTestRootPath(String rootPath); static void setNodeNumber(int number); static void setNodeUrl(String url); static void setTopologyFileName(String filename); static void setPrivateKey(PrivateKey key); static Reporter getReporter(); static synchronized ClientNetwork getClientNetwork(); static synchronized Map<String, PrivateKey> keysMap(); static synchronized Map<String, PrivateKey> keysMapContract(); }
CLIMain { private static void printWallets(List<Wallet> wallets) { reporter.message(""); List<Contract> foundContracts = new ArrayList<>(); for (Wallet wallet : wallets) { foundContracts.addAll(wallet.getContracts()); reporter.message("found wallet: " + wallet.toString()); reporter.verbose(""); HashSet<WalletValueModel> balance = new HashSet<>(); for (Contract contract : wallet.getContracts()) { try { Decimal numcoins = new Decimal(contract.getStateData().getStringOrThrow(AMOUNT_FIELD_NAME)); SplitJoinPermission sjp = (SplitJoinPermission)contract.getPermissions().get("split_join").iterator().next(); WalletValueModel walletValueModel = null; for (WalletValueModel wvm : balance) { if (sjp.validateMergeFields(contract, wvm.contract)) walletValueModel = wvm; } if (walletValueModel == null) walletValueModel = new WalletValueModel(); walletValueModel.value = walletValueModel.value.add(numcoins); String currencyTag = contract.getDefinition().getData().getString("currency_code", null); if (currencyTag == null) currencyTag = contract.getDefinition().getData().getString("unit_short_name", null); if (currencyTag == null) currencyTag = contract.getDefinition().getData().getString("short_currency", null); if (currencyTag == null) currencyTag = contract.getDefinition().getData().getString("currency", null); if (currencyTag == null) currencyTag = contract.getDefinition().getData().getString("name", null); if (currencyTag == null) currencyTag = contract.getDefinition().getData().getString("unit_name", null); if (currencyTag == null) currencyTag = contract.getOrigin().toString(); walletValueModel.tag = currencyTag; walletValueModel.contract = contract; balance.add(walletValueModel); reporter.verbose("found coins: " + contract.getOrigin().toString() + " -> " + numcoins + " (" + currencyTag + ") "); } catch (Exception e) { e.printStackTrace(); } } reporter.verbose(""); reporter.message("total in the wallet: "); for (WalletValueModel w : balance) { reporter.message(w.value + " (" + w.tag + ") "); } } }  static void main(String[] args); static PrivateKey getPrivateKey(); static BasicHttpClientSession getSession(int nodeNumber); static void breakSession(int nodeNumber); static void clearSession(); static void clearSession(boolean full); static void saveSession(); static void setVerboseMode(boolean verboseMode); static Contract loadContract(String fileName, Boolean fromPackedTransaction); static Parcel loadParcel(String fileName); static Contract loadContract(String fileName); static void exportContract(Contract contract, String fileName, String format, Boolean jsonPretty); static boolean saveContract(Contract contract, String fileName, Boolean fromPackedTransaction, Boolean addSigners); static boolean saveContract(Contract contract, String fileName, Boolean fromPackedTransaction, Boolean addSigners, Set<Contract> referencedItems); static boolean saveParcel(Parcel parcel, String fileName); static void saveContract(Contract contract, String fileName); static List<Wallet> findWallets(String path); static HashMap<String, Contract> findContracts(String path); static HashMap<String, Contract> findContracts(String path, Boolean recursively); static List<File> findFiles(String path, Boolean recursively); static Contract downloadContract(String url); static Parcel revokeContract(Contract contract, Contract u, int amount, Set<PrivateKey> uKeys, boolean withTestPayment, PrivateKey... key); @Deprecated static Contract revokeContract(Contract contract, PrivateKey... key); @Deprecated static void registerContract(Contract contract, int waitTime, Boolean fromPackedTransaction); static Parcel prepareForRegisterContract(Contract contract, Contract u, int amount, Set<PrivateKey> uKeys, boolean withTestPayment); static Parcel prepareForRegisterPayingParcel(Contract contract, Contract u, int amount, int amountStorage, Set<PrivateKey> uKeys, boolean withTestPayment); static ItemResult registerParcel(Parcel parcel, int waitTime); static void registerContract(Contract contract); static void registerContract(Contract contract, int waitTime); static void setTestMode(); static void setTestRootPath(String rootPath); static void setNodeNumber(int number); static void setNodeUrl(String url); static void setTopologyFileName(String filename); static void setPrivateKey(PrivateKey key); static Reporter getReporter(); static synchronized ClientNetwork getClientNetwork(); static synchronized Map<String, PrivateKey> keysMap(); static synchronized Map<String, PrivateKey> keysMapContract(); static String DEFAULT_WALLET_PATH; static final String AMOUNT_FIELD_NAME; }