calling "publish", getting "Insufficient funds" error

+2 votes

Hello everyone,

We are using MultiChain for data storage and retrieval only, not for asset management. I managed to set up several nodes (with different datadir) on the same laptop, and could read/publish on streams without any problem. Today I tried to set up from scratch a new node on a separate laptop, and connect it to the man chain. The connection between both nodes works fine. I subscribed from the new node to the original node to a stream and granted write access. All fine.
But when I tried to publish something on the stream, I got this error.
message sent:

{
    "jsonrpc": "2.0",
    "method": "publish",
    "params": ["stream-ref-redacted", "key1", "lots of nice hexadecimal data redacted"],
    "id": 12345
}

server's response:

{
    "result": null,
    "error": {
        "code": -4,
        "message": "Insufficient funds, but there are coins belonging to addresses without send permission or P2SH addresses."
    },
    "id": 12345
}

I was suprised by the error message, as I don't manipulate funds. I checked that all the write access were ok, they are. I also used the getaddressbalances function & had an empty array in return.
Any idea?

 

[edit] : solved by MultiChain user, I needed to grant both send & receive to the associated address to be able to publish ; was new in alpha25 release.

asked Oct 28, 2016 by financedev
edited Oct 31, 2016 by financedev

1 Answer

+2 votes
Did you do this in alpha 24? If so please try again in alpha 25, which fixes a number of publish bugs that your code may have touched upon. If not, please let us know and we'll think some more.
answered Oct 28, 2016 by MultiChain
Yes I did this in alpha24 on Windows. I hasdn't realized that alpha 25 was available, I'll test it and get back to you on the results.
OK, here's the new result (apparently, a different error code) :
request:
{
    "jsonrpc": "2.0",
    "method": "publish",
    "params": ["_redacted_stream_address_", "key1", "_hexa_data_"],
    "id": 789
}
result:
{
    "result": null,
    "error": {
        "code": -8,
        "message": "Publishing in this stream is not allowed from this wallet"
    },
    "id": 789
}
so I checked the write permission on the stream:
request:
{
    "jsonrpc": "2.0",
    "method": "listpermissions",
    "params": ["_redatected_stream_address_.write", "*", true],
    "id": 123
}
result:
[ [_redacted_...], {
    "address": "_redacted_proper_node_address_",
    "for": {
        "type": "stream",
        "name": "_STREAM_NAME_",
        "streamref": "_redacted_"
    },
    "type": "write",
    "startblock": 0,
    "endblock": 4294967295,
    "admins": ["_redacted_"],
    "pending": []
}]
Everything seems fine. Is there something I'm missing?
Can you please try using publishfrom with the explicit address that you want to write to the stream from?
Sure.
So at first with the publishfrom function I got :
{
    "result": null,
    "error": {
        "code": -8,
        "message": "from-address doesn't have send permission"
    },
    "id": ...
}
which was weird because the other nodes I use (that can publish on my stream) don't have the send permission. Still I added it & managed to send data on the stream 6 times, then it stopped and I got this error:
{
    "result": null,
    "error": {
        "code": -4,
        "message": "No unspent output with write permission"
    },
    "id": ...
}
Not sure what to do next :)
Your publishing address needs send and receive permission - the receive permission is for the 'change' that creates the unspent output for the next item. (We of course need to make this clearer...)
OK, so moving to alpha25 made all the nodes that didn't have both send & receive permissions stop working and having the "No unspent output with write permission" error message. I granted access and all started to work again.
I agree that making things clearer in the documentation &/or in the error messages sent by the server would be nice. Problem solved for me at least. Thanks for your help and your efficiency.
...