Sending raw transactions

0 votes
Hello,

 

I was working through the guide "Working with raw transactions" and was able to successfully send non-native assets (thanks!)

However, after completing a transaction and attempting another, I had to go farther back in the return list to get the next txid and vout for the same asset. I did this again and again I must go farther back.

If I keep using these txids and vouts to send transactions, I assume the list of unspent for this asset will eventually become zero as there aren't any txids being added to the list, only removed.

Is there a way to create a raw transaction from a previous transaction or similar so that I can have a definitive method for getting the proper txid and vout to create another transaction? Am I missing something about listunspent? I tried to make the maxconf variable larger, but it seems I am viewing the whole list.

Thanks for any help.
asked May 2, 2016 by anonymous

1 Answer

+1 vote

Until you actually send the raw transaction with sendrawtransaction, any txid/vout it uses remains unspent. Once it's sent, you can't use the same txid/vout again. The point of calling preparelockunspent is to create a new txid/vout to use (it also creates a second output that is used to send change back, to avoid UTXO depletion). So I'm not sure what problem you're seeing here?

answered May 3, 2016 by MultiChain
I think this answers my question. I guess I was confused by the API reference in that I was thinking atomic exchange transaction commands shouldn't be used with the raw transaction commands.

To summarize, I should use preparelockunspent to get the txid and vout for all transactions? Or is there a certain time to use one over the other?

Thanks!
If you want a new txid/vout to use with a raw transaction, then preparelockunspent / preparelockunspentfrom is the way to go.
Thanks for this, this is what I was looking for.

Another follow-up question, and I can put this in a new thread if needed.

Do you know what the syntax would be to call preparelockunspentfrom via python-bitcoinrpc? I have tried the following:

preparelockunspentfrom("address", '{"asset":20}')

preparelockunspentfrom("address", "asset", "20")

preparelockunspentfrom("address", "asset", float("20"))

preparelockunspentfrom("address", "asset", Decimal("20"))

These get the following error:

JSONRPCException: -1: value is type str, expected real


Thanks for any help you may be able to provide.
I guess the second parameter would be {"asset":20} in Python format, without the single quotes.
Now that you say this, it makes perfect sense. Thanks for all your help!
...