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

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

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

origin: UniversaBlockchain/universa

@Test
public void createFromBinaryWithRealContract() throws Exception {
  String fileName = "./src/test_contracts/simple_root_contract.yml";
  Contract c = Contract.fromDslFile(fileName);
  c.addSignerKeyFromFile(PRIVATE_KEY_PATH);
  sealCheckTrace(c, true);
  fileName = "./src/test_contracts/binaryContract.unc";
  try(FileOutputStream stream = new FileOutputStream(fileName)) {
    stream.write(c.seal());
  }
  readContract(fileName);
}
origin: UniversaBlockchain/universa

@Test
public void createFromSealedWithRealContract() throws Exception {
  String fileName = "./src/test_contracts/subscription.yml";
  Contract c = Contract.fromDslFile(fileName);
  c.addSignerKeyFromFile(PRIVATE_KEY_PATH);
  sealCheckTrace(c, true);
  // Contract from seal
  byte[] seal = c.seal();
  Contract sealedContract = new Contract(seal);
  sealedContract.addSignerKeyFromFile(PRIVATE_KEY_PATH);
  sealCheckTrace(sealedContract, true);
}
origin: UniversaBlockchain/universa

@Test
public void createFromSealedWithRealContractData() throws Exception {
  String fileName = "./src/test_contracts/subscription_with_data.yml";
  Contract c = Contract.fromDslFile(fileName);
  c.addSignerKeyFromFile(PRIVATE_KEY_PATH);
  sealCheckTrace(c, true);
  // Contract from seal
  byte[] seal = c.seal();
  Contract sealedContract = new Contract(seal);
  sealedContract.addSignerKeyFromFile(PRIVATE_KEY_PATH);
  sealCheckTrace(sealedContract, true);
}
origin: UniversaBlockchain/universa

@Test
public void shouldNotSplitWithAnotherRevision() throws Exception {
  Contract c = createCoin();
  c.addSignerKeyFromFile(PRIVATE_KEY_PATH);
  c.getState().setBranchNumber(1);
  try {
    Contract c2 = c.split(1)[0];
    fail("Expected exception to be thrown.");
  } catch (IllegalArgumentException e) {
    assertTrue(e.getMessage().equalsIgnoreCase("this revision is already split"));
  }
}
origin: UniversaBlockchain/universa

private Contract basicContractCreation(final String fileName, final String keyFileName, final PrivateKey key) throws Exception {
  Contract c = Contract.fromDslFile(rootPath + fileName);
  c.setOwnerKey(key);
  c.addSignerKeyFromFile(rootPath + keyFileName);
  c.seal();
  c.check();
  c.traceErrors();
  assertTrue(c.check());
  return c;
}
origin: UniversaBlockchain/universa

@Test
public void validPermissionIds() throws Exception {
  Contract c = Contract.fromDslFile(ROOT_CONTRACT);
  c.addSignerKeyFromFile(PRIVATE_KEY_PATH);
  byte[] sealed = c.seal();
  assertTrue(c.check());
  Binder s = DefaultBiMapper.serialize(c);
  s.getBinderOrThrow("definition","permissions");
}
origin: UniversaBlockchain/universa

  protected Contract createCoinWithAmount(String amount, String fieldName) throws Exception {
    Contract contract = createCoin();
    contract.getStateData().set(fieldName, new Decimal(amount));
    contract.addSignerKeyFromFile(PRIVATE_KEY_PATH);

    sealCheckTrace(contract, true);

    return contract;
  }
}
origin: UniversaBlockchain/universa

@Test
public void checkContractCreatedAtFutureTime() throws Exception{
  Contract futureContract = Contract.fromDslFile(rootPath + "simple_root_contract_future.yml");
  futureContract.addSignerKeyFromFile(rootPath+"_xer0yfe2nn1xthc.private.unikey");
  futureContract.seal();
  futureContract.check();
  futureContract.traceErrors();
  System.out.println("Contract is valid: " + futureContract.isOk());
  assertFalse(futureContract.isOk());
}
origin: UniversaBlockchain/universa

@Test
public void checkRegisterContractCreatedAtFutureTime() throws Exception{
  Contract futureContract = Contract.fromDslFile(ROOT_PATH + "simple_root_contract_future.yml");
  futureContract.addSignerKeyFromFile(ROOT_PATH+"_xer0yfe2nn1xthc.private.unikey");
  futureContract.seal();
  futureContract.check();
  futureContract.traceErrors();
  System.out.println("Contract is valid: " + futureContract.isOk());
  assertFalse(futureContract.isOk());
}
origin: UniversaBlockchain/universa

@Test
public void checkContractCreatedAtPastTime() throws Exception{
  Contract oldContract = Contract.fromDslFile(rootPath + "simple_root_contract_past.yml");
  oldContract.addSignerKeyFromFile(rootPath+"_xer0yfe2nn1xthc.private.unikey");
  oldContract.seal();
  oldContract.check();
  oldContract.traceErrors();
  System.out.println("Contract is valid: " + oldContract.isOk());
  assertFalse(oldContract.isOk());
}
origin: UniversaBlockchain/universa

