javax.swing.plaf.ComboBoxUI#org.spongycastle.util.encoders.Hex源码实例Demo

下面列出了javax.swing.plaf.ComboBoxUI#org.spongycastle.util.encoders.Hex 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: gsc-core   文件: ProgramResultTest.java

private byte[] deployCalledContractAndGetItsAddress()
    throws ContractExeException, ReceiptCheckErrException, ContractValidateException, VMIllegalException {
  String contractName = "calledContract";
  byte[] address = Hex.decode(OWNER_ADDRESS);
  String ABI =
      "[{\"constant\":false,\"inputs\":[],\"name\":\"getZero\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],"
          + "\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]";
  String code =
      "6080604052348015600f57600080fd5b5060988061001e6000396000f300608060405260043610603e5763ffffffff7c01"
          + "000000000000000000000000000000000000000000000000000000006000350416639f3f89dc81146043575b600080fd5b34801560"
          + "4e57600080fd5b5060556067565b60408051918252519081900360200190f35b6000905600a165627a7a72305820fa4124f68cd4c9"
          + "2df5362cb343d4831acd8ed666b72eb497974cdf511ae642a90029";
  long value = 0;
  long feeLimit = 1000000000;
  long consumeUserResourcePercent = 0;

  return GVMTestUtils
      .deployContractWholeProcessReturnContractAddress(contractName, address, ABI, code, value,
          feeLimit, consumeUserResourcePercent, null,
          deposit, null);
}
 
源代码2 项目: gsc-core   文件: WalletTestBlock002.java

/**
 * constructor.
 */

public Account queryAccount(String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) {
  byte[] address;
  ECKey temKey = null;
  try {
    BigInteger priK = new BigInteger(priKey, 16);
    temKey = ECKey.fromPrivate(priK);
  } catch (Exception ex) {
    ex.printStackTrace();
  }
  ECKey ecKey = temKey;
  if (ecKey == null) {
    String pubKey = loadPubKey(); //04 PubKey[128]
    if (StringUtils.isEmpty(pubKey)) {
      logger.warn("Warning: QueryAccount failed, no wallet address !!");
      return null;
    }
    byte[] pubKeyAsc = pubKey.getBytes();
    byte[] pubKeyHex = Hex.decode(pubKeyAsc);
    ecKey = ECKey.fromPublicOnly(pubKeyHex);
  }
  return grpcQueryAccount(ecKey.getAddress(), blockingStubFull);
}
 
源代码3 项目: aion   文件: TrieTestWithRootHashValues.java

@Test
public void testDeleteLongString2() {
    String ROOT_HASH_BEFORE =
            "e020de34ca26f8d373ff2c0a8ac3a4cb9032bfa7a194c68330b7ac3584a1d388";
    String ROOT_HASH_AFTER = "334511f0c4897677b782d13a6fa1e58e18de6b24879d57ced430bad5ac831cb2";
    TrieImpl trie = new TrieImpl(mockDb);

    trie.update(ca, LONG_STRING);
    assertEquals(LONG_STRING, new String(trie.get(ca)));

    trie.update(cat, LONG_STRING);
    assertEquals(LONG_STRING, new String(trie.get(cat)));
    assertEquals(ROOT_HASH_BEFORE, Hex.toHexString(trie.getRootHash()));

    trie.delete(cat);
    assertEquals("", new String(trie.get(cat)));
    assertEquals(ROOT_HASH_AFTER, Hex.toHexString(trie.getRootHash()));
}
 
源代码4 项目: aion   文件: TrieTestWithRootHashValues.java

@Test
public void testDeleteShortString1() {
    String ROOT_HASH_BEFORE =
            "a9539c810cc2e8fa20785bdd78ec36cc1dab4b41f0d531e80a5e5fd25c3037ee";
    String ROOT_HASH_AFTER = "fc5120b4a711bca1f5bb54769525b11b3fb9a8d6ac0b8bf08cbb248770521758";
    TrieImpl trie = new TrieImpl(mockDb);

    trie.update(cat, dog);
    assertEquals(dog, new String(trie.get(cat)));

    trie.update(ca, dude);
    assertEquals(dude, new String(trie.get(ca)));
    assertEquals(ROOT_HASH_BEFORE, Hex.toHexString(trie.getRootHash()));

    trie.delete(ca);
    assertEquals("", new String(trie.get(ca)));
    assertEquals(ROOT_HASH_AFTER, Hex.toHexString(trie.getRootHash()));
}
 

/**
 * constructor.
 */

