Search in sources :

Example 11 with TxBuilder

use of com.jd.blockchain.transaction.TxBuilder in project jdchain-core by blockchain-jd-com.

the class LedgerTestUtils method createLedgerInitTxRequest_SHA256.

// public static TransactionRequest createTxRequest_UserReg(BlockchainKeypair userKeypair, HashDigest ledgerHash, BlockchainKeypair... partiKeys) {
// return createTxRequest_UserReg(userKeypair, ledgerHash, null, null);
// }
public static TransactionRequest createLedgerInitTxRequest_SHA256(BlockchainKeypair... participants) {
    TxBuilder txBuilder = new TxBuilder(null, ClassicAlgorithm.SHA256);
    for (BlockchainKeypair parti : participants) {
        txBuilder.users().register(parti.getIdentity());
    }
    // 202001202020L
    // long ts = System.currentTimeMillis();
    // long ts = 1580271132149L; //OK;
    long ts = 1580271176324L;
    System.out.printf("\r\n++++++ ts=%s ++++++\r\n", ts);
    TransactionRequestBuilder txReqBuilder = txBuilder.prepareRequest(ts);
    for (BlockchainKeypair parti : participants) {
        txReqBuilder.signAsNode(parti);
    }
    return txReqBuilder.buildRequest();
}
Also used : TxBuilder(com.jd.blockchain.transaction.TxBuilder)

Example 12 with TxBuilder

use of com.jd.blockchain.transaction.TxBuilder in project jdchain-core by blockchain-jd-com.

the class LedgerTestUtils method createTxRequest_DataAccountWrite_SHA256.

public static TransactionRequest createTxRequest_DataAccountWrite_SHA256(Bytes dataAccountAddress, String key, String value, long version, HashDigest ledgerHash, BlockchainKeypair nodeKeypair, BlockchainKeypair... signers) {
    TxBuilder txBuilder = new TxBuilder(ledgerHash, ClassicAlgorithm.SHA256);
    txBuilder.dataAccount(dataAccountAddress).setText(key, value, version);
    TransactionRequestBuilder txReqBuilder = txBuilder.prepareRequest(202001202020L);
    if (signers != null) {
        for (BlockchainKeypair signer : signers) {
            txReqBuilder.signAsEndpoint(signer);
        }
    }
    if (nodeKeypair != null) {
        txReqBuilder.signAsNode(nodeKeypair);
    }
    return txReqBuilder.buildRequest();
}
Also used : TxBuilder(com.jd.blockchain.transaction.TxBuilder)

Example 13 with TxBuilder

use of com.jd.blockchain.transaction.TxBuilder in project jdchain-core by blockchain-jd-com.

the class LedgerTestUtils method createTxRequest_MultiOPs_WithNotExistedDataAccount_SHA256.

/**
 * 创建一个写入到不存在账户的多操作交易;
 *
 * @param userKeypair 要注册的用户key;
 * @param ledgerHash  账本哈希;
 * @param nodeKeypair 节点key;
 * @param signers     签名者列表;
 * @return
 */
public static TransactionRequest createTxRequest_MultiOPs_WithNotExistedDataAccount_SHA256(BlockchainKeypair userKeypair, HashDigest ledgerHash, long ts, BlockchainKeypair nodeKeypair, BlockchainKeypair... signers) {
    TxBuilder txBuilder = new TxBuilder(ledgerHash, ClassicAlgorithm.SHA256);
    txBuilder.users().register(userKeypair.getIdentity());
    // 故意构建一个错误的
    // BlockchainKeypair testAccount = BlockchainKeyGenerator.getInstance().generate();
    BlockchainKeypair testAccount = createKeyPair("7VeRJRN2A1dwSAA6BNAM728aN12A3uwj1DVVVMzvJUP7Gnxm", "7VeRSBZNE6rNzkeRE3Sre2QbtNDKZNKqgzYhsvoY2QfKZenS");
    txBuilder.dataAccount(testAccount.getAddress()).setBytes("AA", "Value".getBytes(), 1);
    TransactionRequestBuilder txReqBuilder = txBuilder.prepareRequest(ts);
    txReqBuilder.signAsEndpoint(nodeKeypair);
    if (nodeKeypair != null) {
        txReqBuilder.signAsNode(nodeKeypair);
    }
    return txReqBuilder.buildRequest();
}
Also used : TxBuilder(com.jd.blockchain.transaction.TxBuilder)

