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

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

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

origin: UniversaBlockchain/universa

/**
 * Get the id sealing self if need
 *
 * @param sealAsNeed true to seal the contract if there is no {@link #getLastSealedBinary()}.
 *
 * @return contract id.
 */
public HashId getId(boolean sealAsNeed) {
  if (id != null)
    return id;
  if (getLastSealedBinary() == null && sealAsNeed)
    seal();
  return getId();
}
origin: UniversaBlockchain/universa

@Override
public Binder serialize(BiSerializer serializer) {
  synchronized (this) {
    Binder of = Binder.of(
        "contract", contract.getLastSealedBinary(),
        "subItems",
        serializer.serialize(
            subItems.values().stream()
                .map(x -> x.getLastSealedBinary()).collect(Collectors.toList())
        )
    );
    if(referencedItems.size() > 0) {
      of.set("referencedItems",
          serializer.serialize(
              referencedItems.values().stream()
                  .map(x -> x.getLastSealedBinary()).collect(Collectors.toList())
          ));
    }
    if(keysForPack.size() > 0) {
      of.set("keys", serializer.serialize(
          keysForPack.stream()
              .map(x -> x.pack()).collect(Collectors.toList())
      ));
    }
    if(contract instanceof NSmartContract) {
      of.set("extended_type", ((NSmartContract) contract).getExtendedType());
    }
    return of;
  }
}
origin: UniversaBlockchain/universa

public byte[] sealAsV2() {
  byte[] theContract = Boss.pack(
      BossBiMapper.serialize(
          Binder.of(
              "contract", this,
              "revoking", revokingItems.stream()
                  .map(i -> i.getLastSealedBinary())
                  .collect(Collectors.toList()),
              "new", newItems.stream()
                  .map(i -> i.seal())
                  .collect(Collectors.toList())
          )
      )
  );
  //redundand code. already executed here newItems.stream().map(i -> i.seal())
  //newItems.forEach(c -> c.seal());
  Binder result = Binder.of(
      "type", "unicapsule",
      "version", 2,
      "data", theContract
  );
  List<byte[]> signatures = new ArrayList<>();
  keysToSignWith.forEach(key -> {
    signatures.add(ExtendedSignature.sign(key, theContract));
  });
  result.put("signatures", signatures);
  setOwnBinary(result);
  return sealedBinary;
}
origin: UniversaBlockchain/universa

data = contract.getLastSealedBinary();
origin: UniversaBlockchain/universa

  /**
   * Register a specified contract.
   *
   * @param contract              must be a sealed binary.
   * @param waitTime - wait time for responce.
   * @param fromPackedTransaction - register contract with Contract.getPackedTransaction()
   */
  @Deprecated
  public static void registerContract(Contract contract, int waitTime, Boolean fromPackedTransaction) throws IOException {
//        checkContract(contract);
    List<ErrorRecord> errors = contract.getErrors();
    if (errors.size() > 0) {
      report("contract has errors and can't be submitted for registration");
      report("contract id: " + contract.getId().toBase64String());
      addErrors(errors);
    } else {
//            contract.seal();

      ItemResult r;
      if (fromPackedTransaction) {
        r = getClientNetwork().register(contract.getPackedTransaction(), waitTime);
      } else {
        r = getClientNetwork().register(contract.getLastSealedBinary(), waitTime);
      }
      report("submitted with result:");
      report(r.toString());
    }
  }

origin: UniversaBlockchain/universa

