I want to use Data Stream as a append-only log, when testing the method sendwithmetadata following the guide of the doc the website provided. At first, things works well, but after executions of sendwithmetadata many time, suddenly I found an error occurs:
testchain: sendwithmetadata 1AxyjHveM5qHAabj494HHEgVny3iX3KyUfKjUh 0 123454321
{"method":"sendwithmetadata","params":["1AxyjHveM5qHAabj494HHEgVny3iX3KyUfKjUh",0,"123454321"],"id":1,"chain_name":"testchain"}
error code: -4
error message:
Insufficient funds, but there are coins belonging to addresses without send permission or P2SH addresses.
Using the multichain-explorer,I found a sendwithmetadata method normally creates a transaction(I name this kind tx as sendwithmetadata transaction) with three outputs:
When executing a new sendwithmetadata method, the third output of former sendwithmetadata transaction will be redeemed, and the new sendwithmetadata transaction also has three output.
But, when the error occurs, I found the sendwithmetadata transaction only have two outputs, so next time when I execute sendwithmetadata method, I have no "unspend" output to redeem, which make the error happen.I recreate a new chain and test sendwithmetadata many times, untill now there is no such error. I'm confused now.
so my question is why there are different transaction outputs for the same method sendwithmetadata, and is there some trick I don't know when execute sendwithmetadata, or this is just a bug?