public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) {
  byte[] address;
  if (ecKey == null) {
    String pubKey = loadPubKey(); //04 PubKey[128]
    if (StringUtils.isEmpty(pubKey)) {
      logger.warn("Warning: QueryAccount failed, no wallet address !!");
      return null;
    }
    byte[] pubKeyAsc = pubKey.getBytes();
    byte[] pubKeyHex = Hex.decode(pubKeyAsc);
    ecKey = ECKey.fromPublicOnly(pubKeyHex);
  }
  return grpcQueryAccount(ecKey.getAddress(), blockingStubFull);
}
 
源代码6 项目: SightRemote   文件: Pipeline.java

public Pipeline(DataStorage dataStorage, StatusCallback statusCallback) {
    this.dataStorage = dataStorage;
    this.statusCallback = statusCallback;
    if (dataStorage.contains("INCOMINGKEY") && dataStorage.contains("OUTGOINGKEY")) {
        derivedKeys = new DerivedKeys();
        derivedKeys.setIncomingKey(Hex.decode(dataStorage.get("INCOMINGKEY")));
        derivedKeys.setOutgoingKey(Hex.decode(dataStorage.get("OUTGOINGKEY")));
    }
    if (dataStorage.contains("COMMID"))
        commID = Long.parseLong(dataStorage.get("COMMID"));
    if (dataStorage.contains("LASTNONCESENT"))
        lastNonceSent = new BigInteger(Hex.decode(dataStorage.get("LASTNONCESENT")));
    if (dataStorage.contains("LASTNONCERECEIVED"))
        lastNonceReceived = new BigInteger(Hex.decode(dataStorage.get("LASTNONCERECEIVED")));
    setupPipeline();
}
 
源代码7 项目: gsc-core   文件: MemoryTest.java

@Test
public void memorySave_3() {

  Memory memoryBuffer = new Memory();
  byte[] data = Hex.decode("010101010101010101010101010101010101010101010101010101010101010101");

  memoryBuffer.write(0, data, data.length, false);

  assertTrue(1 == memoryBuffer.getChunks().size());

  byte[] chunk = memoryBuffer.getChunks().get(0);
  assertTrue(chunk[0] == 1);
  assertTrue(chunk[1] == 1);

  assertTrue(chunk[30] == 1);
  assertTrue(chunk[31] == 1);
  assertTrue(chunk[32] == 1);
  assertTrue(chunk[33] == 0);

  assertTrue(memoryBuffer.size() == 64);
}
 
源代码8 项目: ethereumj   文件: ECKeyTest.java

@Test
  public void testVerifySignature2() {
      BigInteger r = new BigInteger("c52c114d4f5a3ba904a9b3036e5e118fe0dbb987fe3955da20f2cd8f6c21ab9c", 16);
      BigInteger s = new BigInteger("6ba4c2874299a55ad947dbc98a25ee895aabf6b625c26c435e84bfd70edf2f69", 16);
      ECDSASignature sig = ECDSASignature.fromComponents(r.toByteArray(), s.toByteArray(), (byte) 0x1b);
      byte[] rawtx = Hex.decode("f82804881bc16d674ec8000094cd2a3d9f938e13cd947ec05abc7fe734df8dd8268609184e72a0006480");
try {
	ECKey key = ECKey.signatureToKey(HashUtil.sha3(rawtx), sig.toBase64());
	System.out.println("Signature public key\t: " + Hex.toHexString(key.getPubKey()));
	System.out.println("Sender is\t\t: " + Hex.toHexString(key.getAddress()));
	assertEquals("cd2a3d9f938e13cd947ec05abc7fe734df8dd826", Hex.toHexString(key.getAddress()));
	key.verify(HashUtil.sha3(rawtx), sig);
} catch (SignatureException e) {
	fail();
}
  }
 
源代码9 项目: ethereumj   文件: AccountsListWindow.java

@Override
public Object getValueAt(int rowIndex, int columnIndex) {
	if(columnIndex == 0) {
		return Hex.toHexString(data.get(rowIndex).address);
	}
	else if(columnIndex == 1 ){
		if(data.get(rowIndex).accountState != null) {
			return Denomination.toFriendlyString(data.get(rowIndex).accountState.getBalance());
		}
		return "---";
	}
	else {
		if(data.get(rowIndex).accountState != null) {
			if(!Arrays.areEqual(data.get(rowIndex).accountState.getCodeHash(), HashUtil.EMPTY_DATA_HASH))
				return "Yes";
		}
		return "No";
	}
}
 
源代码10 项目: ethereumj   文件: LocalJSONTestSuiteTest.java

