org.spongycastle.util.encoders.Hex Java Examples

The following examples show how to use org.spongycastle.util.encoders.Hex. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PublicMethedForMutiSign.java    From gsc-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
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);
  }
 
Example #2
Source File: TrieTestWithRootHashValues.java    From aion with MIT License 6 votes vote down vote up
@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()));
}
 
Example #3
Source File: TrieTestWithRootHashValues.java    From aion with MIT License 6 votes vote down vote up
@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()));
}
 
Example #4
Source File: WalletTestBlock002.java    From gsc-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #5
Source File: MainNetVoteOrFreezeOrCreate.java    From gsc-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #6
Source File: Pipeline.java    From SightRemote with GNU General Public License v3.0 6 votes vote down vote up
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();
}
 
Example #7
Source File: MemoryTest.java    From gsc-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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);
}
 
Example #8
Source File: ECKeyTest.java    From ethereumj with MIT License 6 votes vote down vote up
@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();
}
  }
 
Example #9
Source File: AccountsListWindow.java    From ethereumj with MIT License 6 votes vote down vote up
@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";
	}
}
 
Example #10
Source File: LocalJSONTestSuiteTest.java    From ethereumj with MIT License 6 votes vote down vote up
@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());
}
 
Example #11
Source File: VMTest.java    From ethereumj with MIT License 6 votes vote down vote up
@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());
}
 
Example #12
Source File: MemoryTest.java    From gsc-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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());
}
 
Example #13
Source File: RepositoryTest.java    From ethereumj with MIT License 6 votes vote down vote up
@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();
    }
}
 
Example #14
Source File: VMTest.java    From ethereumj with MIT License 6 votes vote down vote up
@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());
}
 
Example #15
Source File: UnfreezeAsset2Test.java    From gsc-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #16
Source File: RuntimeImpl.java    From gsc-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
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);
    }

}
 
Example #17
Source File: VMTest.java    From ethereumj with MIT License 6 votes vote down vote up
@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()));
}
 
Example #18
Source File: RepositoryImpl.java    From ethereumj with MIT License 6 votes vote down vote up
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;
    }
 
Example #19
Source File: Wallet.java    From ethereumj with MIT License 6 votes vote down vote up
/***********************************************************************
   *	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;
  }
 
Example #20
Source File: ParticipateAssetIssue2Test.java    From gsc-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #21
Source File: ProgramResultTest.java    From gsc-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
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);
}
 
Example #22
Source File: PrivKeyToPubKey.java    From gsc-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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());
}
 
Example #23
Source File: DecodeResult.java    From BlockchainWallet-Crypto with GNU General Public License v3.0 5 votes vote down vote up
private String asString(Object decoded) {
    if (decoded instanceof String) {
        return (String) decoded;
    } else if (decoded instanceof byte[]) {
        return Hex.toHexString((byte[]) decoded);
    } else if (decoded instanceof Object[]) {
        String result = "";
        for (Object item : (Object[]) decoded) {
            result += asString(item);
        }
        return result;
    }
    throw new RuntimeException("Not a valid type. Should not occur");
}
 
Example #24
Source File: EthereumNetworkManager.java    From guarda-android-wallets with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected RawTransactionResponse doInBackground(Void... params) {
    BigInteger nonce = getNonce();
    if (nonce == null) return null;
    RawTransaction rawTransaction;
    String blockNumber = getBlocNumber();
    if (TextUtils.isEmpty(contractData)) {
        rawTransaction = RawTransaction.createEtherTransaction(nonce, gasPrice, gasLimit, toAddress, value);
    } else {
        rawTransaction = RawTransaction.createTransaction(nonce, gasPrice, gasLimit, toAddress, new String(Hex.encode(contractData.getBytes())));
    }

    byte[] signedMessage;
    if (walletManager.getCredentials() != null && rawTransaction != null) {
        signedMessage = TransactionEncoder.signMessage(rawTransaction, walletManager.getCredentials());
    } else {
        return null;
    }

    String hexValue = Numeric.toHexString(signedMessage);
    EthSendTransaction ethSendTransaction = null;


        try {
            ethSendTransaction = web3jConnection.ethSendRawTransaction(hexValue).send();
        } catch (IOException e) {
            e.printStackTrace();
        }

    if (ethSendTransaction != null && ethSendTransaction.getTransactionHash() != null) {
        return new RawTransactionResponse(ethSendTransaction.getTransactionHash(),
                hexValue, blockNumber);
    } else {
        return null;
    }
}
 
Example #25
Source File: TransactionTrace.java    From gsc-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void check() throws ReceiptCheckErrException {
    if (!needVM()) {
        return;
    }
    if (Objects.isNull(trx.getContractRet())) {
        throw new ReceiptCheckErrException("null resultCode");
    }
    if (!trx.getContractRet().equals(receipt.getResult())) {
        logger.info(
                "this tx id: {}, the resultCode in received block: {}, the resultCode in self: {}",
                Hex.toHexString(trx.getTransactionId().getBytes()), trx.getContractRet(),
                receipt.getResult());
        throw new ReceiptCheckErrException("Different resultCode");
    }
}
 
Example #26
Source File: VMTest.java    From ethereumj with MIT License 5 votes vote down vote up
@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());
}
 
Example #27
Source File: VMTest.java    From ethereumj with MIT License 5 votes vote down vote up
@Test // SMOD OP
public void testSMOD_1() {
    VM vm = new VM();
    program =  new Program(Hex.decode("6003600407"), invoke);
    String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000001";

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

    DataWord item1 = program.stackPop();
    assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase());
}
 
Example #28
Source File: DecodeResult.java    From ethereumj with MIT License 5 votes vote down vote up
private String asString(Object decoded) {
	if(decoded instanceof String) {
		return (String) decoded;
	} else if (decoded instanceof byte[]) {
		return Hex.toHexString((byte[]) decoded);
	} else if (decoded instanceof Object[]) {
		String result = "";
		for (Object item : (Object[]) decoded) {
			result += asString(item);
		}
		return result;
	} 
	throw new RuntimeException("Not a valid type. Should not occur");
}
 
Example #29
Source File: EthTransaction.java    From BlockchainWallet-Crypto with GNU General Public License v3.0 5 votes vote down vote up
public static EthTransaction create(String to, BigInteger amount, BigInteger nonce,
                                    BigInteger gasPrice,
                                    BigInteger gasLimit, Integer chainId) {
    return new EthTransaction(BigIntegers.asUnsignedByteArray(nonce),
            BigIntegers.asUnsignedByteArray(gasPrice),
            BigIntegers.asUnsignedByteArray(gasLimit),
            Hex.decode(to),
            BigIntegers.asUnsignedByteArray(amount),
            null,
            chainId);
}
 
Example #30
Source File: VMTest.java    From ethereumj with MIT License 5 votes vote down vote up
@Test  // PUSH3 OP
public void testPUSH3() {

    VM vm = new VM();
    program = new Program(Hex.decode("62A0B0C0"), invoke);
    String expected = "0000000000000000000000000000000000000000000000000000000000A0B0C0";

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

    assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()  );
}