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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations