当前位置: 首页>>代码示例>>Java>>正文


Java TransactionsMessage类代码示例

本文整理汇总了Java中org.ethereum.net.eth.message.TransactionsMessage的典型用法代码示例。如果您正苦于以下问题:Java TransactionsMessage类的具体用法?Java TransactionsMessage怎么用?Java TransactionsMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TransactionsMessage类属于org.ethereum.net.eth.message包,在下文中一共展示了TransactionsMessage类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test_1

import org.ethereum.net.eth.message.TransactionsMessage; //导入依赖的package包/类
@Ignore
@Test  /* Transactions message 1 */
public void test_1() {

    String txsPacketRaw = "f86e12f86b04648609184e72a00094cd2a3d9f938e13cd947ec05abc7fe734df8dd826"
            + "881bc16d674ec80000801ba05c89ebf2b77eeab88251e553f6f9d53badc1d800"
            + "bbac02d830801c2aa94a4c9fa00b7907532b1f29c79942b75fff98822293bf5f"
            + "daa3653a8d9f424c6a3265f06c";

    byte[] payload = Hex.decode(txsPacketRaw);

    TransactionsMessage transactionsMessage = new TransactionsMessage(ConfigHelper.CONFIG, payload);
    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", tx.getReceiveAddress().toString());
    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()));
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:32,代码来源:TransactionsMessageTest.java

示例2: test_1

import org.ethereum.net.eth.message.TransactionsMessage; //导入依赖的package包/类
@Ignore
@Test  /* Transactions message 1 */
public void test_1() {

    String txsPacketRaw = "f86e12f86b04648609184e72a00094cd2a3d9f938e13cd947ec05abc7fe734df8dd826"
            + "881bc16d674ec80000801ba05c89ebf2b77eeab88251e553f6f9d53badc1d800"
            + "bbac02d830801c2aa94a4c9fa00b7907532b1f29c79942b75fff98822293bf5f"
            + "daa3653a8d9f424c6a3265f06c";

    byte[] payload = Hex.decode(txsPacketRaw);

    TransactionsMessage transactionsMessage = new TransactionsMessage(payload);
    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()));
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:32,代码来源:TransactionsMessageTest.java

示例3: sendTransaction

import org.ethereum.net.eth.message.TransactionsMessage; //导入依赖的package包/类
@Override
public void sendTransaction(List<Transaction> txs) {
    TransactionsMessage msg = new TransactionsMessage(config, txs);
    sendMessage(msg);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:6,代码来源:RskWireProtocol.java

示例4: sendTransaction

import org.ethereum.net.eth.message.TransactionsMessage; //导入依赖的package包/类
/**
 * submit transaction to the network
 *
 * @param tx - fresh transaction object
 */
public void sendTransaction(Transaction tx) {

    TransactionsMessage msg = new TransactionsMessage(config, tx);
    msgQueue.sendMessage(msg);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:11,代码来源:P2pHandler.java

示例5: createEthMessage

import org.ethereum.net.eth.message.TransactionsMessage; //导入依赖的package包/类
public static Message createEthMessage() {
    Account acc1 = new AccountBuilder().name("acc1").build();
    Account acc2 = new AccountBuilder().name("acc2").build();
    Transaction tx = new co.rsk.test.builders.TransactionBuilder().sender(acc1).receiver(acc2).value(BigInteger.valueOf(1000000)).build();
    return new TransactionsMessage(ConfigHelper.CONFIG, tx);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:7,代码来源:WriterMessageRecorderTest.java

示例6: test_3

import org.ethereum.net.eth.message.TransactionsMessage; //导入依赖的package包/类
@Test /* Transactions msg encode */
public void test_3() throws Exception {

    String expected =
            "f872f870808609184e72a0008242559479b08ad8787060333663d19704909ee7b1903e588b00d3c21bcecceda1000000801ca07c3f47d609d453737ddcf7c403190f67432c41e1f26051296b24e4e10a837083a0375fdb6d3b82dae7e1e78aa7d7413d0bfefeb05341058361d2b5a53d9c8783d6";

    BigInteger value = new BigInteger("1000000000000000000000000");

    byte[] privKey = HashUtil.sha3("cat".getBytes());
    ECKey ecKey = ECKey.fromPrivate(privKey);

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

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

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

    TransactionsMessage transactionsMessage = new TransactionsMessage(ConfigHelper.CONFIG, Collections.singletonList(tx));

    assertEquals(expected, Hex.toHexString(transactionsMessage.getEncoded()));
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:25,代码来源:TransactionsMessageTest.java

示例7: test_4

import org.ethereum.net.eth.message.TransactionsMessage; //导入依赖的package包/类
@Test
public void test_4() {
    String msg = "f872f87083011a6d850ba43b740083015f9094ec210ec3715d5918b37cfa4d344a45d177ed849f881b461c1416b9d000801ba023a3035235ca0a6f80f08a1d4bd760445d5b0f8a25c32678fe18a451a88d6377a0765dde224118bdb40a67f315583d542d93d17d8637302b1da26e1013518d3ae8";
    TransactionsMessage tmsg = new TransactionsMessage(ConfigHelper.CONFIG, Hex.decode(msg));
    assertEquals(1, tmsg.getTransactions().size());
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:7,代码来源:TransactionsMessageTest.java

示例8: sendTransaction

import org.ethereum.net.eth.message.TransactionsMessage; //导入依赖的package包/类
/**
 * submit transaction to the network
 *
 * @param tx - fresh transaction object
 */
public void sendTransaction(Transaction tx) {

    TransactionsMessage msg = new TransactionsMessage(tx);
    msgQueue.sendMessage(msg);
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:11,代码来源:P2pHandler.java

示例9: test_3

import org.ethereum.net.eth.message.TransactionsMessage; //导入依赖的package包/类
@Test /* Transactions msg encode */
public void test_3() throws Exception {

    String expected =
            "f872f870808b00d3c21bcecceda10000009479b08ad8787060333663d19704909ee7b1903e588609184e72a000824255801ca00f410a70e42b2c9854a8421d32c87c370a2b9fff0a27f9f031bb4443681d73b5a018a7dc4c4f9dee9f3dc35cb96ca15859aa27e219a8e4a8547be6bd3206979858";

    BigInteger value = new BigInteger("1000000000000000000000000");

    byte[] privKey = HashUtil.sha3("cat".getBytes());
    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();

    TransactionsMessage transactionsMessage = new TransactionsMessage(Collections.singletonList(tx));

    assertEquals(expected, Hex.toHexString(transactionsMessage.getEncoded()));
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:25,代码来源:TransactionsMessageTest.java

示例10: test_4

import org.ethereum.net.eth.message.TransactionsMessage; //导入依赖的package包/类
@Test
public void test_4() {
    String msg = "f872f87083011a6d850ba43b740083015f9094ec210ec3715d5918b37cfa4d344a45d177ed849f881b461c1416b9d000801ba023a3035235ca0a6f80f08a1d4bd760445d5b0f8a25c32678fe18a451a88d6377a0765dde224118bdb40a67f315583d542d93d17d8637302b1da26e1013518d3ae8";
    TransactionsMessage tmsg = new TransactionsMessage(Hex.decode(msg));
    assertEquals(1, tmsg.getTransactions().size());
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:7,代码来源:TransactionsMessageTest.java


注:本文中的org.ethereum.net.eth.message.TransactionsMessage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。