Package org.ethereum.core

Examples of org.ethereum.core.Transaction


        byte[] nonceBytes    =  ByteUtil.bigIntegerToBytes(nonce);
        byte[] gasPriceBytes =  ByteUtil.bigIntegerToBytes(gasPrice);
        byte[] gasBytes      =  ByteUtil.bigIntegerToBytes(gas);
        byte[] valueBytes    =  ByteUtil.bigIntegerToBytes(value);

        Transaction tx = new Transaction(nonceBytes, gasPriceBytes, gasBytes,
                recieveAddress, valueBytes, data);

        return tx;
    }
View Full Code Here


        System.out.println(transactionsMessage);

        assertEquals(EthMessageCodes.TRANSACTIONS, transactionsMessage.getCommand());
        assertEquals(1, transactionsMessage.getTransactions().size());

    Transaction tx = transactionsMessage.getTransactions().iterator().next();

    assertEquals("5d2aee0490a9228024158433d650335116b4af5a30b8abb10e9b7f9f7e090fd8", Hex.toHexString(tx.getHash()));
    assertEquals("04", Hex.toHexString(tx.getNonce()));
    assertEquals("1bc16d674ec80000", Hex.toHexString(tx.getValue()));
    assertEquals("cd2a3d9f938e13cd947ec05abc7fe734df8dd826", Hex.toHexString(tx.getReceiveAddress()));
    assertEquals("64", Hex.toHexString(tx.getGasPrice()));
    assertEquals("09184e72a000", Hex.toHexString(tx.getGasLimit()));
    assertEquals("", ByteUtil.toHexString(tx.getData()));

    assertEquals("1b", Hex.toHexString(new byte[] { tx.getSignature().v }));
    assertEquals("5c89ebf2b77eeab88251e553f6f9d53badc1d800bbac02d830801c2aa94a4c9f", Hex.toHexString(tx.getSignature().r.toByteArray()));
    assertEquals("0b7907532b1f29c79942b75fff98822293bf5fdaa3653a8d9f424c6a3265f06c", Hex.toHexString(tx.getSignature().s.toByteArray()));
    }
View Full Code Here

        assertEquals(EthMessageCodes.TRANSACTIONS, transactionsMessage.getCommand());
       
        assertEquals(3, transactionsMessage.getTransactions().size());

        Iterator<Transaction> txIter = transactionsMessage.getTransactions().iterator();
        Transaction tx1 = txIter.next(); txIter.next(); // skip one
        Transaction tx3 = txIter.next();
       
        assertEquals("1b9d9456293cbcbc2f28a0fdc67028128ea571b033fb0e21d0ee00bcd6167e5d",
            Hex.toHexString(tx3.getHash()));

        assertEquals("00",
            Hex.toHexString(tx3.getNonce()));

        assertEquals("2710",
            Hex.toHexString(tx3.getValue()));

        assertEquals("09184e72a000",
            Hex.toHexString(tx3.getReceiveAddress()));

        assertNull(tx3.getGasPrice());

        assertEquals("0000000000000000000000000000000000000000",
            Hex.toHexString(tx3.getGasLimit()));

        assertEquals("606956330c0d630000003359366000530a0d630000003359602060005301356000533557604060005301600054630000000c58",
            Hex.toHexString(tx3.getData()));

        assertEquals("33",
            Hex.toHexString(new byte[] {tx3.getSignature().v}));

        assertEquals("1c",
            Hex.toHexString(tx3.getSignature().r.toByteArray()));

        assertEquals("7f6eb94576346488c6253197bde6a7e59ddc36f2773672c849402aa9c402c3c4",
            Hex.toHexString(tx3.getSignature().s.toByteArray()));

        // Transaction #2
       
        assertEquals("dde9543921850f41ca88e5401322cd7651c78a1e4deebd5ee385af8ac343f0ad",
            Hex.toHexString(tx1.getHash()));
View Full Code Here

        ECKey ecKey = ECKey.fromPrivate(privKey);

        byte[] gasPrice=  Hex.decode("09184e72a000");
        byte[] gas =      Hex.decode("4255");

        Transaction tx = new Transaction(null, value.toByteArray(),
                ecKey.getAddress(),  gasPrice, gas, null);

        tx.sign(privKey);
        tx.getEncoded();

        Set<Transaction> txs = new HashSet<>(Arrays.asList(tx));
        TransactionsMessage transactionsMessage = new TransactionsMessage(txs);

        assertEquals(EthMessageCodes.TRANSACTIONS, transactionsMessage.getCommand());
View Full Code Here

        if (programCode == null || programCode.length == 0) {
            alertStatusMsg("Such account exist but no code in the db");
            return;
        }

        Transaction tx = createTransaction();
        if (tx == null) return;

        Block lastBlock = UIEthereumManager.ethereum.getBlockchain().getBestBlock();
        ProgramPlayDialog.createAndShowGUI(programCode, tx, lastBlock);
    }
View Full Code Here

        if (!UIEthereumManager.ethereum.isConnected()) {
            dialog.alertStatusMsg("Not connected to any peer");
            return;
        }

        Transaction tx = createTransaction();
        if (tx == null) return;

        if (logger.isInfoEnabled()) {
            logger.info("tx.hash: {}", (new BigInteger(tx.getHash()).toString(16)));
        }
        // SwingWorker
        DialogWorker worker = new DialogWorker(tx, this);
        worker.execute();
    }
