Bitcoin Forum

Bitcoin => Project Development => Topic started by: gyouny on May 10, 2017, 04:55:35 AM



Title: sendrawtransaction over 1000 times every minutes?
Post by: gyouny on May 10, 2017, 04:55:35 AM

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<UnspentOutput> 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<lst.size(); ++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.");
   }
}   


Title: Re: sendrawtransaction over 1000 times every minutes?
Post by: achow101 on May 10, 2017, 01:17:44 PM
Try doing
Code:
listunspent 0
instead. The default (without any parameters) is to have a minimum of 1 confirmation. With that one parameter, you set the minimum confirmation requirement to 0, so it should return the outputs for unconfirmed transactions.

You are going to have a problem after making the 25th transaction. Core will not allow you to have unconfirmed transaction chains of more than 25.