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


Java Transaction类代码示例

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


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

示例1: onTransactionReceived

import org.web3j.protocol.core.methods.response.Transaction; //导入依赖的package包/类
public void onTransactionReceived(Transaction tx) {
    BigInteger wei = tx.getValue();
    BigDecimal ether = Convert.fromWei(new BigDecimal(tx.getValue()), Convert.Unit.ETHER);
    String to = tx.getTo();
    String hash = tx.getHash();
    String from = tx.getFrom();

    if (addressMap.containsKey(tx.getTo())) {
        // credito
        System.out.println("Se ha recibido su depósito de " + ether + " ether enviado a su cuenta " + to + " enviado por " + from + " tx " + hash);
    } else if (addressMap.containsKey(tx.getFrom())) {
        //debito
        System.out.println("Se ha hecho un retiro de " + ether + " ether desde su cuenta " + to + " hacia la cuenta destino " + from + " tx " + hash);
    }
}
 
开发者ID:jestevez,项目名称:ethereum-java-wallet,代码行数:16,代码来源:EthereumWallet.java

示例2: testEthGetTransactionByHash

import org.web3j.protocol.core.methods.response.Transaction; //导入依赖的package包/类
@Test
public void testEthGetTransactionByHash() throws Exception {
    EthTransaction ethTransaction = web3j.ethGetTransactionByHash(
            config.validTransactionHash()).send();
    assertTrue(ethTransaction.getTransaction().isPresent());
    Transaction transaction = ethTransaction.getTransaction().get();
    assertThat(transaction.getBlockHash(), is(config.validBlockHash()));
}
 
开发者ID:web3j,项目名称:web3j,代码行数:9,代码来源:CoreIT.java

示例3: testEthGetTransactionByBlockHashAndIndex

import org.web3j.protocol.core.methods.response.Transaction; //导入依赖的package包/类
@Test
public void testEthGetTransactionByBlockHashAndIndex() throws Exception {
    BigInteger index = BigInteger.ONE;

    EthTransaction ethTransaction = web3j.ethGetTransactionByBlockHashAndIndex(
            config.validBlockHash(), index).send();
    assertTrue(ethTransaction.getTransaction().isPresent());
    Transaction transaction = ethTransaction.getTransaction().get();
    assertThat(transaction.getBlockHash(), is(config.validBlockHash()));
    assertThat(transaction.getTransactionIndex(), equalTo(index));
}
 
开发者ID:web3j,项目名称:web3j,代码行数:12,代码来源:CoreIT.java

示例4: testEthGetTransactionByBlockNumberAndIndex

import org.web3j.protocol.core.methods.response.Transaction; //导入依赖的package包/类
@Test
public void testEthGetTransactionByBlockNumberAndIndex() throws Exception {
    BigInteger index = BigInteger.ONE;

    EthTransaction ethTransaction = web3j.ethGetTransactionByBlockNumberAndIndex(
            DefaultBlockParameter.valueOf(config.validBlock()), index).send();
    assertTrue(ethTransaction.getTransaction().isPresent());
    Transaction transaction = ethTransaction.getTransaction().get();
    assertThat(transaction.getBlockHash(), is(config.validBlockHash()));
    assertThat(transaction.getTransactionIndex(), equalTo(index));
}
 
开发者ID:web3j,项目名称:web3j,代码行数:12,代码来源:CoreIT.java

示例5: toTransactions

import org.web3j.protocol.core.methods.response.Transaction; //导入依赖的package包/类
private static List<Transaction> toTransactions(EthBlock ethBlock) {
    // If you ever see an exception thrown here, it's probably due to an incomplete chain in
    // Geth/Parity. You should resync to solve.
    return ethBlock.getBlock().getTransactions().stream()
            .map(transactionResult -> (Transaction) transactionResult.get())
            .collect(Collectors.toList());
}
 
开发者ID:web3j,项目名称:web3j,代码行数:8,代码来源:JsonRpc2_0Rx.java

示例6: testTransaction

import org.web3j.protocol.core.methods.response.Transaction; //导入依赖的package包/类
@Test
public void testTransaction() {
    EqualsVerifier.forClass(Transaction.class)
            .suppress(Warning.NONFINAL_FIELDS)
            .suppress(Warning.STRICT_INHERITANCE)
            .verify();
}
 
