Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sourabhlodha opened this issue Sep 25, 2018 · 3 comments

Comments

@sourabhlodha
Copy link

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

@innopreneur
Copy link
Contributor

@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?

@sourabhlodha
Copy link
Author

sourabhlodha commented Sep 28, 2018

@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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants