issue while running publish command

+3 votes
\nerror code: -716\nerror message:\nNo unspent outputs are available. Please send a transaction, with zero amount, to this node or address first and wait for its confirmation.\n'

b'{"method":"publish","params":[ .....................]"chain_name":"chain2"}\n\nerror code: -26\nerror message:\nError: this transaction was rejected. This may be because you are sharing private keys between nodes, and another node has spent the funds used by this transaction.\n'

.........................................................

then I created a new chain in a separate folder, but still got same message. The python file was running properly few days back, then after database corruption issue. these message are appearing now for publishcommand.

\nerror code: -708\nerror message:\nStream with this name not found: chr2stream15\n'

nerror code: -26\nerror message:\nError: this transaction was rejected. This may be because you are sharing private keys between nodes, and another node has spent the funds used by this transaction.\n'
asked Feb 27, 2023 by anju
started a new chain "chainx"
 
$ python3 ./SAMchain/buildChain.py  -cn 'chainx' -dr './chaindata'
 Message:
MultiChain 2.3.1 Daemon (Enterprise Demo Edition, latest protocol 20013)
NOTE! THIS DEMO VERSION CAN BE USED DURING THE FIRST 3 MONTHS OF A BLOCKCHAIN.
Starting up node...
Looking for genesis block...
Genesis block found
Other nodes can connect to this node using:
multichaind chainx@169.254.207.242:2907
This host has multiple IP addresses, so from some networks:
multichaind chainx@192.168.56.1:2907
multichaind chainx@10.100.2.102:2907
multichaind chainx@169.254.65.172:2907
multichaind chainx@192.168.48.1:2907
multichaind chainx@192.168.42.1:2907
multichaind chainx@192.168.216.169:2907
multichaind chainx@169.254.193.134:2907
Listening for API requests on port 2906 (local only - see rpcallowip setting)
Node ready.

--STREAM CREATION--
Chain construction complete! Chain name: chainx
  $ multichain-cli chainx -datadir=./chaindata getwalletinfo
{"method":"getwalletinfo","params":[],"id":"68463936-1678434259","chain_name":"chainx"}
{
    "walletversion" : 60000,
    "balance" : 0,
    "walletdbversion" : 3,
    "txcount" : 607,
    "utxocount" : 1,
    "keypoololdest" : 1678427047,
    "keypoolsize" : 2
}
$ python3 ./SAMchain/insertData.py ./datafile/HG00114.bam -cn 'chainx' -dr './chaindata'
Message:
 ………………
Starting up node...
Other nodes can connect to this node using:
multichaind chainx@169.254.207.242:2907
………………………
Listening for API requests on port 2906 (local only - see rpcallowip setting)
Node didn't shut down normally, performing recovery
Node ready.
 
--PREPROCESSING--
1
b'error: Could not connect to the server 127.0.0.1:2906\n\nMake sure the multichaind server is running and that you are connecting to the correct RPC port.\n'
……………………………………
// however the message couldn’t connect to server is coming, but still data is published in streams
 $ multichain-cli chainx -datadir=./chaindata getwalletinfo
{"method":"getwalletinfo","params":[],"id":"95677074-1678435694","chain_name":"chainx"}
{
    "walletversion" : 60000,
    "balance" : 0,
    "walletdbversion" : 3,
    "txcount" : 923,
    "utxocount" : 1,
    "keypoololdest" : 1678427047,
    "keypoolsize" : 2
}
 $ python3 ./SAMchain/queryReads.py chainx  
………………output generated……………….

 $ multichain-cli chainx -datadir=./chaindata getwalletinfo

{"method":"getwalletinfo","params":[],"id":"40505990-1678445645","chain_name":"chainx"}
{
    "walletversion" : 60000,
    "balance" : 0,
    "walletdbversion" : 3,
    "txcount" : 923,
    "utxocount" : 1,
    "keypoololdest" : 1678427047,
    "keypoolsize" : 2
}

***********************************************************
Next day 

$ python3 ./SAMchain/queryReads.py chainx   
//no  data found in streams
 $ multichain-cli chainx -datadir=./chaindata getwalletinfo

{"method":"getwalletinfo","params":[],"id":"88295731-1678622774","chain_name":"chainx"}
{
    "walletversion" : 60000,
    "balance" : 0,
    "walletdbversion" : 3,
    "txcount" : 607,
    "utxocount" : 0,
    "keypoololdest" : 1678427047,
    "keypoolsize" : 2
}

//again tried to publish data

 $ python3 ./SAMchain/insertData.py ./datafile/HG00114.bam -cn 'chainx' -dr './chaindata'

MultiChain 2.3.1 Daemon (Enterprise Demo Edition, latest protocol 20013)
NOTE! THIS DEMO VERSION CAN BE USED DURING THE FIRST 3 MONTHS OF A BLOCKCHAIN.
Starting up node...
Other nodes can connect to this node using:
multichaind chainx@169.254.207.242:2907
……………………………………….
Listening for API requests on port 2906 (local only - see rpcallowip setting)
Node didn't shut down normally, performing recovery
Node ready.
 
--PREPROCESSING--
 
204
b'{"method":"publish","params":["metaData",["header"],{"json":{"header":"@HD\\tVN:1.5\\tGO:none\\tSO:coordinate\\n"}}],"id":"60186058-1678622982","chain_name":"chainx"}\n\nerror code: -716\nerror message:\nNo unspent outputs are available. Please send a transaction, with zero amount, to this node or address first and wait for its confirmation.\n'
……………………….
/////////////////////////////////////////////
I couldn’t publish data now in streams. I couldn’t understand why data is cleared next day( when system is restarted). Also, there is one major change in txcount and utxocount from ("txcount" : 923,  "utxocount": 1, )  ----> (  "txcount" : 607,    "utxocount" : 0, ).
Since, utxocount is 0, the data can’t be published now.
Thanks for this, but this list of commands (using your own Python code) does not help us, since we have no idea what your code is doing (and we are not going to be able to get into the detail of reading it).

Please try building your workflow in multichain-cli first, send us the list of multichain-cli commands and their responses. This is how we can see where something is going wrong. I'm afraid we cannot debug your specific Python code.
test file "build.py" code:-
 
import sys
import time
import math
import binascii
import argparse
import subprocess
from subprocess import Popen, PIPE
import os
import psutil
import time
import multiprocessing
import glob
import json
import re
import pandas as pd

