Create transactions at the same time

+1 vote
Dear Admin,

I created 2 transaction from a wallet address with function: "createrawsendfrom". After, I used private key to sign the tow transactions. When  I sent the transactions, I only send a transaction successful and a transaction is fail.

I get an error:

Error code: -26

Message:18: Bad-txns-inputs-spent

So, Can you please help me to create transactions from a wallet address at the same time?

thanks so much.
asked Nov 5, 2018 by baonv

1 Answer

0 votes

First, have you considered using a single transaction to cover both of the actions you wanted in separate transactions? There is a lot of flexibility in what can be done together using createrawsendfrom.

If this is not an option, first you need to ensure that this address has at least two unspent transaction outputs that it can use. You can do this by sending an amount to yourself. Then, when using createrawsendfrom for the first transaction, make sure you pass lock in the action parameter, so the second transaction doesn't try to spend the same output.

answered Nov 5, 2018 by MultiChain
Hi  MultiChain Developer Q&A
I'm using "createrawsendfrom" to create transactions to publish stream item. 2 transactions are different the hex data of transaction. But It's same the TxId and Vout in Vin of the transactions.
So when we create/sign/send transactions at the same time. The first transaction is successful and then second transaction is fail with error:
Error code: -26
Message:18: Bad-txns-inputs-spent

So, Can we create 2 transactions to publish stream from one wallet address and at the time?
Yes, as explained in the answer, first send a transaction to yourself, e.g.:

send [address] 0

Then you can use createrawsendfrom twice, but be sure to pass 'lock' in the final 'action' parameter the first time, so the same outputs are not spent in both transactions.
...