开发者ID:web3j,项目名称:web3j,代码行数:8,代码来源:EqualsVerifierResponseTest.java

示例7: transactionObservable

import org.web3j.protocol.core.methods.response.Transaction; //导入依赖的package包/类
private void transactionObservable(Transaction tx) {
    // Si es de mi monedero capturo el evento
    if (addressMap.containsKey(tx.getTo()) || addressMap.containsKey(tx.getFrom())) {
        onTransactionReceived(tx);
    }
}
 
开发者ID:jestevez,项目名称:ethereum-java-wallet,代码行数:7,代码来源:EthereumWallet.java

示例8: pendingTransactionObservable

import org.web3j.protocol.core.methods.response.Transaction; //导入依赖的package包/类
private void pendingTransactionObservable(Transaction tx) {
    // Si es de mi monedero capturo el evento
    if (addressMap.containsKey(tx.getTo()) || addressMap.containsKey(tx.getFrom())) {
        onTransactionReceived(tx);
    }
}
 
开发者ID:jestevez,项目名称:ethereum-java-wallet,代码行数:7,代码来源:EthereumWallet.java

示例9: transactionObservable

import org.web3j.protocol.core.methods.response.Transaction; //导入依赖的package包/类
public Observable<Transaction> transactionObservable(long pollingInterval) {
    return blockObservable(true, pollingInterval)
            .flatMapIterable(JsonRpc2_0Rx::toTransactions);
}
 
开发者ID:web3j,项目名称:web3j,代码行数:5,代码来源:JsonRpc2_0Rx.java

示例10: pendingTransactionObservable

import org.web3j.protocol.core.methods.response.Transaction; //导入依赖的package包/类
public Observable<Transaction> pendingTransactionObservable(long pollingInterval) {
    return ethPendingTransactionHashObservable(pollingInterval)
            .flatMap(transactionHash ->
                    web3j.ethGetTransactionByHash(transactionHash).observable())
            .map(ethTransaction -> ethTransaction.getTransaction().get());
}
 
开发者ID:web3j,项目名称:web3j,代码行数:7,代码来源:JsonRpc2_0Rx.java

示例11: replayTransactionsObservable

import org.web3j.protocol.core.methods.response.Transaction; //导入依赖的package包/类
public Observable<Transaction> replayTransactionsObservable(
        DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
    return replayBlocksObservable(startBlock, endBlock, true)
            .flatMapIterable(JsonRpc2_0Rx::toTransactions);
}
 
开发者ID:web3j,项目名称:web3j,代码行数:6,代码来源:JsonRpc2_0Rx.java

示例12: catchUpToLatestTransactionObservable

import org.web3j.protocol.core.methods.response.Transaction; //导入依赖的package包/类
public Observable<Transaction> catchUpToLatestTransactionObservable(
        DefaultBlockParameter startBlock) {
    return catchUpToLatestBlockObservable(
            startBlock, true, Observable.empty())
            .flatMapIterable(JsonRpc2_0Rx::toTransactions);
}
 
开发者ID:web3j,项目名称:web3j,代码行数:7,代码来源:JsonRpc2_0Rx.java

示例13: catchUpToLatestAndSubscribeToNewTransactionsObservable

import org.web3j.protocol.core.methods.response.Transaction; //导入依赖的package包/类
public Observable<Transaction> catchUpToLatestAndSubscribeToNewTransactionsObservable(
        DefaultBlockParameter startBlock, long pollingInterval) {
    return catchUpToLatestAndSubscribeToNewBlocksObservable(
            startBlock, true, pollingInterval)
            .flatMapIterable(JsonRpc2_0Rx::toTransactions);
}
 
开发者ID:web3j,项目名称:web3j,代码行数:7,代码来源:JsonRpc2_0Rx.java

示例14: testEthTransaction

