public BlockHeader(JsonObject jsonObject) { this.chain = Hex.decode(jsonObject.get("chain").getAsString()); this.version = Hex.decode(jsonObject.get("version").getAsString()); this.type = Hex.decode(jsonObject.get("type").getAsString()); this.prevBlockHash = Hex.decode(jsonObject.get("prevBlockHash").getAsString()); this.index = HexUtil.hexStringToLong(jsonObject.get("index").getAsString()); this.timestamp = HexUtil.hexStringToLong(jsonObject.get("timestamp").getAsString()); this.merkleRoot = Hex.decode(jsonObject.get("merkleRoot").getAsString()); this.bodyLength = HexUtil.hexStringToLong(jsonObject.get("bodyLength").getAsString()); }
public TransactionHeader(JsonObject jsonObject) { this.chain = Hex.decode(jsonObject.get("chain").getAsString()); this.version = Hex.decode(jsonObject.get("version").getAsString()); this.type = Hex.decode(jsonObject.get("type").getAsString()); this.timestamp = HexUtil.hexStringToLong(jsonObject.get("timestamp").getAsString()); this.bodyHash = Hex.decode(jsonObject.get("bodyHash").getAsString()); this.bodyLength = HexUtil.hexStringToLong(jsonObject.get("bodyLength").getAsString()); }
protected Branch(JsonObject json) { this.json = json; this.branchId = BranchId.of(json); this.name = json.get("name").getAsString(); this.symbol = json.get("symbol").getAsString(); this.property = json.get("property").getAsString(); String timestampHex = json.get("timestamp").getAsString(); this.timestamp = HexUtil.hexStringToLong(timestampHex); this.rawForSign = rawHashForSign(); this.signature = Sha3Hash.createByHashed(Hex.decode(json.get("signature").getAsString())); this.owner = Address.of(json.get("owner").getAsString()); this.contractId = ContractId.of(json.get("contractId").getAsString()); this.description = json.get("description").getAsString(); }
long bodyLength = HexUtil.hexStringToLong(header.get("bodyLength").getAsString()); long timestamp = HexUtil.hexStringToLong(header.get("timestamp").getAsString()); if (timestamp < System.currentTimeMillis() - (COMMAND_ACTIVE_TIME)) { log.error("Timestamp is not valid.");
long bodyLength = HexUtil.hexStringToLong(header.get("bodyLength").getAsString()); long timestamp = HexUtil.hexStringToLong(header.get("timestamp").getAsString()); if (timestamp < System.currentTimeMillis() - (COMMAND_ACTIVE_TIME)) { log.error("Timestamp is not valid.");
@Test public void defaultTest() { String name = "STEM"; String symbol = "STEM"; String property = "ecosystem"; String description = "The Basis of the YGGDRASH Ecosystem. " + "It is also an aggregate and a blockchain containing information " + "of all Branch Chains."; String contractId = "d399cd6d34288d04ba9e68ddfda9f5fe99dd778e"; String timestamp = "00000166c837f0c9"; JsonObject genesis = new JsonObject(); JsonObject json = ContractTestUtils.createBranchJson(name, symbol, property, description, contractId, timestamp, genesis); Branch branch = Branch.of(json); assertThat(branch.getName()).isEqualTo(name); assertThat(branch.getSymbol()).isEqualTo(symbol); assertThat(branch.getProperty()).isEqualTo(property); assertThat(branch.getDescription()).isEqualTo(description); assertThat(branch.getContractId().toString()).isEqualTo(contractId); assertThat(branch.getTimestamp()) .isEqualTo(HexUtil.hexStringToLong(timestamp)); assertThat(branch.getOwner().toString()).isEqualTo(TestConstants.wallet().getHexAddress()); assertThat(branch.verify()).isTrue(); }