Tabnine Logo
Contract.setIssuerKeys
Code IndexAdd Tabnine to your IDE (free)

How to use
setIssuerKeys
method
in
com.icodici.universa.contract.Contract

Best Java code snippets using com.icodici.universa.contract.Contract.setIssuerKeys (Showing top 12 results out of 315)

origin: UniversaBlockchain/universa

static Contract createSimpleContract(PrivateKey key) {
  Contract result = new Contract();
  // default expiration date
  result.setExpiresAt(ZonedDateTime.now().plusDays(90));
  // issuer role is a key for a new contract
  result.setIssuerKeys(key.getPublicKey().getShortAddress());
  // issuer is owner, link roles
  result.registerRole(new RoleLink("owner", "issuer"));
  result.registerRole(new RoleLink("creator", "issuer"));
  return result;
}
origin: UniversaBlockchain/universa

  privateKeys.add(privateKey);
contract.setIssuerKeys(privateKeys);
contract.setExpiresAt(ZonedDateTime.now().plusDays(90));
contract.registerRole(new RoleLink("owner", "issuer"));
origin: UniversaBlockchain/universa

/**
 * Create a batch contract, which registers all the included contracts, possibily referencing each other,
 * in the single transaction, saving time and reducing U cost. Note that if any of the batched contracts
 * fails, the whole batch is rejected.
 *
 * @param contracts to register all in one batch. Shuld be prepared and sealed.
 * @param keys to sign batch with.
 * @return batch contract that includes all contracts as new items.
 */
public static Contract createBatch(Collection<PrivateKey> keys, Contract... contracts) {
  Contract batch = new Contract();
  batch.setIssuerKeys(keys);
  batch.registerRole(new RoleLink("creator","issuer"));
  batch.registerRole(new RoleLink("owner","issuer"));
  batch.setExpiresAt(ZonedDateTime.now().plusDays(3));
  for(Contract c : contracts) {
    batch.addNewItems(c);
  }
  batch.addSignerKeys(keys);
  batch.seal();
  return batch;
}
origin: UniversaBlockchain/universa

public void asd() throws Exception {
  PrivateKey key = new PrivateKey(Do.read("/Users/romanu/Downloads/ru/roman.uskov.privateKey.unikey"));
  Set<PrivateKey> issuers = new HashSet<>();
  issuers.add(key);
  Set<PublicKey> owners = new HashSet<>();
  owners.add(key.getPublicKey());
  TestSpace testSpace = prepareTestSpace();
  testSpace.nodes.forEach(n->n.config.setIsFreeRegistrationsAllowedFromYaml(true));
  for(int i = 109; i < 110; i++) {
    Contract c = ContractsService.createTokenContract(issuers, owners, new BigDecimal("100000.9"), new BigDecimal("0.01"));
    c.setIssuerKeys(key.getPublicKey().getShortAddress());
    c.setCreatorKeys(key.getPublicKey().getShortAddress());
    c.setExpiresAt(ZonedDateTime.now().plusDays(10));
    c.seal();
    new FileOutputStream("/Users/romanu/Downloads/ru/token"+i+".unicon").write(c.getPackedTransaction());
    assertEquals(testSpace.client.register(Contract.fromPackedTransaction(Do.read("/Users/romanu/Downloads/ru/token"+i+".unicon")).getPackedTransaction(),10000).state,ItemState.APPROVED);
  }
}
origin: UniversaBlockchain/universa

/**
 * Create a default empty new contract using a provided key as issuer and owner and sealer. Default expiration is
 * set to 90 days.
 * <p>
 * This constructor adds key as sealing signature so it is ready to {@link #seal()} just after construction, thought
 * it is necessary to put real data to it first. It is allowed to change owner, expiration and data fields after
 * creation (but before sealing).
 * <p>
 * Change owner permission is added by default
 * @param key is {@link PrivateKey} for creating roles "issuer", "owner", "creator" and sign contract
 */
public Contract(PrivateKey key) {
  this();
  // default expiration date
  setExpiresAt(ZonedDateTime.now().plusDays(90));
  // issuer role is a key for a new contract
  setIssuerKeys(key.getPublicKey());
  // issuer is owner, link roles
  registerRole(new RoleLink("owner", "issuer"));
  registerRole(new RoleLink("creator", "issuer"));
  RoleLink roleLink = new RoleLink("@change_ower_role","owner");
  roleLink.setContract(this);
  // owner can change permission
  addPermission(new ChangeOwnerPermission(roleLink));
  // issuer should sign
  addSignerKey(key);
}
origin: UniversaBlockchain/universa

@Test
public void shouldNotSplitWithAnotherIssuerSerialize() throws Exception {
  Contract c = createCoin();
  c.addSignerKeyFromFile(PRIVATE_KEY_PATH);
  sealCheckTrace(c, true);
  Contract c2 = c.splitValue(FIELD_NAME, new Decimal(50));
  c2.setIssuerKeys(ownerKey1.getPublicKey());
  sealCheckTrace(c2, false);
}
origin: UniversaBlockchain/universa

Contract consent = new Contract();
consent.setExpiresAt(ZonedDateTime.now().plusDays(10));
consent.setIssuerKeys(Arrays.asList(consentKeyAddresses));
consent.registerRole(new RoleLink("creator","issuer"));
consent.registerRole(new RoleLink("owner","issuer"));
origin: UniversaBlockchain/universa

