"No unspent outputs are available" errror when publishing using external key

+2 votes

Hello,

I have been trying to publish data into stream using external private key fetched using "createkeypairs" API call.

This is the command flow:

-createrawsendfrom

-signrawtransaction

-sendrawtransaction

 

Sometimes (randomly) i get an error "No unspent outputs are available. Please send a transaction, with zero amount, to this node or address first and wait for its confirmation." when using 'createrawsendfrom' API call.

Funny thing is that, at some point it will allow publish of the same message, this is the log:

http://prntscr.com/ekpgb4

Are you familiar with this problem? What might be the issue?

Thank you in advance.

asked Mar 16, 2017 by anonymous

1 Answer

+1 vote

Are you running on alpha 28 of MultiChain? Some issues relating to tracking unspent outputs for watch-only addresses were resolved in this version. Also, if you upgraded to this version from a previous one, you may need to reindex the chain (running multichaind with -reindex=1) to resolve the issue completely. 

answered Mar 16, 2017 by MultiChain
Hello, it seems that i am using alpha 28 version, and i have put both reindex=1 as a paramater and into command (multichaind chain -reindex=1 -daemon) and i still have this issue.
OK. Are you sending transactions to multiple nodes simultaneously, for the same addresses?
Transaction is being sent to one node only, so basically this is what i do:

- Create key pair and import given address to a node and grant it send,receive permission

- createrawsendfrom address '{}' '[{"for":"stream","key":"key","data":"datahex"}]'

- signrawtransaction [hex blob output from previous api call] '[]' '["privkey"]'

- sendrawtransaciton [hex blob output from previous api call]

And i occasionally get this "No unspent outputs available" at createrawsendfrom
OK, I think we understand the problem. It seems that createrawsendfrom currently requires the transaction outputs it spends to be 'confirmed', which means that after it is used one time, you need to wait for the change output from that transaction to be confirmed in a block before you can use it in the next transaction.

This is a shortcoming, and we'll fix it shortly. But a good workaround for now is to make sure there are plenty of spare unspent transaction outputs (UTXOs) available. You can do this by calling createrawsendfrom a bunch of times, to send a zero quantity from the address back to itself. Each time this is done, it will create an extra UTXO, because that transaction will also send an additional change output to the same address.

You can use the listunspent API to see how many UTXOs are currently available, to confirm the workaround is effective.
Ok, thank you again.
Alpha 29 has just been released which should fix this issue.
Great! Thank you for this fixing this :)
...