java-bigchaindb-driver icon indicating copy to clipboard operation
java-bigchaindb-driver copied to clipboard

Not able to import com.bigchaindb.cryptoconditions.types.Ed25519Sha256Condition Package

Open sourabhlodha opened this issue 7 years ago • 3 comments

Hi Team,

I am trying to implement the java-bigchaindb but I am not able to send the transcation as it give error while importing package com.bigchaindb.cryptoconditions.types.Ed25519Sha256Condition;

Can you help me out as its by default package of bigchaindb

Thanks Sourabh Lodha

sourabhlodha avatar Sep 25 '18 09:09 sourabhlodha

@sourabhlodha can you please paste error stacktrace here. Also specify which driver version you are using? And are you using raw jar file or via maven or gradle?

innopreneur avatar Sep 28 '18 12:09 innopreneur

@innoprenuer I am using the same project with 1.0 version of the driver. Error

Exception in thread "main" java.lang.Error: Unresolved compilation problems: Ed25519Sha256Condition cannot be resolved to a type Ed25519Sha256Condition cannot be resolved to a type

at com.bigchaindb.builders.BigchainDbTransactionBuilder$Builder.addOutput(BigchainDbTransactionBuilder.java:264)
at com.bigchaindb.builders.BigchainDbTransactionBuilder$Builder.addOutput(BigchainDbTransactionBuilder.java:257)
at com.bigchaindb.builders.BigchainDbTransactionBuilder$Builder.addOutput(BigchainDbTransactionBuilder.java:251)
at com.bigchaindb.builders.BigchainDbTransactionBuilder$Builder.build(BigchainDbTransactionBuilder.java:353)
at com.bigchaindb.builders.BigchainDbTransactionBuilder$Builder.buildAndSign(BigchainDbTransactionBuilder.java:446)
at com.bigchaindb.builders.BigChainDBTest.main(BigChainDBTest.java:48)

Code

BigchainDbConfigBuilder .baseUrl("http://ip:9984") .setup(); net.i2p.crypto.eddsa.KeyPairGenerator edDsaKpg = new net.i2p.crypto.eddsa.KeyPairGenerator(); KeyPair keyPair = edDsaKpg.generateKeyPair();

	// New asset
	Map<String, String> assetData = new TreeMap<String, String>() {{
	    put("city", "Berlin, DE");
	    put("temperature", "22");
	    put("datetime", new Date().toString());
	}};

	// New metadata
	MetaData metaData = new MetaData();
	metaData.setMetaData("what", "My first BigchainDB transaction");
	Transaction createTransaction = BigchainDbTransactionBuilder
			.init()
			.addAssets(assetData, TreeMap.class)
			.addMetaData(metaData)
			.operation(Operations.CREATE)
			.buildAndSign((EdDSAPublicKey) keyPair.getPublic(), (EdDSAPrivateKey) keyPair.getPrivate()) //Facing error in this line
			.sendTransaction();
	KeyPair targetKeypair = edDsaKpg.generateKeyPair();

	// Describe the output you are fulfilling on the previous transaction
	final FulFill spendFrom = new FulFill();
	spendFrom.setTransactionId(createTransaction.getId());
	spendFrom.setOutputIndex(0);

	// Change the metadata if you want
	MetaData transferMetadata = new MetaData();
	metaData.setMetaData("what2", "My first BigchainDB transaction");

	// the asset's ID is equal to the ID of the transaction that created it
	String assetId = createTransaction.getId();

	// By default, the 'amount' of a created digital asset == "1". So we spend "1" in our TRANSFER.
	String amount = "1";

	// Use the previous transaction's asset and TRANSFER it
	Transaction transferTransaction = BigchainDbTransactionBuilder
		.init()
		.addMetaData(metaData)

		// source keypair is used in the input, because the current owner is "spending" the output to transfer it
		.addInput(null, spendFrom, (EdDSAPublicKey) keyPair.getPublic())

		// after this transaction, the target 'owns' the asset, so, the new output includes the target's public key
		.addOutput(output, (EdDSAPublicKey) targetKeypair.getPublic())

		// reference the asset by ID when doing a transfer
		.addAssets(assetId, String.class)
		.operation(Operations.TRANSFER)

		// the source key signs the transaction to authorize the transfer
		.buildAndSign((EdDSAPublicKey) keyPair.getPublic(), (EdDSAPrivateKey) keyPair.getPrivate())
		.sendTransaction();

sourabhlodha avatar Sep 28 '18 12:09 sourabhlodha

@innoprenuer Can you help me out in giving simple working.

sourabhlodha avatar Sep 28 '18 12:09 sourabhlodha