@Test
public void issuerTest() throws Exception {
  KeyAddress keyAddress1 = TestKeys.privateKey(0).getPublicKey().getShortAddress();
  KeyAddress keyAddress2 = TestKeys.privateKey(1).getPublicKey().getShortAddress();
  Contract contract = new Contract(TestKeys.privateKey(2));
  contract.setCreatorKeys(keyAddress1);
  contract.setIssuerKeys(keyAddress2);
  contract.addSignerKey(TestKeys.privateKey(0));
  contract.seal();
  assertFalse(contract.check());
  contract.setIssuerKeys(keyAddress1);
  contract.getErrors().clear();
  contract.seal();
  assertTrue(contract.check());
}
origin: UniversaBlockchain/universa

c.setIssuerKeys(TestKeys.publicKey(3));
c.addSignerKey(TestKeys.privateKey(3));
c.registerRole(new RoleLink("owner", "issuer"));
origin: UniversaBlockchain/universa

private Contract createNetConfigContract(List<NodeInfo> netConfig,PrivateKey issuerKey) throws IOException {
  Contract contract = new Contract();
  contract.setIssuerKeys(issuerKey.getPublicKey());
  contract.registerRole(new RoleLink("creator", "issuer"));
  ListRole listRole = new ListRole("owner");
  for(NodeInfo ni: netConfig) {
    SimpleRole role = new SimpleRole(ni.getName());
    contract.registerRole(role);
    role.addKeyRecord(new KeyRecord(ni.getPublicKey()));
    listRole.addRole(role);
  }
  listRole.setQuorum(netConfig.size()-1);
  contract.registerRole(listRole);
  RoleLink ownerLink = new RoleLink("ownerlink","owner");
  ChangeOwnerPermission changeOwnerPermission = new ChangeOwnerPermission(ownerLink);
  HashMap<String,Object> fieldsMap = new HashMap<>();
  fieldsMap.put("net_config",null);
  Binder modifyDataParams = Binder.of("fields",fieldsMap);
  ModifyDataPermission modifyDataPermission = new ModifyDataPermission(ownerLink,modifyDataParams);
  contract.addPermission(changeOwnerPermission);
  contract.addPermission(modifyDataPermission);
  contract.setExpiresAt(ZonedDateTime.now().plusYears(40));
  contract.getStateData().set("net_config",netConfig);
  contract.addSignerKey(issuerKey);
  contract.seal();
  return contract;
}
origin: UniversaBlockchain/universa

@Test
public void registerContractWithAnonymousId() throws Exception {
  TestSpace ts = prepareTestSpace();
  PrivateKey newPrivateKey = new PrivateKey(Do.read("./src/test_contracts/keys/u_key.private.unikey"));
  byte[] myAnonId = newPrivateKey.createAnonymousId();
  Contract contract = new Contract();
  contract.setExpiresAt(ZonedDateTime.now().plusDays(90));
  Role r = contract.setIssuerKeys(AnonymousId.fromBytes(myAnonId));
  contract.registerRole(new RoleLink("owner", "issuer"));
  contract.registerRole(new RoleLink("creator", "issuer"));
  contract.addPermission(new ChangeOwnerPermission(r));
  contract.addSignerKey(newPrivateKey);
  contract.seal();
  assertTrue(contract.isOk());
  System.out.println("contract.check(): " + contract.check());
  contract.traceErrors();
  ts.client.getSession().setPrivateKey(newPrivateKey);
  ts.client.restart();
  ItemResult itemResult = ts.client.register(contract.getPackedTransaction(), 5000);
  assertEquals(ItemState.APPROVED, itemResult.state);
  ts.nodes.forEach(x -> x.shutdown());
}
origin: UniversaBlockchain/universa

payload.setIssuerKeys(TestKeys.publicKey(3));
payload.addSignerKey(TestKeys.privateKey(3));
payload.registerRole(new RoleLink("owner", "issuer"));
payment.setIssuerKeys(TestKeys.publicKey(3));
payment.addSignerKey(TestKeys.privateKey(3));
payment.registerRole(new RoleLink("owner", "issuer"));
com.icodici.universa.contractContractsetIssuerKeys

Javadoc

Set "issuer" role to given keys

Popular methods of Contract

  • <init>
    Extract old, deprecated v2 self-contained binary partially unpacked by the TransactionPack, and fill
  • addNewItems
    Add one or more siblings to the contract. Note that those must be sealed before calling #seal() or #
  • addSignerKey
    Add private key to keys contract binary to be signed with when sealed next time. It is called before
  • getExpiresAt
    Get contract expiration time
  • getId
    Get the id sealing self if need
  • getPackedTransaction
    Pack the contract to the most modern .unicon format, same as TransactionPack#pack(). Uses bounded Tr
  • registerRole
    Register new role. Name must be unique otherwise existing role will be overwritten
  • seal
    Seal contract to binary. This call adds signatures from #getKeysToSignWith()
  • addSignatureToSeal
    Add signature to sealed (before) contract. Do not deserializing or changing contract bytes, but will
  • check
  • createRevision
    Create new revision to be changed, signed sealed and then ready to approve. Created "revision" contr
  • fromDslFile
    Create contract importing its parameters with passed .yaml file. No signatures are added automatical
  • createRevision,
  • fromDslFile,
  • fromPackedTransaction,
  • getCreatedAt,
  • getDefinition,
  • getErrors,
  • getKeysToSignWith,
  • getLastSealedBinary,
  • getNew,
  • getNewItems

Popular in Java

  • Start an intent from android
  • addToBackStack (FragmentTransaction)
  • putExtra (Intent)
  • onCreateOptionsMenu (Activity)
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now