@Test // CallCreate parsing  //
public void test4() throws ParseException {

    String expectedData         =   "";
    String expectedDestination =   "cd1722f3947def4cf144679da39c4c32bdc35681";
    String expectedGasLimit    =   "9792";
    String expectedValue       =   "74";

    JSONParser parser = new JSONParser();
    String callCreateString = "{'data' : '','destination' : 'cd1722f3947def4cf144679da39c4c32bdc35681','gasLimit' : 9792,'value' : 74}";
    callCreateString = callCreateString.replace("'", "\"");

    JSONObject callCreateJSONObj = (JSONObject)parser.parse(callCreateString);

    CallCreate callCreate = new CallCreate(callCreateJSONObj);

    Assert.assertEquals(expectedData,         Hex.toHexString(callCreate.getData()));
    Assert.assertEquals(expectedDestination,  Hex.toHexString(callCreate.getDestination()));
    Assert.assertEquals(expectedGasLimit,     new BigInteger( callCreate.getGasLimit()).toString());
    Assert.assertEquals(expectedValue,        new BigInteger( callCreate.getValue()).toString());
}
 
源代码11 项目: ethereumj   文件: VMTest.java

@Test // SSTORE OP
public void testSSTORE_2() {

    VM vm = new VM();

    program =  new Program(Hex.decode("602260AA57602260BB57"), invoke);
    String s_expected_key = "00000000000000000000000000000000000000000000000000000000000000BB";
    String s_expected_val = "0000000000000000000000000000000000000000000000000000000000000022";

    vm.step(program);
    vm.step(program);
    vm.step(program);
    vm.step(program);
    vm.step(program);
    vm.step(program);

    Repository repository = program.result.getRepository();
    DataWord key = new DataWord(Hex.decode(s_expected_key));
    DataWord val = repository.getStorageValue(invoke.getOwnerAddress().getNoLeadZeroesData(),  key);

    assertEquals(s_expected_val, Hex.toHexString(val.getData()).toUpperCase());
}
 
源代码12 项目: ethereumj   文件: RepositoryImpl.java

public AccountState createAccount(byte[] addr) {

        logger.trace("createAccount: [{}]", Hex.toHexString(addr)) ;
    	this.validateAddress(addr);
    	    	
        // 1. Save AccountState
        AccountState state =  new AccountState();
        accountStateDB.update(addr, state.getEncoded());
        
        ContractDetails details = new ContractDetails();
        contractDetailsDB.put(addr, details.getEncoded());
        
        if (logger.isDebugEnabled())
            logger.debug("New account created: [{}]", Hex.toHexString(addr));

        return state;
    }
 
源代码13 项目: gsc-core   文件: MemoryTest.java

@Test
public void memoryChunk_2() {
  Memory memoryBuffer = new Memory();

  byte[] data1 = new byte[32];
  Arrays.fill(data1, (byte) 1);

  memoryBuffer.write(0, data1, data1.length, false);
  assertTrue(32 == memoryBuffer.size());

  byte[] data = memoryBuffer.read(0, 64);

  assertArrayEquals(
      Hex.decode("0101010101010101010101010101010101010101010101010101010101010101" +
          "0000000000000000000000000000000000000000000000000000000000000000"),
      data
  );

  Assert.assertEquals(64, memoryBuffer.size());
}
 
源代码14 项目: ethereumj   文件: RepositoryTest.java

@Test  // get/set code
public void test8() {

    byte[] addr = Hex.decode("cd2a3d9f938e13cd947ec05abc7fe734df8dd826");
    Repository repository = new RepositoryImpl();

    try {
        byte[] code0 = repository.getCode(addr);
        repository.createAccount(addr);
        byte[] code1 = repository.getCode(addr);
        AccountState accountState = repository.getAccountState(addr);
        assertTrue(code0 == null);
        assertNull(code1);
        assertNull(accountState.getCodeHash());
    } finally {
        repository.close();
    }
}
 
源代码15 项目: ethereumj   文件: VMTest.java

@Test // MLOAD OP
public void testMLOAD_4() {

    VM vm = new VM();
    program =  new Program(Hex.decode("611234602054602053"), invoke);
    String m_expected = "0000000000000000000000000000000000000000000000000000000000000000" +
                        "0000000000000000000000000000000000000000000000000000000000001234";
    String s_expected = "0000000000000000000000000000000000000000000000000000000000001234";

    vm.step(program);
    vm.step(program);
    vm.step(program);
    vm.step(program);
    vm.step(program);

    assertEquals(m_expected, Hex.toHexString(program.memory.array()));
    assertEquals(s_expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase());
}
 
源代码16 项目: gsc-core   文件: UnfreezeAsset2Test.java

/**
 * constructor.
 */

