I am developing a Document Signing Solution using Bitcoin.
1. A User sign a document and post the signed document to Server.
2. Server calculate the hash(sha-256) of the signed document.
3. Server create a new Bitcoin Raw-Transaction with the hashed value of document as OP_RETURN and finally send to Bitcoin network.
(
I have Bitcoin Server running bitcoin-qt.exe as Daemon on testnet and communicating by JSON-RPC with bitcoinj-core.jar.
A Wallet's account has enough bitcoin has received from the free bitcoin charge site like "
http://tpfaucet.appspot.com/".
)
Problem: Now Bitcoin Server send one transaction successfully but has to wait long time(i don't know exactly) to send next transaction until the previouse one has been confirmed.
Question: I want to send over 1000 transactions every minutes.
How can i obtain available UnspentOutput at any time?
Do you have any idea?
This is my real test code.
NetworkParameters np = TestNet3Params.get();
URI server = new URI("");
String username = "";
String password = "";
BitcoinExtendedClient client = new BitcoinExtendedClient(np, server, username, password);
List
lst = client.listUnspent(); // How can i obtain available UnspentOutput at any time?
if (lst.size() == 0) {
System.out.println("No UnspentOutput.");
} else {
ECKey senderKey = null;
for(int n=0; n UnspentOutput item = lst.get(n);
Coin ownAmount = item.getAmount();
if (ownAmount.value >= Coin.SATOSHI.value) {
senderKey = client.dumpPrivKey(item.getAddress());
break;
}
}
if (senderKey != null) {
Coin sendingAmount = Coin.ZERO;
Address receiverAddress = client.getNewAddress();
byte[] opRetData = BlockSignAlg.sign("test", BlockSignAlg.TEST_NET);
if (opRetData != null) {
Transaction tx = client.createSignedTransaction(senderKey, receiverAddress, sendingAmount, opRetData);
//Coin coinFee = tx.getFee();
tx.verify();
Sha256Hash txId = client.sendRawTransaction(tx);
System.out.println("txId : " + txId.toString());
} else {
System.out.println("Can't generate OpReturn Data.");
}
} else {
System.out.println("No UnspentOutput.");
}
}