@Test
public void anonymizeRole() throws Exception {
  callMain2("-create", rootPath + "TokenDSLTemplate.yml", "--output", basePath + "forRoleAnonymizing.unicon",
      "-k", rootPath + "_xer0yfe2nn1xthc.private.unikey");
  assertTrue (new File(basePath + "forRoleAnonymizing.unicon").exists());
  callMain("-anonymize", basePath + "forRoleAnonymizing.unicon",
      "-role", "issuer");
  assertTrue (new File(basePath + "forRoleAnonymizing_anonymized.unicon").exists());
  System.out.println(output);
  PrivateKey key = new PrivateKey(Do.read(rootPath + "_xer0yfe2nn1xthc.private.unikey"));
  Contract contract = CLIMain.loadContract(basePath + "forRoleAnonymizing_anonymized.unicon", true);
  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 anonymizeRoleAndSaveWithName() throws Exception {
  callMain2("-create", rootPath + "TokenDSLTemplate.yml", "--output", basePath + "forRoleAnonymizing.unicon",
      "-k", rootPath + "_xer0yfe2nn1xthc.private.unikey");
  assertTrue (new File(basePath + "forRoleAnonymizing.unicon").exists());
  callMain("-anonymize", basePath + "forRoleAnonymizing.unicon",
      "-role", "issuer",
      "--output", basePath + "myAnon.unicon");
  assertTrue (new File(basePath + "myAnon.unicon").exists());
  System.out.println(output);
  PrivateKey key = new PrivateKey(Do.read(rootPath + "_xer0yfe2nn1xthc.private.unikey"));
  Contract contract = CLIMain.loadContract(basePath + "myAnon.unicon", true);
  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 anonymizeRoleForTwoContracts() throws Exception {
  callMain2("-create", rootPath + "TokenDSLTemplate.yml", "--output", basePath + "forRoleAnonymizing1.unicon",
      "-k", rootPath + "_xer0yfe2nn1xthc.private.unikey");
  callMain2("-create", rootPath + "TokenDSLTemplate.yml", "--output", basePath + "forRoleAnonymizing2.unicon",
      "-k", rootPath + "_xer0yfe2nn1xthc.private.unikey");
  assertTrue (new File(basePath + "forRoleAnonymizing1.unicon").exists());
  assertTrue (new File(basePath + "forRoleAnonymizing2.unicon").exists());
  callMain("-anonymize", basePath + "forRoleAnonymizing1.unicon", basePath + "forRoleAnonymizing2.unicon",
      "-role", "issuer");
  assertTrue (new File(basePath + "forRoleAnonymizing1_anonymized.unicon").exists());
  assertTrue (new File(basePath + "forRoleAnonymizing2_anonymized.unicon").exists());
  System.out.println(output);
  PrivateKey key = new PrivateKey(Do.read(rootPath + "_xer0yfe2nn1xthc.private.unikey"));
  Contract contract1 = CLIMain.loadContract(basePath + "forRoleAnonymizing1_anonymized.unicon", true);
  assertFalse(contract1.getIssuer().getKeys().contains(key.getPublicKey()));
  Contract anonPublishedContract1 = new Contract(contract1.getLastSealedBinary());
  assertFalse(anonPublishedContract1.getIssuer().getKeys().contains(key.getPublicKey()));
  assertFalse(anonPublishedContract1.getSealedByKeys().contains(key.getPublicKey()));
  Contract contract2 = CLIMain.loadContract(basePath + "forRoleAnonymizing2_anonymized.unicon", true);
  assertFalse(contract2.getIssuer().getKeys().contains(key.getPublicKey()));
  Contract anonPublishedContract2 = new Contract(contract2.getLastSealedBinary());
  assertFalse(anonPublishedContract2.getIssuer().getKeys().contains(key.getPublicKey()));
  assertFalse(anonPublishedContract2.getSealedByKeys().contains(key.getPublicKey()));
}
origin: UniversaBlockchain/universa

@Test
public void anonymizeRoleForTwoContractsWithNames() throws Exception {
  callMain2("-create", rootPath + "TokenDSLTemplate.yml", "--output", basePath + "forRoleAnonymizing1.unicon",
      "-k", rootPath + "_xer0yfe2nn1xthc.private.unikey");
  callMain2("-create", rootPath + "TokenDSLTemplate.yml", "--output", basePath + "forRoleAnonymizing2.unicon",
      "-k", rootPath + "_xer0yfe2nn1xthc.private.unikey");
  assertTrue (new File(basePath + "forRoleAnonymizing1.unicon").exists());
  assertTrue (new File(basePath + "forRoleAnonymizing2.unicon").exists());
  callMain("-anonymize", basePath + "forRoleAnonymizing1.unicon", basePath + "forRoleAnonymizing2.unicon",
      "-role", "issuer",
      "--output", basePath + "myAnon1.unicon", "--output", basePath + "myAnon2.unicon");
  assertTrue (new File(basePath + "myAnon1.unicon").exists());
  assertTrue (new File(basePath + "myAnon2.unicon").exists());
  System.out.println(output);
  PrivateKey key = new PrivateKey(Do.read(rootPath + "_xer0yfe2nn1xthc.private.unikey"));
  Contract contract1 = CLIMain.loadContract(basePath + "myAnon1.unicon", true);
  assertFalse(contract1.getIssuer().getKeys().contains(key.getPublicKey()));
  Contract anonPublishedContract1 = new Contract(contract1.getLastSealedBinary());
  assertFalse(anonPublishedContract1.getIssuer().getKeys().contains(key.getPublicKey()));
  assertFalse(anonPublishedContract1.getSealedByKeys().contains(key.getPublicKey()));
  Contract contract2 = CLIMain.loadContract(basePath + "myAnon2.unicon", true);
  assertFalse(contract2.getIssuer().getKeys().contains(key.getPublicKey()));
  Contract anonPublishedContract2 = new Contract(contract2.getLastSealedBinary());
  assertFalse(anonPublishedContract2.getIssuer().getKeys().contains(key.getPublicKey()));
  assertFalse(anonPublishedContract2.getSealedByKeys().contains(key.getPublicKey()));
}
origin: UniversaBlockchain/universa

assertArrayEquals(c.getLastSealedBinary(), c1.getLastSealedBinary());
origin: UniversaBlockchain/universa

@Test
public void anonymizeAllRoles() throws Exception {
  callMain2("-create", rootPath + "TokenDSLTemplate.yml", "--output", basePath + "forRoleAnonymizing.unicon",
      "-k", rootPath + "_xer0yfe2nn1xthc.private.unikey");
  assertTrue (new File(basePath + "forRoleAnonymizing.unicon").exists());
  callMain("-anonymize", basePath + "forRoleAnonymizing.unicon");
  assertTrue (new File(basePath + "forRoleAnonymizing_anonymized.unicon").exists());
  System.out.println(output);
  PrivateKey key = new PrivateKey(Do.read(rootPath + "_xer0yfe2nn1xthc.private.unikey"));
  PrivateKey ownerKey = new PrivateKey(Do.read(rootPath + "keys/stepan_mamontov.private.unikey"));
  Contract contract = CLIMain.loadContract(basePath + "forRoleAnonymizing_anonymized.unicon", true);
  assertFalse(contract.getOwner().getKeys().contains(ownerKey.getPublicKey()));
  assertFalse(contract.getIssuer().getKeys().contains(key.getPublicKey()));
  assertFalse(contract.getCreator().getKeys().contains(key.getPublicKey()));
  Contract anonPublishedContract = new Contract(contract.getLastSealedBinary());
  assertFalse(anonPublishedContract.getOwner().getKeys().contains(ownerKey.getPublicKey()));
  assertFalse(anonPublishedContract.getIssuer().getKeys().contains(key.getPublicKey()));
  assertFalse(anonPublishedContract.getCreator().getKeys().contains(key.getPublicKey()));
  assertFalse(anonPublishedContract.getSealedByKeys().contains(key.getPublicKey()));
  assertFalse(anonPublishedContract.getSealedByKeys().contains(ownerKey.getPublicKey()));
}
origin: UniversaBlockchain/universa

assertFalse(contract1.getCreator().getKeys().contains(key.getPublicKey()));
Contract anonPublishedContract1 = new Contract(contract1.getLastSealedBinary());
assertFalse(contract2.getCreator().getKeys().contains(key.getPublicKey()));
Contract anonPublishedContract2 = new Contract(contract2.getLastSealedBinary());
origin: UniversaBlockchain/universa

delorean.seal();
byte[] firstSeal = delorean.getLastSealedBinary();
System.out.println("--delorean 1--");
System.out.println(delorean.getRevoking().size());
System.out.println(delorean2.getRevoking().size());
byte[] secondSeal = delorean2.getLastSealedBinary();
Binder data1 = Boss.unpack(firstSeal);
byte[] contractBytes1 = data1.getBinaryOrThrow("data");
origin: UniversaBlockchain/universa

assertTrue(afterSend.getOwner().isAllowedForKeys(martyPublicKeys));
Contract anonPublishedContract = new Contract(anonSignedContract.getLastSealedBinary());
ItemResult itemResult = node.waitItem(anonPublishedContract.getId(), 8000);
assertEquals(ItemState.APPROVED, itemResult.state);
origin: UniversaBlockchain/universa

assertTrue(afterSend.getOwner().isAllowedForKeys(martyPublicKeys));
Contract anonPublishedContract = new Contract(anonSignedContract.getLastSealedBinary());
ItemResult itemResult = node.waitItem(anonPublishedContract.getId(), 8000);
assertEquals(ItemState.APPROVED, itemResult.state);
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

Contract c1copy = new Contract(c1.getLastSealedBinary());
origin: UniversaBlockchain/universa

assertTrue(afterSend.getOwner().isAllowedForKeys(martyPublicKeys));
Contract anonPublishedContract = new Contract(anonSignedContract.getLastSealedBinary());
ItemResult itemResult = node.waitItem(anonPublishedContract.getId(), 8000);
assertEquals(ItemState.APPROVED, itemResult.state);
origin: UniversaBlockchain/universa

assertTrue(afterSend.getOwner().isAllowedForKeys(martyPublicKeys));
Contract anonPublishedContract = new Contract(anonSignedContract.getLastSealedBinary());
ItemResult itemResult = node.waitItem(anonPublishedContract.getId(), 8000);
assertEquals(ItemState.APPROVED, itemResult.state);
origin: UniversaBlockchain/universa

private Binder getBody(Binder params, Session session) throws IOException {
  checkNode(session, true);
  Binder res = new Binder();
  if (!node.getConfig().isPermanetMode())
    return res;
  HashId itemId = (HashId) params.get("itemId");
  byte[] body = node.getLedger().getKeepingItem(itemId);
  if (body != null) {
    res.put("packedContract", body);
    return res;
  }
  node.resync(itemId);
  ItemResult itemResult = node.checkItem(itemId);
  if (itemResult == ItemResult.UNDEFINED)
    return res;
  Approvable item = node.getKeepingItemFromNetwork(itemId);
  if (item == null)
    return res;
  if ((item instanceof Contract) &&
    (item.getId().equals(itemId)) &&
    (HashId.of(((Contract) item).getLastSealedBinary()).equals(itemId))) {
    StateRecord record = node.getLedger().getRecord(itemId);
    node.getLedger().putKeepingItem(record, item);
    body = ((Contract) item).getPackedTransaction();
    res.put("packedContract", body);
  }
  return res;
}
com.icodici.universa.contractContractgetLastSealedBinary

Javadoc

Get the last knwon packed representation pf the contract. Should be called if the contract was contructed from a packed binary ( #Contract(byte[]) or was explicitly sealed #seal().

Caution. This method could return out of date binary, if the contract was changed after the #seal() call. Before we will add track of changes, use it only if you are sure that #seal() was called and contract was not changed since then.

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,
  • getNew,
  • getNewItems

Popular in Java

  • Reading from database using SQL prepared statement
  • getExternalFilesDir (Context)
  • compareTo (BigDecimal)
  • getResourceAsStream (ClassLoader)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • 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