#create a chain given the name of the chain
def createChain(chainName, multichainLoc, datadir):
    hasError = 0
    createCommand=multichainLoc+'multichain-util create {} -datadir={}'.format(chainName, datadir)
    runCommand = multichainLoc+'multichaind {} -datadir={} -daemon'.format(chainName, datadir)

    #make the chain
    procCreate = subprocess.Popen(createCommand.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    stdout_valc, stderr_valc = procCreate.communicate()
    if(("error".encode() in stderr_valc) or ("ERROR".encode() in stderr_valc)):
        print("Could not create chain (it probably already exists)")
        hasError = -1
    else:
        print("Created chain")

    #start the chain
    daemonOut = subprocess.call(runCommand.split()) #returns 0 whether or not it had an error; subprocess hangs
    #because output is too long (known subprocess bug); just relying on chain creation to catch bug
    time.sleep(1)
    return hasError

#Given a chain name and the name of the new stream, makes that stream
def makeStream(chainName, streamName, multichainLoc, datadir):
    createStreamCommand=multichainLoc+'multichain-cli {} -datadir={} create stream {} true'.format(chainName,datadir,streamName)
    subscribeStreamCommand=multichainLoc+'multichain-cli {} -datadir={} subscribe {}'.format(chainName,datadir,streamName)

    #make stream of name StreamName
    procCreate = subprocess.Popen(createStreamCommand.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    procCreate.wait()

    #subscribe to the stream
    procSubscribe = subprocess.Popen(subscribeStreamCommand.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    procCreate.wait()
 
def publishToStream(chainName, datadir, streamName, key, multichainLoc, data= format(" ".encode().hex())):
   
    subscribeStreamCommand=multichainLoc+'multichain-cli {} -datadir={} subscribe {}'.format(chainName,datadir,streamName)
    #subscribe to the stream
    procSubscribe = subprocess.Popen(subscribeStreamCommand.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    procSubscribe.wait()
    hasError = 0
    publishCommand = [multichainLoc+'multichain-cli', str('{}'.format(chainName)), str('-datadir={}'.format(datadir)),
    'publish', str('{}'.format(streamName)), str('{}'.format(key)), str('{}'.format(data))]
     
    try:
        dummy = subprocess.check_output(publishCommand, stderr=subprocess.STDOUT)
        print("data published")
    except subprocess.CalledProcessError as e:
        print(e.returncode)
        print(e.output)
    
    return hasError
def query(chainName, datadir, multichainLoc,streamName ):
    subscribeStreamCommand=multichainLoc+'multichain-cli {} -datadir={} subscribe {}'.format(chainName,datadir,streamName)
    #subscribe to the stream
    procSubscribe = subprocess.Popen(subscribeStreamCommand.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    procSubscribe.wait()

    queryCommand = multichainLoc+'multichain-cli {} -datadir={} liststreamitems {}'.format(chainName, datadir, streamName)
    items = subprocess.check_output(queryCommand.split())
    if("error".encode() in items or "ERROR".encode() in items):
        return -1
    got_items = json.loads(items, parse_int= int)
    print("items fetched")
    for streamitem in got_items:
        #data=streamitem["data"]["json"]['field1']
        print(streamitem)
        

def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-cn", "--chainName", help = "the name of the chain to store data", default = "chain1")
    parser.add_argument("-ml", "--multichainLoc", help = "path to multichain commands", default = "")
    parser.add_argument("-dr", "--datadir", help = "path to store the chain")
    args = parser.parse_args()

    start = time.time()
    #make a chain
    print("--CHAIN CREATION--")
    hasError=0
    hasError = createChain(args.chainName, args.multichainLoc, args.datadir)
    if hasError:
        sys.stderr.write("\nERROR: Failed chain creation. Please try again with a different chain name.\n")
        quit()

    #make the streams
    makeStream(args.chainName, "stream2", args.multichainLoc, args.datadir)
    print("Chain construction complete!")
    #publish data for chain (thrice)
    for i in range(1, 3):
        chainData = '{"json":{"field1":"abc", "field2":"xyz"}}'
        publishToStream(args.chainName, args.datadir, "stream2", ("key1"), args.multichainLoc, chainData)
    # query stream
    query(args.chainName, args.datadir, args.multichainLoc,"stream2")

if __name__ == "__main__":
    main()
19mar23
the output for new test file( shared before this post) for checking commands is provided below--

anju@DESKTOP-FFAFKFO:/mnt/c/Users/RAM/project$ python3 build.py  -cn 'chain1' -dr './chaindata'
--CHAIN CREATION--
Chain construction complete! Chain name: chain1
data published
data published
{"method":"liststreamitems","params":["stream2"],"id":"62752225-1679207580","chain_name":"chain1"}

items fetched
{'publishers': ['1SdvmjcS4U2KHt5ewscRfoFwV9TBDUPpcmMRP8'], 'keys': ['key1'], 'offchain': False, 'available': True, 'data': {'json': {'field1': 'abc', 'field2': 'xyz'}}, 'confirmations': 11, 'blocktime': 1679207264, 'txid': '1a3926afc391d8a1db163000b8f67ae06c4b19efb66b725f8344ffe3b9d27d8c'}
{'publishers': ['1SdvmjcS4U2KHt5ewscRfoFwV9TBDUPpcmMRP8'], 'keys': ['key1'], 'offchain': False, 'available': True, 'data': {'json': {'field1': 'abc', 'field2': 'xyz'}}, 'confirmations': 11, 'blocktime': 1679207264, 'txid': '3ef9cb75011d133066bd699d04584fb05b9a2c6843f191325ef2aa6255d29249'}
{'publishers': ['1SdvmjcS4U2KHt5ewscRfoFwV9TBDUPpcmMRP8'], 'keys': ['key1'], 'offchain': False, 'available': True, 'data': {'json': {'field1': 'abc', 'field2': 'xyz'}}, 'confirmations': 0, 'txid': '896e15949bdfee5689944ce3c8226fe0d25091b465ef9282db563489253c0449'}
{'publishers': ['1SdvmjcS4U2KHt5ewscRfoFwV9TBDUPpcmMRP8'], 'keys': ['key1'], 'offchain': False, 'available': True, 'data': {'json': {'field1': 'abc', 'field2': 'xyz'}}, 'confirmations': 0, 'txid': '6566a803689a2d2885adba3914eda1e18c44ef4857dc4f5611c27f7a9d4d9209'}
anju@DESKTOP-FFAFKFO:/mnt/c/Users/RAM/project$ multichain-cli chain1 -datadir=./chaindata getwalletinfo
{"method":"getwalletinfo","params":[],"id":"90982612-1679207616","chain_name":"chain1"}

{
    "walletversion" : 60000,
    "balance" : 0,
    "walletdbversion" : 3,
    "txcount" : 18,
    "utxocount" : 1,
    "keypoololdest" : 1679204288,
    "keypoolsize" : 2
}
...........................
stop ubuntu app
restart
...........................
anju@DESKTOP-FFAFKFO:~$ cd /mnt/c/Users/RAM
anju@DESKTOP-FFAFKFO:/mnt/c/Users/RAM$ cd project
anju@DESKTOP-FFAFKFO:/mnt/c/Users/RAM/project$ multichaind chain1 -datadir=./chaindata -daemon &
[1] 383
anju@DESKTOP-FFAFKFO:/mnt/c/Users/RAM/project$
MultiChain 2.3.1 Daemon (Enterprise Demo Edition, latest protocol 20013)

NOTE! THIS DEMO VERSION CAN BE USED DURING THE FIRST 3 MONTHS OF A BLOCKCHAIN.

Starting up node...

Error: ERROR: Couldn't initialize asset database for blockchain chain1. Please restart multichaind with reindex=1.


[1]+  Done                    multichaind chain1 -datadir=./chaindata -daemon
anju@DESKTOP-FFAFKFO:/mnt/c/Users/RAM/project$ multichain-cli chain1 -datadir=./chaindata getwalletinfo
{"method":"getwalletinfo","params":[],"id":"41156030-1679207875","chain_name":"chain1"}

{
    "walletversion" : 60000,
    "balance" : 0,
    "walletdbversion" : 3,
    "txcount" : 18,
    "utxocount" : 1,
    "keypoololdest" : 1679204288,
    "keypoolsize" : 2
}
anju@DESKTOP-FFAFKFO:/mnt/c/Users/RAM/project$ multichaind chain1 -datadir=./chaindata -daemon reindex=1

MultiChain 2.3.1 Daemon (Enterprise Demo Edition, latest protocol 20013)

NOTE! THIS DEMO VERSION CAN BE USED DURING THE FIRST 3 MONTHS OF A BLOCKCHAIN.

Starting up node...

Other nodes can connect to this node using:
multichaind chain1@169.254.193.134:5747

...................

Listening for API requests on port 5746 (local only - see rpcallowip setting)

Node ready.

anju@DESKTOP-FFAFKFO:/mnt/c/Users/RAM/project$ multichain-cli chain1 -datadir=./chaindata subscribe stream2
{"method":"subscribe","params":["stream2"],"id":"47761770-1679207928","chain_name":"chain1"}

anju@DESKTOP-FFAFKFO:/mnt/c/Users/RAM/project$ multichain-cli chain1 -datadir=./chaindata liststreamitems stream2
{"method":"liststreamitems","params":["stream2"],"id":"75192754-1679208004","chain_name":"chain1"}

[
    {
        "publishers" : [
            "1SdvmjcS4U2KHt5ewscRfoFwV9TBDUPpcmMRP8"
        ],
        "keys" : [
            "key1"
        ],
        "offchain" : false,
        "available" : true,
        "data" : {
            "json" : {
                "field1" : "abc",
                "field2" : "xyz"
            }
        },
        "confirmations" : 11,
        "blocktime" : 1679207597,
        "txid" : "896e15949bdfee5689944ce3c8226fe0d25091b465ef9282db563489253c0449"
    },
    {
        "publishers" : [
            "1SdvmjcS4U2KHt5ewscRfoFwV9TBDUPpcmMRP8"
        ],
        "keys" : [
            "key1"
        ],
        "offchain" : false,
        "available" : true,
        "data" : {
            "json" : {
                "field1" : "abc",
                "field2" : "xyz"
            }
        },
        "confirmations" : 11,
        "blocktime" : 1679207597,
        "txid" : "6566a803689a2d2885adba3914eda1e18c44ef4857dc4f5611c27f7a9d4d9209"
    }
]
anju@DESKTOP-FFAFKFO:/mnt/c/Users/RAM/project$

///////////////////////////////
22mar23

Before running "build.py" file, I commented createchain() [line99] and makestream() [line105]........

anju@DESKTOP-FFAFKFO:/mnt/c/Users/RAM/project$ multichain-cli chain1 -datadir=./chaindata liststreams
{"method":"liststreams","params":[],"id":"89061816-1679474180","chain_name":"chain1"}

[
    {
        "name" : "root",
        "createtxid" : "3c7a274f893e9cd973d8c40af3f534531498e42ac6f5a53f52f9f1b8ca562916",
        "streamref" : "0-0-0",
      ....................................
    },
    {
        "name" : "stream2",
        "createtxid" : "468c8301070ab6d14333e64656a6e5094c8f9e3f08dffae0d5dd873d7c7bc093",
        "streamref" : null,
        "restrict" : {
            "write" : false,
            "read" : false,
            "onchain" : false,
            "offchain" : false
        },
        "details" : {
        },
        "subscribed" : false
    }
]
anju@DESKTOP-FFAFKFO:/mnt/c/Users/RAM/project$ multichain-cli chain1 -datadir=./chaindata subscribe stream2
{"method":"subscribe","params":["stream2"],"id":"59710475-1679476445","chain_name":"chain1"}

error code: -708
error message:
Entity with this name not found: stream2
anju@DESKTOP-FFAFKFO:/mnt/c/Users/RAM/project$ python3 build.py  -cn 'chain1' -dr './chaindata'
--CHAIN CREATION--
Chain construction complete!
196
b'{"method":"publish","params":["stream2","key1",{"json":{"field1":"abc","field2":"xyz"}}],"id":"54292752-1679474681","chain_name":"chain1"}\n\nerror code: -708\nerror message:\nStream with this name not found: stream2\n'
196
b'{"method":"publish","params":["stream2","key1",{"json":{"field1":"abc","field2":"xyz"}}],"id":"54292752-1679474681","chain_name":"chain1"}\n\nerror code: -708\nerror message:\nStream with this name not found: stream2\n'
{"method":"liststreamitems","params":["stream2"],"id":"54292752-1679474681","chain_name":"chain1"}

error code: -708
error message:
Stream with this name not found: stream2
Traceback (most recent call last):
  File "build.py", line 111, in <module>
    main()
  File "build.py", line 108, in main
    query(args.chainName, args.datadir, args.multichainLoc,"stream2")
  File "build.py", line 74, in query
    items = subprocess.check_output(queryCommand.split())
  File "/usr/lib/python3.8/subprocess.py", line 415, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.8/subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['multichain-cli', 'chain1', '-datadir=./chaindata', 'liststreamitems', 'stream2']' returned non-zero exit status 196.

anju@DESKTOP-FFAFKFO:/mnt/c/Users/RAM/project$ multichain-cli chain1 -datadir=./chaindata getwalletinfo
{"method":"getwalletinfo","params":[],"id":"99380486-1679474959","chain_name":"chain1"}

{
    "walletversion" : 60000,
    "balance" : 0,
    "walletdbversion" : 3,
    "txcount" : 3,
    "utxocount" : 0,
    "keypoololdest" : 1679204288,
    "keypoolsize" : 2
}
I think the problem is most likely to be how you are using MultiChain on Linux within Windows.

The first thing to do is try is to make sure that you always stop MultiChain properly before stopping the Linux environment. You can do this using the 'stop' command via the MultiChain API or multichain-cli. Otherwise there could be corruption of its files, because of the emulation environment not behaving how Linux usually behaves.

If that does not work, please try running MultiChain on Linux directly. You can get a cheap Linux cloud instance for a few dollars per month from providers like Digital Ocean and Hetzner Cloud. MultiChain will run fine on those.

Please log in or register to answer this question.

...