public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) {
  byte[] address;
  if (ecKey == null) {
    String pubKey = loadPubKey(); //04 PubKey[128]
    if (StringUtils.isEmpty(pubKey)) {
      logger.warn("Warning: QueryAccount failed, no wallet address !!");
      return null;
    }
    byte[] pubKeyAsc = pubKey.getBytes();
    byte[] pubKeyHex = Hex.decode(pubKeyAsc);
    ecKey = ECKey.fromPublicOnly(pubKeyHex);
  }
  return grpcQueryAccount(ecKey.getAddress(), blockingStubFull);
}
 
源代码17 项目: gsc-core   文件: RuntimeImpl.java

public void finalization() {
    if (StringUtils.isEmpty(runtimeError)) {
        for (DataWord contract : result.getDeleteAccounts()) {
            deposit.deleteContract(MUtil.convertToGSCAddress((contract.getLast20Bytes())));
        }
    }

    if (config.vmTrace() && program != null) {
        String traceContent = program.getTrace()
                .result(result.getHReturn())
                .error(result.getException())
                .toString();

        if (config.vmTraceCompressed()) {
            traceContent = VMUtils.zipAndEncode(traceContent);
        }

        String txHash = Hex.toHexString(rootInternalTransaction.getHash());
        VMUtils.saveProgramTraceFile(config, txHash, traceContent);
    }

}
 
源代码18 项目: ethereumj   文件: VMTest.java

@Test // MSTORE OP
public void testMSTORE_2() {

    VM vm = new VM();
    program =  new Program(Hex.decode("611234600054615566602054"), invoke);
    String expected = "0000000000000000000000000000000000000000000000000000000000001234" +
                      "0000000000000000000000000000000000000000000000000000000000005566";

    vm.step(program);
    vm.step(program);
    vm.step(program);
    vm.step(program);
    vm.step(program);
    vm.step(program);

    assertEquals(expected, Hex.toHexString(program.memory.array()));
}
 
源代码19 项目: ethereumj   文件: Wallet.java

/***********************************************************************
   *	1) the dialog put a pending transaction on the list
   *  2) the dialog send the transaction to a net
   *  3) wherever the transaction got in from the wire it will change to approve state
   *  4) only after the approve a) Wallet state changes
   *  5) After the block is received with that tx the pending been clean up
   */
  public WalletTransaction addTransaction(Transaction transaction) {
      String hash = Hex.toHexString(transaction.getHash());
      logger.info("pending transaction placed hash: {}", hash );

      WalletTransaction walletTransaction =  this.walletTransactions.get(hash);
if (walletTransaction != null)
	walletTransaction.incApproved();
else {
	walletTransaction = new WalletTransaction(transaction);
	this.walletTransactions.put(hash, walletTransaction);
}

      this.applyTransaction(transaction);

      return walletTransaction;
  }
 

/**
 * constructor.
 */

public Account queryAccount(String priKey, WalletGrpc.WalletBlockingStub blockingStubFull) {
  byte[] address;
  ECKey temKey = null;
  try {
    BigInteger priK = new BigInteger(priKey, 16);
    temKey = ECKey.fromPrivate(priK);
  } catch (Exception ex) {
    ex.printStackTrace();
  }
  ECKey ecKey = temKey;
  if (ecKey == null) {
    String pubKey = loadPubKey(); //04 PubKey[128]
    if (StringUtils.isEmpty(pubKey)) {
      logger.warn("Warning: QueryAccount failed, no wallet address !!");
      return null;
    }
    byte[] pubKeyAsc = pubKey.getBytes();
    byte[] pubKeyHex = Hex.decode(pubKeyAsc);
    ecKey = ECKey.fromPublicOnly(pubKeyHex);
  }
  return grpcQueryAccount(ecKey.getAddress(), blockingStubFull);
}
 
源代码21 项目: gsc-core   文件: PublicMethedForMutiSign.java

private static byte[] replaceLibraryAddress(String code, String libraryAddressPair) {

    String[] libraryAddressList = libraryAddressPair.split("[,]");

    for (int i = 0; i < libraryAddressList.length; i++) {
      String cur = libraryAddressList[i];

      int lastPosition = cur.lastIndexOf(":");
      if (-1 == lastPosition) {
        throw new RuntimeException("libraryAddress delimit by ':'");
      }
      String libraryName = cur.substring(0, lastPosition);
      String addr = cur.substring(lastPosition + 1);
      String libraryAddressHex = ByteArray.toHexString(Wallet.decodeFromBase58Check(addr))
          .substring(2);

      String repeated = new String(new char[40 - libraryName.length() - 2]).replace("\0", "_");
      String beReplaced = "__" + libraryName + repeated;
      Matcher m = Pattern.compile(beReplaced).matcher(code);
      code = m.replaceAll(libraryAddressHex);
    }

    return Hex.decode(code);
  }
 
