congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
Contract.addSignerKey
Code IndexAdd Tabnine to your IDE (free)

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

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

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
List l =
  • Codota Iconnew ArrayList()
  • Codota Iconnew LinkedList()
  • Smart code suggestions by Tabnine
}
origin: UniversaBlockchain/universa

/**
 * Add private key from file to keys contract binary to be signed with when sealed next time. It is called before seal()
 * @param fileName path to file containing private key
 */
public void addSignerKeyFromFile(String fileName) throws IOException {
  addSignerKey(new PrivateKey(Do.read(fileName)));
}
origin: UniversaBlockchain/universa

@Test
public void splitLessThanMinValue() throws Exception {
  Contract root = createCoinWithAmount("200", FIELD_NAME);
  root = root.createRevision();
  root.addSignerKeyFromFile(PRIVATE_KEY_PATH);
  Contract c1 = root.splitValue(FIELD_NAME, new Decimal("0.00001"));
  root.addSignerKey(ownerKey2);
  c1.addSignerKey(ownerKey2);
  sealCheckTrace(c1, false);
  sealCheckTrace(root, false);
}
origin: UniversaBlockchain/universa

/**
 * Create new revision to be changed, signed sealed and then ready to approve. Created "revision" contract is a copy
 * of this contract, with all fields and references correctly set. After this call one need to change mutable
 * fields, add signing keys, seal it and then apss to Universa network for approval.
 *
 * @param keys initially added and signer keys. Role "creator" is set to these keys for new revision
 * @param transactional is {@link Transactional} section to create new revision with
 * @return new revision of this contract, identical to this one, to be modified.
 */
public synchronized Contract createRevision(Collection<PrivateKey> keys, Transactional transactional) {
  Contract newRevision = createRevision(transactional);
  Set<KeyRecord> krs = new HashSet<>();
  keys.forEach(k -> {
    krs.add(new KeyRecord(k.getPublicKey()));
    newRevision.addSignerKey(k);
  });
  newRevision.setCreator(krs);
  return newRevision;
}
origin: UniversaBlockchain/universa

@Test
public void overSpending() throws Exception {
  Contract root = createCoinWithAmount("200", FIELD_NAME);
  root = root.createRevision();
  root.addSignerKeyFromFile(PRIVATE_KEY_PATH);
  Contract c1 = root.splitValue(FIELD_NAME, new Decimal(100));
  root.addSignerKey(ownerKey2);
  c1.addSignerKey(ownerKey2);
  sealCheckTrace(c1, true);
  sealCheckTrace(root, true);
  // c1 == 100
  // now reset root to 200:
  root.getStateData().set(FIELD_NAME, new Decimal(200));
  // total now is 300 (200 + 100) - and must be rejected
  sealCheckTrace(root, false);
}
origin: UniversaBlockchain/universa

protected synchronized Contract checkPayment_preparePaymentContract(Set<PrivateKey> privateKeys) throws Exception {
  Contract stepaCoins = Contract.fromDslFile(ROOT_PATH + "stepaCoins.yml");
  stepaCoins.addSignerKey(privateKeys.iterator().next());
  stepaCoins.seal();
  registerAndCheckApproved(stepaCoins);
  Parcel parcel = createParcelWithFreshU(stepaCoins, privateKeys);
  return parcel.getPaymentContract();
}
origin: UniversaBlockchain/universa

@Test
public void shouldSplitWithChangedOwnerAndNewValueSerialize() throws Exception {
  int defaultValue = 1000000;
  int valueForSplit = 85;
  Contract c = createCoin();
  c.addSignerKeyFromFile(PRIVATE_KEY_PATH);
  Binder d = c.getStateData();
  sealCheckTrace(c, true);
  Contract c2 = c.splitValue(FIELD_NAME, new Decimal(valueForSplit));
  c2.addSignerKey(ownerKey2);
  Binder d2 = c2.getStateData();
  sealCheckTrace(c2, true);
  assertEquals(defaultValue - valueForSplit, d.getIntOrThrow(FIELD_NAME));
  assertEquals(valueForSplit, d2.getIntOrThrow(FIELD_NAME));
}
origin: UniversaBlockchain/universa

@Test
public void registerSimpleContract_getStateOnly() throws Exception {
  Set<PrivateKey> stepaPrivateKeys = new HashSet<>();
  Set<PublicKey> stepaPublicKeys = new HashSet<>();
  stepaPrivateKeys.add(new PrivateKey(Do.read(ROOT_PATH + "keys/stepan_mamontov.private.unikey")));
  for (PrivateKey pk : stepaPrivateKeys) {
    stepaPublicKeys.add(pk.getPublicKey());
  }
  Contract stepaCoins = Contract.fromDslFile(ROOT_PATH + "stepaCoins.yml");
  stepaCoins.addSignerKey(stepaPrivateKeys.iterator().next());
  stepaCoins.seal();
  ItemResult itemResult = nodeClient.getState(stepaCoins.getId());
  System.out.println("nodeClient.getState(stepaCoins): " + itemResult.state);
  assertEquals(ItemState.APPROVED, itemResult.state);
}
origin: UniversaBlockchain/universa