@Test
public void checkContractExpiresAtDistantPastTime() throws Exception{
  Contract oldContract = Contract.fromDslFile(rootPath + "simple_root_contract.yml");
  oldContract.addSignerKeyFromFile(rootPath+"_xer0yfe2nn1xthc.private.unikey");
  oldContract.getDefinition().setExpiresAt(ZonedDateTime.of(LocalDateTime.MIN.truncatedTo(ChronoUnit.SECONDS), ZoneOffset.UTC));
  oldContract.seal();
  oldContract.check();
  oldContract.traceErrors();
  System.out.println("Contract is valid: " + oldContract.isOk());
  assertFalse(oldContract.isOk());
}
origin: UniversaBlockchain/universa

@Test
public void checkRegisterContractExpiresAtDistantPastTime() throws Exception{
  Contract oldContract = Contract.fromDslFile(ROOT_PATH + "simple_root_contract.yml");
  oldContract.addSignerKeyFromFile(ROOT_PATH+"_xer0yfe2nn1xthc.private.unikey");
  oldContract.getDefinition().setExpiresAt(ZonedDateTime.of(LocalDateTime.MIN.truncatedTo(ChronoUnit.SECONDS), ZoneOffset.UTC));
  oldContract.seal();
  oldContract.check();
  oldContract.traceErrors();
  System.out.println("Contract is valid: " + oldContract.isOk());
  assertFalse(oldContract.isOk());
}
origin: UniversaBlockchain/universa

  @Test
  public void goodRevoke() throws Exception {
    Contract c = Contract.fromDslFile(rootPath + "simple_root_contract.yml");
    c.addSignerKeyFromFile(rootPath+"_xer0yfe2nn1xthc.private.unikey");
    PrivateKey goodKey = c.getKeysToSignWith().iterator().next();
    c.setOwnerKeys(new KeyRecord(goodKey.getPublicKey()));
    c.seal();

    Contract revokeContract = c.createRevocation(goodKey);

    revokeContract.check();
    assertTrue(revokeContract.isOk());
//        tc.traceErrors();
  }

origin: UniversaBlockchain/universa

@Test
public void checkContractExpiresAtResentFutureTime() throws Exception{
  Contract futureContract = Contract.fromDslFile(rootPath + "simple_root_contract.yml");
  futureContract.addSignerKeyFromFile(rootPath+"_xer0yfe2nn1xthc.private.unikey");
  futureContract.getDefinition().setExpiresAt(futureContract.getCreatedAt().plusMinutes(1));
  futureContract.seal();
  assertTrue(futureContract.check());
  System.out.println("Contract is valid: " + futureContract.isOk());
}
origin: UniversaBlockchain/universa

@Test
public void checkContractExpiresAtDistantFutureTime() throws Exception{
  Contract futureContract = Contract.fromDslFile(rootPath + "simple_root_contract.yml");
  futureContract.addSignerKeyFromFile(rootPath+"_xer0yfe2nn1xthc.private.unikey");
  futureContract.getDefinition().setExpiresAt(futureContract.getCreatedAt().plusYears(50));
  futureContract.seal();
  assertTrue(futureContract.check());
  System.out.println("Contract is valid: " + futureContract.isOk());
}
origin: UniversaBlockchain/universa

@Test
public void checkRegisterContractExpiresAtReсentFutureTime() throws Exception{
  Contract futureContract = Contract.fromDslFile(ROOT_PATH + "simple_root_contract.yml");
  futureContract.addSignerKeyFromFile(ROOT_PATH+"_xer0yfe2nn1xthc.private.unikey");
  futureContract.getDefinition().setExpiresAt(futureContract.getCreatedAt().plusMinutes(1));
  futureContract.seal();
  assertTrue(futureContract.check());
  System.out.println("Contract is valid: " + futureContract.isOk());
  registerAndCheckApproved(futureContract);
}
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

@Test
public void checkRegisterContractExpiresAtReсentPastTime() throws Exception{
  Contract oldContract = Contract.fromDslFile(ROOT_PATH + "simple_root_contract.yml");
  oldContract.addSignerKeyFromFile(ROOT_PATH+"_xer0yfe2nn1xthc.private.unikey");
  oldContract.getDefinition().setExpiresAt(oldContract.getCreatedAt().minusMinutes(1));
  oldContract.seal();
  oldContract.check();
  oldContract.traceErrors();
  System.out.println("Contract is valid: " + oldContract.isOk());
  assertFalse(oldContract.isOk());
}
origin: UniversaBlockchain/universa

@Test
public void checkContractExpiresAtResentPastTime() throws Exception{
  Contract oldContract = Contract.fromDslFile(rootPath + "simple_root_contract.yml");
  oldContract.addSignerKeyFromFile(rootPath+"_xer0yfe2nn1xthc.private.unikey");
  oldContract.getDefinition().setExpiresAt(oldContract.getCreatedAt().minusMinutes(1));
  oldContract.seal();
  oldContract.check();
  oldContract.traceErrors();
  System.out.println("Contract is valid: " + oldContract.isOk());
  assertFalse(oldContract.isOk());
}
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);
}
com.icodici.universa.contractContractaddSignerKeyFromFile

Javadoc

Add private key from file 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 #
  • 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

  • Reading from database using SQL prepared statement
  • requestLocationUpdates (LocationManager)
  • onRequestPermissionsResult (Fragment)
  • getSupportFragmentManager (FragmentActivity)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • Top Vim plugins
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