源代码22 项目: ethereumj   文件: VMTest.java

@Test // ADD OP
public void testADD_2() {

    VM vm = new VM();
    program =  new Program(Hex.decode("611002600201"), invoke);
    String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000001004";

    vm.step(program);
    vm.step(program);
    vm.step(program);

    DataWord item1 = program.stackPop();
    assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase());
}
 
源代码23 项目: ethereumj   文件: VMTest.java

@Test // SUB OP
public void testSUB_3() {

    VM vm = new VM();
    program =  new Program(Hex.decode("614444639999666603"), invoke);
    String s_expected_1 = "0000000000000000000000000000000000000000000000000000000099992222";

    vm.step(program);
    vm.step(program);
    vm.step(program);

    DataWord item1 = program.stackPop();
    assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase());
}
 
源代码24 项目: asf-sdk   文件: DefaultGasLimitEstimator.java

@Override public BigInteger estimate(Address from, Address to, byte[] data)
    throws EstimateGasException {

  Transaction transaction =
      Transaction.createEthCallTransaction(from.toHexString(true), to.toHexString(true),
          Hex.toHexString(data));

  try {
    return web3j.ethEstimateGas(transaction)
        .send()
        .getAmountUsed();
  } catch (IOException e) {
    throw new EstimateGasException("Failed to estimate gas!", e);
  }
}
 
源代码25 项目: gsc-core   文件: PrivKeyToPubKey.java

@Test
public void listnode() {
    ManagedChannel channel = null;
    WalletGrpc.WalletBlockingStub blockingStub = null;

    channel = ManagedChannelBuilder.forTarget("39.105.202.12:5021").usePlaintext(true).build();
    blockingStub = WalletGrpc.newBlockingStub(channel);

    GrpcAPI.AssetIssueList block1 = blockingStub.getAssetIssueByAccount(Protocol.Account.newBuilder().build());
    Protocol.Transaction transaction = blockingStub.getTransactionById(GrpcAPI.BytesMessage.newBuilder().setValue(ByteString.copyFrom(Hex.decode(""))).build());
}
 
源代码26 项目: ethereumj   文件: VMTest.java

@Test // EXP OP
public void testEXP_1() {

    VM vm = new VM();
    program =  new Program(Hex.decode("6003600208"), invoke);
    String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000008";

    vm.step(program);
    vm.step(program);
    vm.step(program);

    DataWord item1 = program.stackPop();
    assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase());
}
 
源代码27 项目: ethereumj   文件: VMCustomTest.java

@Test(expected=StackTooSmallException.class) // CALLDATACOPY OP mal
public void testCALLDATACOPY_6() {

    VM vm = new VM();
    program = 
            new Program(Hex.decode("6040600037"), invoke);

    try {
        vm.step(program);
        vm.step(program);
        vm.step(program);
    } finally {
        assertTrue(program.isStopped());
    }
}
 
源代码28 项目: ethereumj   文件: VMTest.java

@Test // MOD OP
public void testMOD_3() {
    VM vm = new VM();
    program =  new Program(Hex.decode("6004600206"), invoke);
    String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000002";

    vm.step(program);
    vm.step(program);
    vm.step(program);

    DataWord item1 = program.stackPop();
    assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase());
}
 
源代码29 项目: ethereumj   文件: VMTest.java

@Test  // SGT OP
public void testSGT_1() {

    VM vm = new VM();
    program =  new Program(Hex.decode("600160020D"), invoke);
    String expected = "0000000000000000000000000000000000000000000000000000000000000001";

    vm.step(program);
    vm.step(program);
    vm.step(program);

    assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase());
}
 
源代码30 项目: gsc-core   文件: WalletTestAssetIssue009.java

public Account queryAccount(ECKey ecKey, WalletGrpc.WalletBlockingStub blockingStubFull) {
  byte[] address;
  if (ecKey == null) {
    String pubKey = loadPubKey(); //04 PubKey[128]
    if (StringUtils.isEmpty(pubKey)) {
      logger.warn("Warning: QueryAccount failed, no wallet address !!");
      return null;
    }
    byte[] pubKeyAsc = pubKey.getBytes();
    byte[] pubKeyHex = Hex.decode(pubKeyAsc);
    ecKey = ECKey.fromPublicOnly(pubKeyHex);
  }
  return grpcQueryAccount(ecKey.getAddress(), blockingStubFull);
}