publish data rejected.

+1 vote
When I publish data into a stream, like this:

publish 558085badaf9cbfc86b0c372addfc560 b875a05a6baaf92621fe185c7a8df74c 3139383330323033

I ran the command above for several times in a loop. sometimes it works good. sometime I get errors(2 kinds of errors):

error 1:

error code: -4 The transaction was rejected: 18: bad-txns-inputs-spent

error 2:

error code: -4 The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here.

Why this command does not give a stable output (good or bad) or how can I avoid this kind of situation?

 

Version is 27.

thanks.
asked Feb 22, 2017 by chad

1 Answer

0 votes
 
Best answer
The most likely explanation is that you have shared private keys between multiple nodes, and are publishing from both of those nodes simultaneously. In this case, each node may be trying to spend the same "UTXOs" (unspent transaction outputs), since there is a short delay from when one node spends a UTXO, to when the other node sees that.

If this explains the problem, it can be mostly easily solved by ensuring that different nodes are publishing from different addresses. Alternatively you can use the createrawtransaction API to manually control which UTXOs are used in each transaction, and then each node can be instructed to only spend those UTXOs which belong to it and/or it created as change outputs from previous transactions. More about raw transactions here: http://www.multichain.com/developers/raw-transactions/
answered Feb 22, 2017 by MultiChain
selected Feb 23, 2017 by chad
yes, i did share private keys between 2 nodes, but I just publish data from one node at that time.
I tried to use publishfrom instead of publish to wirte data into stream, it is solved.
...