Search in sources :

Example 1 with TxContentBlob

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

the class TransactionDecorator method initTxContent.

private TransactionContent initTxContent(TransactionContent txContent) {
    TxContentBlob txContentBlob = new TxContentBlob(txContent.getLedgerHash());
    txContentBlob.setTime(txContent.getTimestamp());
    Operation[] operations = txContent.getOperations();
    if (operations != null && operations.length > 0) {
        for (Operation op : operations) {
            Operation opDecorator = initOperation(op);
            if (opDecorator != null) {
                txContentBlob.addOperation(opDecorator);
            }
        }
    }
    return txContentBlob;
}
Also used : TxContentBlob(com.jd.blockchain.transaction.TxContentBlob) Operation(com.jd.blockchain.ledger.Operation)

Example 2 with TxContentBlob

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

the class LedgerTransactionDataTest method initTransactionContent.

private TransactionContent initTransactionContent() throws Exception {
    TxContentBlob contentBlob = null;
    BlockchainKeypair id = BlockchainKeyGenerator.getInstance().generate(ClassicAlgorithm.ED25519);
    HashDigest ledgerHash = Crypto.getHashFunction("SHA256").hash(UUID.randomUUID().toString().getBytes("UTF-8"));
    BlockchainOperationFactory opFactory = new BlockchainOperationFactory();
    contentBlob = new TxContentBlob(ledgerHash);
    // contentBlob.setSubjectAccount(id.getAddress());
    // contentBlob.setSequenceNumber(1);
    DataAccountKVSetOperation kvsetOP = opFactory.dataAccount(id.getAddress()).setText("Name", "AAA", -1).getOperation();
    contentBlob.addOperation(kvsetOP);
    return contentBlob;
}
Also used : DataAccountKVSetOperation(com.jd.blockchain.ledger.DataAccountKVSetOperation) TxContentBlob(com.jd.blockchain.transaction.TxContentBlob) HashDigest(com.jd.blockchain.crypto.HashDigest) BlockchainKeypair(com.jd.blockchain.ledger.BlockchainKeypair) BlockchainOperationFactory(com.jd.blockchain.transaction.BlockchainOperationFactory)

Aggregations

TxContentBlob (com.jd.blockchain.transaction.TxContentBlob)2 HashDigest (com.jd.blockchain.crypto.HashDigest)1 BlockchainKeypair (com.jd.blockchain.ledger.BlockchainKeypair)1 DataAccountKVSetOperation (com.jd.blockchain.ledger.DataAccountKVSetOperation)1 Operation (com.jd.blockchain.ledger.Operation)1 BlockchainOperationFactory (com.jd.blockchain.transaction.BlockchainOperationFactory)1