static Contract createComplexConctract(PrivateKey key, int subcontracts, int n) {
  Contract root = createSimpleContract(key);
  for(int i = 0; i < subcontracts; i++) {
    Contract c = createSimpleContract(key);
    c.setExpiresAt(c.getExpiresAt().plusSeconds(i+1+(subcontracts+1)*n));
    c.seal();
    root.addNewItems(c);
  }
  root.setExpiresAt(root.getExpiresAt().plusSeconds((subcontracts+1)*n));
  root.addSignerKey(key);
  root.seal();
  return root;
}
origin: UniversaBlockchain/universa

@Ignore("removed functionality")
@Test(timeout = 90000)
public void declineItemFromoutWhiteList() throws Exception {
  Set<PrivateKey> stepaPrivateKeys = new HashSet<>();
  stepaPrivateKeys.add(new PrivateKey(Do.read(ROOT_PATH + "keys/stepan_mamontov.private.unikey")));
  Contract stepaCoins = Contract.fromDslFile(ROOT_PATH + "stepaCoins.yml");
  stepaCoins.setExpiresAt(ZonedDateTime.now().plusMonths(1));
  stepaCoins.addSignerKey(stepaPrivateKeys.iterator().next());
  stepaCoins.seal();
  stepaCoins.check();
  stepaCoins.traceErrors();
  node.registerItem(stepaCoins);
  ItemResult itemResult = node.waitItem(stepaCoins.getId(), 18000);
  assertEquals(ItemState.UNDEFINED, itemResult.state);
}
origin: UniversaBlockchain/universa

  @Test
  public void checkTransactional() throws Exception {

    PrivateKey manufacturePrivateKey = new PrivateKey(Do.read(rootPath + "_xer0yfe2nn1xthc.private.unikey"));

    Contract delorean = Contract.fromDslFile(rootPath + "DeLoreanOwnership.yml");
    delorean.addSignerKey(manufacturePrivateKey);
    delorean.seal();
    delorean.traceErrors();

    Contract.Transactional transactional = delorean.createTransactionalSection();
    Reference reference = new Reference();
//        reference.setName("transactional_example");
    transactional.addReference(reference);
    Contract deloreanTransactional = delorean.createRevision(transactional);
    deloreanTransactional.addSignerKey(manufacturePrivateKey);
    deloreanTransactional.seal();
    deloreanTransactional.traceErrors();

  }

origin: UniversaBlockchain/universa

@Test
public void checkFitTestnetCriteria() throws Exception {
  PrivateKey key = new PrivateKey(Do.read(rootPath + "keys/stepan_mamontov.private.unikey"));
  Contract contract = Contract.fromDslFile(rootPath + "LamborghiniTestDrive.yml");
  contract.setExpiresAt(ZonedDateTime.now().plusMonths(1));
  contract.addSignerKey(key);
  sealCheckTrace(contract, true);
  System.out.println("Processing cost is " + contract.getProcessedCostU());
  assertTrue(contract.isSuitableForTestnet());
  // now set contract limited for testnet
  contract.setLimitedForTestnet(true);
  sealCheckTrace(contract, true);
  assertTrue(contract.isSuitableForTestnet());
}
origin: UniversaBlockchain/universa

@Test
public void checkTestnetExpirationDateCriteria() throws Exception {
  PrivateKey key = new PrivateKey(Do.read(rootPath + "keys/stepan_mamontov.private.unikey"));
  Contract contract = Contract.fromDslFile(rootPath + "LamborghiniTestDrive.yml");
  contract.addSignerKey(key);
  sealCheckTrace(contract, true);
  contract.setExpiresAt(ZonedDateTime.now().plusMonths(13));
  assertFalse(contract.isSuitableForTestnet());
  // now set contract limited for testnet
  contract.setLimitedForTestnet(true);
  sealCheckTrace(contract, false);
  assertFalse(contract.isSuitableForTestnet());
}
origin: UniversaBlockchain/universa