Example 14 with TxBuilder

use of com.jd.blockchain.transaction.TxBuilder in project jdchain-core by blockchain-jd-com.

the class LedgerTestUtils method createTxRequest_UserReg_SHA256.

public static TransactionRequest createTxRequest_UserReg_SHA256(BlockchainKeypair userKeypair, HashDigest ledgerHash, long ts, BlockchainKeypair nodeKeypair, BlockchainKeypair... signers) {
    TxBuilder txBuilder = new TxBuilder(ledgerHash, ClassicAlgorithm.SHA256);
    txBuilder.users().register(userKeypair.getIdentity());
    TransactionRequestBuilder txReqBuilder = txBuilder.prepareRequest(ts);
    if (signers != null) {
        for (BlockchainKeypair signer : signers) {
            txReqBuilder.signAsEndpoint(signer);
        }
    }
    if (nodeKeypair != null) {
        txReqBuilder.signAsNode(nodeKeypair);
    }
    return txReqBuilder.buildRequest();
}
Also used : TxBuilder(com.jd.blockchain.transaction.TxBuilder)

Example 15 with TxBuilder

use of com.jd.blockchain.transaction.TxBuilder in project jdchain-core by blockchain-jd-com.

the class LedgerTestUtils method createTxRequest_DataAccountReg_SHA256.

public static TransactionRequest createTxRequest_DataAccountReg_SHA256(BlockchainKeypair dataAccountID, HashDigest ledgerHash, BlockchainKeypair nodeKeypair, BlockchainKeypair... signers) {
    TxBuilder txBuilder = new TxBuilder(ledgerHash, ClassicAlgorithm.SHA256);
    txBuilder.dataAccounts().register(dataAccountID.getIdentity());
    TransactionRequestBuilder txReqBuilder = txBuilder.prepareRequest(202001202020L);
    if (signers != null) {
        for (BlockchainKeypair signer : signers) {
            txReqBuilder.signAsEndpoint(signer);
        }
    }
    if (nodeKeypair != null) {
        txReqBuilder.signAsNode(nodeKeypair);
    }
    return txReqBuilder.buildRequest();
}
Also used : TxBuilder(com.jd.blockchain.transaction.TxBuilder)

Aggregations

TxBuilder (com.jd.blockchain.transaction.TxBuilder)18 LedgerEditor (com.jd.blockchain.ledger.core.LedgerEditor)6 HashDigest (com.jd.blockchain.crypto.HashDigest)5 LedgerDataSet (com.jd.blockchain.ledger.core.LedgerDataSet)5 TransactionBatchProcessor (com.jd.blockchain.ledger.core.TransactionBatchProcessor)5 TransactionBatchResultHandle (com.jd.blockchain.service.TransactionBatchResultHandle)5 LedgerManager (com.jd.blockchain.ledger.core.LedgerManager)4 LedgerRepository (com.jd.blockchain.ledger.core.LedgerRepository)4 DefaultOperationHandleRegisteration (com.jd.blockchain.ledger.core.DefaultOperationHandleRegisteration)3 ServiceEndpoint (com.jd.httpservice.agent.ServiceEndpoint)3 Test (org.junit.Test)3 Matchers.anyString (org.mockito.Matchers.anyString)3 TxTestContract (test.com.jd.blockchain.ledger.TxTestContract)3 Bytes (utils.Bytes)3 Property (utils.Property)3 LedgerSecurityManager (com.jd.blockchain.ledger.core.LedgerSecurityManager)2 Ignore (org.junit.Ignore)2 TxTestContractImpl (test.com.jd.blockchain.ledger.TxTestContractImpl)2 BlockchainIdentityData (com.jd.blockchain.ledger.BlockchainIdentityData)1 BlockchainKeypair (com.jd.blockchain.ledger.BlockchainKeypair)1