@Test public void goodToken() throws Exception { Set<PrivateKey> martyPrivateKeys = new HashSet<>(); Set<PrivateKey> stepaPrivateKeys = new HashSet<>(); Set<PublicKey> martyPublicKeys = new HashSet<>(); Set<PublicKey> stepaPublicKeys = new HashSet<>(); martyPrivateKeys.add(new PrivateKey(Do.read(rootPath + "keys/marty_mcfly.private.unikey"))); stepaPrivateKeys.add(new PrivateKey(Do.read(rootPath + "keys/stepan_mamontov.private.unikey"))); for (PrivateKey pk : stepaPrivateKeys) stepaPublicKeys.add(pk.getPublicKey()); for (PrivateKey pk : martyPrivateKeys) martyPublicKeys.add(pk.getPublicKey()); Contract tokenContract = ContractsService.createTokenContract(martyPrivateKeys, stepaPublicKeys, new BigDecimal("100")); tokenContract.check(); tokenContract.traceErrors(); assertTrue(tokenContract.isOk()); assertTrue(tokenContract.getOwner().isAllowedForKeys(stepaPublicKeys)); assertTrue(tokenContract.getIssuer().isAllowedForKeys(martyPrivateKeys)); assertTrue(tokenContract.getCreator().isAllowedForKeys(martyPrivateKeys)); assertFalse(tokenContract.getOwner().isAllowedForKeys(martyPrivateKeys)); assertFalse(tokenContract.getIssuer().isAllowedForKeys(stepaPublicKeys)); assertFalse(tokenContract.getCreator().isAllowedForKeys(stepaPublicKeys)); assertTrue(tokenContract.getExpiresAt().isAfter(ZonedDateTime.now().plusMonths(3))); assertTrue(tokenContract.getCreatedAt().isBefore(ZonedDateTime.now())); assertEquals(InnerContractsService.getDecimalField(tokenContract, "amount"), new Decimal(100)); assertEquals(tokenContract.getPermissions().get("split_join").size(), 1); Binder splitJoinParams = tokenContract.getPermissions().get("split_join").iterator().next().getParams(); assertEquals(splitJoinParams.get("min_value"), "0.01"); assertEquals(splitJoinParams.get("min_unit"), "0.01"); assertEquals(splitJoinParams.get("field_name"), "amount"); assertTrue(splitJoinParams.get("join_match_fields") instanceof List); assertEquals(((List)splitJoinParams.get("join_match_fields")).get(0), "state.origin"); assertTrue(tokenContract.isPermitted("revoke", stepaPublicKeys)); assertTrue(tokenContract.isPermitted("revoke", martyPublicKeys)); assertTrue(tokenContract.isPermitted("change_owner", stepaPublicKeys)); assertFalse(tokenContract.isPermitted("change_owner", martyPublicKeys)); assertTrue(tokenContract.isPermitted("split_join", stepaPublicKeys)); assertFalse(tokenContract.isPermitted("split_join", martyPublicKeys)); }
@Deprecated public synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount, Double minValue, String currency, String name, String description) { return createTokenContract(issuerKeys, ownerKeys, new BigDecimal(amount), new BigDecimal(minValue), currency, name, description); }
ContractsService { @Deprecated public synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount, Double minValue, String currency, String name, String description) { return createTokenContract(issuerKeys, ownerKeys, new BigDecimal(amount), new BigDecimal(minValue), currency, name, description); } }
ContractsService { @Deprecated public synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount, Double minValue, String currency, String name, String description) { return createTokenContract(issuerKeys, ownerKeys, new BigDecimal(amount), new BigDecimal(minValue), currency, name, description); }  }
ContractsService { @Deprecated public synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount, Double minValue, String currency, String name, String description) { return createTokenContract(issuerKeys, ownerKeys, new BigDecimal(amount), new BigDecimal(minValue), currency, name, description); }  synchronized static Contract createRevocation(Contract c, PrivateKey... keys); @Deprecated synchronized static Contract createSplit(Contract c, String amount, String fieldName, Set<PrivateKey> keys); @Deprecated synchronized static Contract createSplit(Contract c, String amount, String fieldName, Set<PrivateKey> keys, boolean andSetCreator); synchronized static Contract createSplit(Contract c, BigDecimal amount, String fieldName, Set<PrivateKey> keys); synchronized static Contract createSplit(Contract c, BigDecimal amount, String fieldName, Set<PrivateKey> keys, boolean andSetCreator); synchronized static Contract createJoin(Contract contract1, Contract contract2, String fieldName, Set<PrivateKey> keys); static List<Contract> createSplitJoin(Collection<Contract> contractsToJoin, List<String> amountsToSplit, List<KeyAddress> addressesToSplit,Set<PrivateKey> ownerKeys, String fieldName); synchronized static Contract startSwap(Contract contract1, Contract contract2, Set<PrivateKey> fromKeys, Set<PublicKey> toKeys); synchronized static Contract startSwap(List<Contract> contracts1, List<Contract> contracts2, Set<PrivateKey> fromKeys, Set<PublicKey> toKeys); synchronized static Contract startSwap(Contract contract1, Contract contract2, Set<PrivateKey> fromKeys, Set<PublicKey> toKeys, boolean createNewRevision); synchronized static Contract startSwap(List<Contract> contracts1, List<Contract> contracts2, Set<PrivateKey> fromKeys, Set<PublicKey> toKeys, boolean createNewRevision); @Deprecated synchronized static Contract signPresentedSwap(Contract swapContract, Set<PrivateKey> keys); @Deprecated synchronized static Contract finishSwap(Contract swapContract, Set<PrivateKey> keys); synchronized static Contract createTwoSignedContract(Contract baseContract, Set<PrivateKey> fromKeys, Set<PublicKey> toKeys, boolean createNewRevision); @Deprecated synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount, Double minValue, String currency, String name, String description); @Deprecated synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount, Double minValue); @Deprecated synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount); synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount, BigDecimal minValue, String currency, String name, String description); synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount, BigDecimal minValue); synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount); @Deprecated synchronized static Contract createMintableTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount, Double minValue, String currency, String name, String description); @Deprecated synchronized static Contract createMintableTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount, Double minValue); synchronized static Contract createMintableTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount, BigDecimal minValue, String currency, String name, String description); synchronized static Contract createMintableTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount, BigDecimal minValue); synchronized static Contract createMintableTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount); @Deprecated synchronized static Contract createTokenContractWithEmission(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount, Double minValue); @Deprecated synchronized static Contract createTokenContractWithEmission(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount); @Deprecated synchronized static Contract createTokenEmission(Contract tokenContract, String amount, Set<PrivateKey> keys, String fieldName); @Deprecated synchronized static Contract createTokenEmission(Contract tokenContract, String amount, Set<PrivateKey> keys); @Deprecated synchronized static Contract createTokenContractWithEmission(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount, BigDecimal minValue); @Deprecated synchronized static Contract createTokenContractWithEmission(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount); @Deprecated synchronized static Contract createTokenEmission(Contract tokenContract, BigDecimal amount, Set<PrivateKey> keys, String fieldName); @Deprecated synchronized static Contract createTokenEmission(Contract tokenContract, BigDecimal amount, Set<PrivateKey> keys); @Deprecated synchronized static Contract createShareContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount); synchronized static Contract createShareContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount); synchronized static Contract createNotaryContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys); synchronized static Contract createNotaryContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys,
                                                             List<String> filePaths); synchronized static Contract createNotaryContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys,
                                                             List<String> filePaths, List<String> fileDescriptions); synchronized static boolean checkAttachNotaryContract(Contract notaryContract, String filePaths); synchronized static SlotContract createSlotContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, NSmartContract.NodeInfoProvider nodeInfoProvider); synchronized static UnsContract createUnsContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, NSmartContract.NodeInfoProvider nodeInfoProvider); synchronized static UnsContract createUnsContractForRegisterContractName(
            Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, NSmartContract.NodeInfoProvider nodeInfoProvider,
            String name, String description, String URL, Contract namedContract); synchronized static UnsContract createUnsContractForRegisterKeyName(
            Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, NSmartContract.NodeInfoProvider nodeInfoProvider,
            String name, String description, String URL, AbstractKey namedKey); synchronized static FollowerContract createFollowerContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, NSmartContract.NodeInfoProvider nodeInfoProvider); synchronized static Contract addReferenceToContract(
            Contract baseContract, Contract refContract, String refName, int refType, Binder conditions); synchronized static Contract addReferenceToContract(
            Contract baseContract, Contract refContract, String refName, int refType, List<String> listConditions, boolean isAllOfConditions); synchronized static Parcel createParcel(Contract payload, Contract payment, int amount, Set<PrivateKey> keys); synchronized static Parcel createParcel(Contract payload, Contract payment, int amount, Set<PrivateKey> keys,
                                                   boolean withTestPayment); synchronized static Parcel createParcel(TransactionPack payload, Contract payment, int amount, Set<PrivateKey> keys); synchronized static Parcel createParcel(TransactionPack payload, Contract payment, int amount, Set<PrivateKey> keys,
                                                   boolean withTestPayment); synchronized static Parcel createPayingParcel(TransactionPack payload, Contract payment, int amount, int amountSecond,
                                                         Set<PrivateKey> keys, boolean withTestPayment); static Contract createBatch(Collection<PrivateKey> keys, Contract... contracts); static Contract addConsent(Contract source, KeyAddress... consentKeyAddresses); static Contract createEscrowContract(
            Collection<PrivateKey> issuerKeys,
            Collection<PublicKey> customerKeys,
            Collection<PublicKey> executorKeys,
            Collection<PublicKey> arbitratorKeys); static Contract createInternalEscrowContract(
            Collection<PrivateKey> issuerKeys,
            Collection<PublicKey> customerKeys,
            Collection<PublicKey> executorKeys,
            Collection<PublicKey> arbitratorKeys); static Contract createExternalEscrowContract(Contract internalEscrow, Collection<PrivateKey> issuerKeys); static Contract modifyPaymentForEscrowContract(
            Contract escrow,
            Contract payment,
            Collection<PrivateKey> paymentOwnerKeys,
            Collection<PublicKey> customerKeys,
            Collection<PublicKey> executorKeys); static Contract modifyPaymentForEscrowContract(
            String escrowOrigin,
            Contract payment,
            Collection<PrivateKey> paymentOwnerKeys,
            Collection<PublicKey> customerKeys,
            Collection<PublicKey> executorKeys); static boolean addPaymentToEscrowContract(
            Contract escrow,
            Contract payment,
            Collection<PrivateKey> paymentOwnerKeys,
            Collection<PublicKey> customerKeys,
            Collection<PublicKey> executorKeys); static Contract completeEscrowContract(Contract escrow); static Contract cancelEscrowContract(Contract escrow); static Contract takeEscrowPayment(Collection<PrivateKey> newOwnerKeys, Contract payment); synchronized static Contract createRateLimitDisablingContract(PublicKey key, Contract payment, int amount, Set<PrivateKey> keys); }