@Test
public void checkTestnetKeyStrengthCriteria() throws Exception {
  PrivateKey key = new PrivateKey(Do.read(PRIVATE_KEY_PATH));
  Contract contract = createCoin100apiv3();
  contract.setExpiresAt(ZonedDateTime.now().plusMonths(1));
  contract.addSignerKey(key);
  sealCheckTrace(contract, true);
  assertFalse(contract.isSuitableForTestnet());
  // now set contract limited for testnet
  contract.setLimitedForTestnet(true);
  sealCheckTrace(contract, false);
  assertFalse(contract.isSuitableForTestnet());
}
origin: UniversaBlockchain/universa

  @Test
  public void checkAnonymizingRole() throws Exception {

    PrivateKey key = new PrivateKey(Do.read(PRIVATE_KEY_PATH));
    Contract contract = createCoin100apiv3();
    contract.addSignerKey(key);
    sealCheckTrace(contract, true);

    assertTrue(contract.getIssuer().getKeys().contains(key.getPublicKey()));

    contract.anonymizeRole("issuer");
    contract.anonymizeRole("owner");
    contract.seal();

    assertFalse(contract.getIssuer().getKeys().contains(key.getPublicKey()));

    Contract anonPublishedContract = new Contract(contract.getLastSealedBinary());

    assertFalse(anonPublishedContract.getIssuer().getKeys().contains(key.getPublicKey()));
//        assertFalse(anonPublishedContract.getSealedByKeys().contains(key.getPublicKey()));
  }

origin: UniversaBlockchain/universa

@Test
public void modifyExpiresAtAllowed() throws Exception {
  Contract contract = new Contract(TestKeys.privateKey(0));
  contract.getStateData().put("field_to_be_changed", "value1");
  ModifyDataPermission modifyDataPermission = new ModifyDataPermission(contract.getRole("owner"), new Binder());
  modifyDataPermission.addField("/expires_at", null);
  contract.addPermission(modifyDataPermission);
  contract.seal();
  Contract changed = contract.createRevision();
  changed.addSignerKey(TestKeys.privateKey(0));
  changed.setExpiresAt(ZonedDateTime.now().plusDays(1));
  changed.seal();
  changed.check();
  assertTrue(changed.isOk());
}
origin: UniversaBlockchain/universa

@Test
public void modifyExpiresAtDeclined() throws Exception {
  Contract contract = new Contract(TestKeys.privateKey(0));
  contract.getStateData().put("field_to_be_changed", "value1");
  ModifyDataPermission modifyDataPermission = new ModifyDataPermission(contract.getRole("owner"), new Binder());
  modifyDataPermission.addField("expires_at", null);
  contract.addPermission(modifyDataPermission);
  contract.seal();
  Contract changed = contract.createRevision();
  changed.addSignerKey(TestKeys.privateKey(0));
  changed.setExpiresAt(ZonedDateTime.now().plusDays(1));
  changed.seal();
  changed.check();
  assertTrue(!changed.isOk());
}
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

@Test
public void defaultParameters() throws Exception {
  Contract contract = new Contract(TestKeys.privateKey(0));
  contract.getStateData().put("field1", "33.000000000000000001");
  ChangeNumberPermission changeNumberPermission = new ChangeNumberPermission(contract.getRole("owner"), Binder.of("field_name", "field1"));
  contract.addPermission(changeNumberPermission);
  contract.seal();
  Contract changed = contract.createRevision();
  changed.addSignerKey(TestKeys.privateKey(0));
  changed.getStateData().set("field1", "33.000000000000000002");
  changed.seal();
  changed.check();
  assertTrue(changed.isOk());
}
origin: UniversaBlockchain/universa

@Test
public void modifyDataDeclined() throws Exception {
  Contract contract = new Contract(TestKeys.privateKey(0));
  contract.getStateData().put("field_to_be_changed", "value1");
  ModifyDataPermission modifyDataPermission = new ModifyDataPermission(contract.getRole("owner"), new Binder());
  contract.addPermission(modifyDataPermission);
  contract.seal();
  Contract changed = contract.createRevision();
  changed.addSignerKey(TestKeys.privateKey(0));
  changed.getStateData().set("field_to_be_changed", "value2");
  changed.seal();
  changed.check();
  assertTrue(!changed.isOk());
}
origin: UniversaBlockchain/universa

@Test
public void modifyDataAllowed() throws Exception {
  Contract contract = new Contract(TestKeys.privateKey(0));
  contract.getStateData().put("field_to_be_changed", "value1");
  ModifyDataPermission modifyDataPermission = new ModifyDataPermission(contract.getRole("owner"), new Binder());
  modifyDataPermission.addField("field_to_be_changed", null);
  contract.addPermission(modifyDataPermission);
  contract.seal();
  Contract changed = contract.createRevision();
  changed.addSignerKey(TestKeys.privateKey(0));
  changed.getStateData().set("field_to_be_changed", "value2");
  changed.seal();
  changed.check();
  assertTrue(changed.isOk());
}
com.icodici.universa.contractContractaddSignerKey

Javadoc

Add private key to keys contract binary to be signed with when sealed next time. It is called before seal()

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 #
  • 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
  • fromPackedTransaction
    Main .unicon read routine. Load any .unicon version and construct a linked Contract with counterpart
  • fromDslFile,
  • fromPackedTransaction,
  • getCreatedAt,
  • getDefinition,
  • getErrors,
  • getKeysToSignWith,
  • getLastSealedBinary,
  • getNew,
  • getNewItems

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSystemService (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • getResourceAsStream (ClassLoader)
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Path (java.nio.file)
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • 21 Best IntelliJ Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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