View Full Code Here

            logger.info("tx.address: {}", Hex.toHexString(contractAddress));
            logger.info("tx.endowment: {}", Hex.toHexString(BigIntegers.asUnsignedByteArray( endowment)));
            logger.info("tx.data: {}", Hex.toHexString(data));
        }

        Transaction tx = UIEthereumManager.ethereum.createTransaction(
                nonce,
                gasPrice, gasBI,
                contractAddress, endowment, data);

        try {
            tx.sign(senderPrivKey);
        } catch (Exception e1) {
            dialog.alertStatusMsg("Failed to sign the transaction");
            return null;
        }
        return tx;
View Full Code Here

                BigInteger nonce = account.getNonce();

                byte[] gasPrice = BigInteger.valueOf(UIEthereumManager.ethereum.getBlockchain().getGasPrice()).toByteArray();

        Transaction tx = new Transaction(
                        BigIntegers.asUnsignedByteArray(nonce),
                         gasPrice,
                        BigIntegers.asUnsignedByteArray(fee), address,
                        BigIntegers.asUnsignedByteArray(value), null);

        try {
          tx.sign(senderPrivKey);
        } catch (Exception e1) {
          dialog.alertStatusMsg("Failed to sign the transaction");
          return;
        }
View Full Code Here

  byte[] testData = Hex.decode("");
  byte[] testInit = Hex.decode("");
 
  @Test
  public void testTransactionFromSignedRLP() throws Exception {
      Transaction txSigned = new Transaction(Hex.decode(RLP_ENCODED_SIGNED_TX));
     
      assertEquals(HASH_TX, Hex.toHexString(txSigned.getHash()));
      assertEquals(RLP_ENCODED_SIGNED_TX, Hex.toHexString(txSigned.getEncoded()));
     
      assertEquals(BigInteger.ZERO, new BigInteger(1, txSigned.getNonce()));
      assertEquals(new BigInteger(1, testGasPrice), new BigInteger(1, txSigned.getGasPrice()));
      assertEquals(new BigInteger(1, testGasLimit), new BigInteger(1, txSigned.getGasLimit()));
      assertEquals(Hex.toHexString(testReceiveAddress), Hex.toHexString(txSigned.getReceiveAddress()));
      assertEquals(new BigInteger(1, testValue), new BigInteger(1, txSigned.getValue()));
      assertNull(txSigned.getData());
      assertEquals(27, txSigned.getSignature().v);
      assertEquals("eab47c1a49bf2fe5d40e01d313900e19ca485867d462fe06e139e3a536c6d4f4", Hex.toHexString(BigIntegers.asUnsignedByteArray(txSigned.getSignature().r)));
      assertEquals("14a569d327dcda4b29f74f93c0e9729d2f49ad726e703f9cd90dbb0fbf6649f1", Hex.toHexString(BigIntegers.asUnsignedByteArray(txSigned.getSignature().s)));
  }
View Full Code Here

      assertEquals("14a569d327dcda4b29f74f93c0e9729d2f49ad726e703f9cd90dbb0fbf6649f1", Hex.toHexString(BigIntegers.asUnsignedByteArray(txSigned.getSignature().s)));
  }
 
  @Test
  public void testTransactionFromUnsignedRLP() throws Exception {
      Transaction txUnsigned = new Transaction(Hex.decode(RLP_ENCODED_UNSIGNED_TX));
     
      assertEquals(HASH_TX, Hex.toHexString(txUnsigned.getHash()));
      assertEquals(RLP_ENCODED_UNSIGNED_TX, Hex.toHexString(txUnsigned.getEncoded()));
      txUnsigned.sign(Hex.decode(KEY));
      assertEquals(RLP_ENCODED_SIGNED_TX, Hex.toHexString(txUnsigned.getEncoded()));    
     
      assertEquals(BigInteger.ZERO, new BigInteger(1, txUnsigned.getNonce()));
      assertEquals(new BigInteger(1, testGasPrice), new BigInteger(1, txUnsigned.getGasPrice()));
      assertEquals(new BigInteger(1, testGasLimit), new BigInteger(1, txUnsigned.getGasLimit()));
      assertEquals(Hex.toHexString(testReceiveAddress), Hex.toHexString(txUnsigned.getReceiveAddress()));
      assertEquals(new BigInteger(1, testValue), new BigInteger(1, txUnsigned.getValue()));
      assertNull(txUnsigned.getData());
      assertEquals(27, txUnsigned.getSignature().v);
      assertEquals("eab47c1a49bf2fe5d40e01d313900e19ca485867d462fe06e139e3a536c6d4f4", Hex.toHexString(BigIntegers.asUnsignedByteArray(txUnsigned.getSignature().r)));
      assertEquals("14a569d327dcda4b29f74f93c0e9729d2f49ad726e703f9cd90dbb0fbf6649f1", Hex.toHexString(BigIntegers.asUnsignedByteArray(txUnsigned.getSignature().s)));
  }
View Full Code Here

TOP

Related Classes of org.ethereum.core.Transaction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.