ContractsService { @Deprecated public synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount, Double minValue, String currency, String name, String description) { return createTokenContract(issuerKeys, ownerKeys, new BigDecimal(amount), new BigDecimal(minValue), currency, name, description); }  synchronized static Contract createRevocation(Contract c, PrivateKey... keys); @Deprecated synchronized static Contract createSplit(Contract c, String amount, String fieldName, Set<PrivateKey> keys); @Deprecated synchronized static Contract createSplit(Contract c, String amount, String fieldName, Set<PrivateKey> keys, boolean andSetCreator); synchronized static Contract createSplit(Contract c, BigDecimal amount, String fieldName, Set<PrivateKey> keys); synchronized static Contract createSplit(Contract c, BigDecimal amount, String fieldName, Set<PrivateKey> keys, boolean andSetCreator); synchronized static Contract createJoin(Contract contract1, Contract contract2, String fieldName, Set<PrivateKey> keys); static List<Contract> createSplitJoin(Collection<Contract> contractsToJoin, List<String> amountsToSplit, List<KeyAddress> addressesToSplit,Set<PrivateKey> ownerKeys, String fieldName); synchronized static Contract startSwap(Contract contract1, Contract contract2, Set<PrivateKey> fromKeys, Set<PublicKey> toKeys); synchronized static Contract startSwap(List<Contract> contracts1, List<Contract> contracts2, Set<PrivateKey> fromKeys, Set<PublicKey> toKeys); synchronized static Contract startSwap(Contract contract1, Contract contract2, Set<PrivateKey> fromKeys, Set<PublicKey> toKeys, boolean createNewRevision); synchronized static Contract startSwap(List<Contract> contracts1, List<Contract> contracts2, Set<PrivateKey> fromKeys, Set<PublicKey> toKeys, boolean createNewRevision); @Deprecated synchronized static Contract signPresentedSwap(Contract swapContract, Set<PrivateKey> keys); @Deprecated synchronized static Contract finishSwap(Contract swapContract, Set<PrivateKey> keys); synchronized static Contract createTwoSignedContract(Contract baseContract, Set<PrivateKey> fromKeys, Set<PublicKey> toKeys, boolean createNewRevision); @Deprecated synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount, Double minValue, String currency, String name, String description); @Deprecated synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount, Double minValue); @Deprecated synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount); synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount, BigDecimal minValue, String currency, String name, String description); synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount, BigDecimal minValue); synchronized static Contract createTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount); @Deprecated synchronized static Contract createMintableTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount, Double minValue, String currency, String name, String description); @Deprecated synchronized static Contract createMintableTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount, Double minValue); synchronized static Contract createMintableTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount, BigDecimal minValue, String currency, String name, String description); synchronized static Contract createMintableTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount, BigDecimal minValue); synchronized static Contract createMintableTokenContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount); @Deprecated synchronized static Contract createTokenContractWithEmission(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount, Double minValue); @Deprecated synchronized static Contract createTokenContractWithEmission(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount); @Deprecated synchronized static Contract createTokenEmission(Contract tokenContract, String amount, Set<PrivateKey> keys, String fieldName); @Deprecated synchronized static Contract createTokenEmission(Contract tokenContract, String amount, Set<PrivateKey> keys); @Deprecated synchronized static Contract createTokenContractWithEmission(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount, BigDecimal minValue); @Deprecated synchronized static Contract createTokenContractWithEmission(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount); @Deprecated synchronized static Contract createTokenEmission(Contract tokenContract, BigDecimal amount, Set<PrivateKey> keys, String fieldName); @Deprecated synchronized static Contract createTokenEmission(Contract tokenContract, BigDecimal amount, Set<PrivateKey> keys); @Deprecated synchronized static Contract createShareContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, String amount); synchronized static Contract createShareContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, BigDecimal amount); synchronized static Contract createNotaryContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys); synchronized static Contract createNotaryContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys,
                                                             List<String> filePaths); synchronized static Contract createNotaryContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys,
                                                             List<String> filePaths, List<String> fileDescriptions); synchronized static boolean checkAttachNotaryContract(Contract notaryContract, String filePaths); synchronized static SlotContract createSlotContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, NSmartContract.NodeInfoProvider nodeInfoProvider); synchronized static UnsContract createUnsContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, NSmartContract.NodeInfoProvider nodeInfoProvider); synchronized static UnsContract createUnsContractForRegisterContractName(
            Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, NSmartContract.NodeInfoProvider nodeInfoProvider,
            String name, String description, String URL, Contract namedContract); synchronized static UnsContract createUnsContractForRegisterKeyName(
            Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, NSmartContract.NodeInfoProvider nodeInfoProvider,
            String name, String description, String URL, AbstractKey namedKey); synchronized static FollowerContract createFollowerContract(Set<PrivateKey> issuerKeys, Set<PublicKey> ownerKeys, NSmartContract.NodeInfoProvider nodeInfoProvider); synchronized static Contract addReferenceToContract(
            Contract baseContract, Contract refContract, String refName, int refType, Binder conditions); synchronized static Contract addReferenceToContract(
            Contract baseContract, Contract refContract, String refName, int refType, List<String> listConditions, boolean isAllOfConditions); synchronized static Parcel createParcel(Contract payload, Contract payment, int amount, Set<PrivateKey> keys); synchronized static Parcel createParcel(Contract payload, Contract payment, int amount, Set<PrivateKey> keys,
                                                   boolean withTestPayment); synchronized static Parcel createParcel(TransactionPack payload, Contract payment, int amount, Set<PrivateKey> keys); synchronized static Parcel createParcel(TransactionPack payload, Contract payment, int amount, Set<PrivateKey> keys,
                                                   boolean withTestPayment); synchronized static Parcel createPayingParcel(TransactionPack payload, Contract payment, int amount, int amountSecond,
                                                         Set<PrivateKey> keys, boolean withTestPayment); static Contract createBatch(Collection<PrivateKey> keys, Contract... contracts); static Contract addConsent(Contract source, KeyAddress... consentKeyAddresses); static Contract createEscrowContract(
            Collection<PrivateKey> issuerKeys,
            Collection<PublicKey> customerKeys,
            Collection<PublicKey> executorKeys,
            Collection<PublicKey> arbitratorKeys); static Contract createInternalEscrowContract(
            Collection<PrivateKey> issuerKeys,
            Collection<PublicKey> customerKeys,
            Collection<PublicKey> executorKeys,
            Collection<PublicKey> arbitratorKeys); static Contract createExternalEscrowContract(Contract internalEscrow, Collection<PrivateKey> issuerKeys); static Contract modifyPaymentForEscrowContract(
            Contract escrow,
            Contract payment,
            Collection<PrivateKey> paymentOwnerKeys,
            Collection<PublicKey> customerKeys,
            Collection<PublicKey> executorKeys); static Contract modifyPaymentForEscrowContract(
            String escrowOrigin,
            Contract payment,
            Collection<PrivateKey> paymentOwnerKeys,
            Collection<PublicKey> customerKeys,
            Collection<PublicKey> executorKeys); static boolean addPaymentToEscrowContract(
            Contract escrow,
            Contract payment,
            Collection<PrivateKey> paymentOwnerKeys,
            Collection<PublicKey> customerKeys,
            Collection<PublicKey> executorKeys); static Contract completeEscrowContract(Contract escrow); static Contract cancelEscrowContract(Contract escrow); static Contract takeEscrowPayment(Collection<PrivateKey> newOwnerKeys, Contract payment); synchronized static Contract createRateLimitDisablingContract(PublicKey key, Contract payment, int amount, Set<PrivateKey> keys);  }