import org.web3j.protocol.core.methods.response.Transaction; //导入依赖的package包/类
@Test
public void testEthTransaction() {
    //CHECKSTYLE:OFF
    buildResponse(
            "{\n"
                    + "    \"id\":1,\n"
                    + "    \"jsonrpc\":\"2.0\",\n"
                    + "    \"result\": {\n"
                    + "        \"hash\":\"0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b\",\n"
                    + "        \"nonce\":\"0x\",\n"
                    + "        \"blockHash\": \"0xbeab0aa2411b7ab17f30a99d3cb9c6ef2fc5426d6ad6fd9e2a26a6aed1d1055b\",\n"
                    + "        \"blockNumber\": \"0x15df\",\n"
                    + "        \"transactionIndex\":  \"0x1\",\n"
                    + "        \"from\":\"0x407d73d8a49eeb85d32cf465507dd71d507100c1\",\n"
                    + "        \"to\":\"0x85h43d8a49eeb85d32cf465507dd71d507100c1\",\n"
                    + "        \"value\":\"0x7f110\",\n"
                    + "        \"gas\": \"0x7f110\",\n"
                    + "        \"gasPrice\":\"0x09184e72a000\",\n"
                    + "        \"input\":\"0x603880600c6000396000f300603880600c6000396000f3603880600c6000396000f360\",\n"
                    + "        \"creates\":null,\n"
                    + "        \"publicKey\":\"0x6614d7d7bfe989295821985de0439e868b26ff05f98ae0da0ce5bccc24ea368a083b785323c9fcb405dd4c10a2c95d93312a1b2d68beb24ab4ea7c3c2f7c455b\",\n"
                    + "        \"raw\":\"0xf8cd83103a048504a817c800830e57e0945927c5cc723c4486f93bf90bad3be8831139499e80b864140f8dd300000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000c03905df347aa6490d5a98fbb8d8e49520000000000000000000000000000000000000000000000000000000057d56ee61ba0f115cc4d7516dd430046504e1c888198e0323e8ded016d755f89c226ba3481dca04a2ae8ee49f1100b5c0202b37ed8bacf4caeddebde6b7f77e12e7a55893e9f62\",\n"
                    + "        \"r\":\"0xf115cc4d7516dd430046504e1c888198e0323e8ded016d755f89c226ba3481dc\",\n"
                    + "        \"s\":\"0x4a2ae8ee49f1100b5c0202b37ed8bacf4caeddebde6b7f77e12e7a55893e9f62\",\n"
                    + "        \"v\":0\n"
                    + "  }\n"
                    + "}"
    );
    Transaction transaction = new Transaction(
            "0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b",
            "0x",
            "0xbeab0aa2411b7ab17f30a99d3cb9c6ef2fc5426d6ad6fd9e2a26a6aed1d1055b",
            "0x15df",
            "0x1",
            "0x407d73d8a49eeb85d32cf465507dd71d507100c1",
            "0x85h43d8a49eeb85d32cf465507dd71d507100c1",
            "0x7f110",
            "0x7f110",
            "0x09184e72a000",
            "0x603880600c6000396000f300603880600c6000396000f3603880600c6000396000f360",
            null,
            "0x6614d7d7bfe989295821985de0439e868b26ff05f98ae0da0ce5bccc24ea368a083b785323c9fcb405dd4c10a2c95d93312a1b2d68beb24ab4ea7c3c2f7c455b",
            "0xf8cd83103a048504a817c800830e57e0945927c5cc723c4486f93bf90bad3be8831139499e80b864140f8dd300000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000c03905df347aa6490d5a98fbb8d8e49520000000000000000000000000000000000000000000000000000000057d56ee61ba0f115cc4d7516dd430046504e1c888198e0323e8ded016d755f89c226ba3481dca04a2ae8ee49f1100b5c0202b37ed8bacf4caeddebde6b7f77e12e7a55893e9f62",
            "0xf115cc4d7516dd430046504e1c888198e0323e8ded016d755f89c226ba3481dc",
            "0x4a2ae8ee49f1100b5c0202b37ed8bacf4caeddebde6b7f77e12e7a55893e9f62",
            (byte) 0
    );
    //CHECKSTYLE:ON

    EthTransaction ethTransaction = deserialiseResponse(EthTransaction.class);
    assertThat(ethTransaction.getTransaction().get(), equalTo(transaction));
}
 
开发者ID:web3j,项目名称:web3j,代码行数:53,代码来源:ResponseTest.java

示例15: transactionObservable

import org.web3j.protocol.core.methods.response.Transaction; //导入依赖的package包/类
/**
 * Create an Observable to emit all new transactions as they are confirmed on the blockchain.
 * i.e. they have been mined and are incorporated into a block.
 *
 * @return Observable to emit new transactions on the blockchain
 */
Observable<Transaction> transactionObservable();
 
开发者ID:web3j,项目名称:web3j,代码行数:8,代码来源:Web3jRx.java


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