appendrawexchange error

+1 vote

Hi All,

I am using the Python RPC from https://github.com/jgarzik/python-bitcoinrpc.git for an atomic transaction

When I use appendrawexchange I am getting the below error:

bitcoinrpc.authproxy.JSONRPCException: -8: Missing inputs; Input: 0, txid: a872954bcbd1827ca3da854d7b0c37aac54a1709928ce2b0d6eed89426621ab1, vout: 

The command I have used is rpc_connection.appendrawexchange(<hex blob>,txnid,v_out,json.loads(asset))

Could anyone help me understand the error?

Note: The same command works well in the Interactive Console 

TIA

 

asked Apr 27, 2016 by Bhargi

1 Answer

0 votes

You should find a way to debug the JSON-RPC request that this library is sending, and compare it to the first line of the output of multichain-cli, to see where the difference is.

answered Apr 28, 2016 by MultiChain
Thanks for the reply.
I tried the Debug option and found some difference in the asked asset field.
This is the format of asset being printed in debug of JSON RPC"{\"TWOBHK\":1}"
Now I am getting a different error as below :bitcoinrpc.authproxy.JSONRPCException: -8: Invalid ask assets object

Again the same format and command works fine in the Interactive console
What could be the possible fix ?
Please show the full strings of both the first line of multichain-cli and the JSON-RPC request you are sending via the library, so we can compare exactly.
This is the request from JSON-RPC:
DEBUG:BitcoinRPC:-2-> appendrawexchange ["01000000013bb577e6ec535790e39ef529295d39e40a1096856db55985aebe871b5abda827000000006a47304402201bcb49582bf6282c3890fb180abb8bb4990b3bf849a4d0445db9df8b646a26600220184e2fb273c18f7b66f9542a69886ba47da73d32828b1fc71d8e8d7b227a4f5a83210272685178dfcb8e4f7ea9e488da690cd82ad9e577109582483cd8fd2e25802f58ffffffff0100000000000000003176a914448d117a6fe4956566000cc2a7b098ce12f592a688ac1673706b71930500000a010000e4800a000000000000007500000000", "58a9a2f8754c07f62652715371035ca5e43c4ba26d4f4df5ee559201f966b832", 0, "{\"TWOBHK\":1}"]
DEBUG:BitcoinRPC:<-- {"result":null,"error":{"code":-8,"message":"Invalid ask assets object"},"id":2}
---------------------------------------------------------------------------------------------------------
This is from the multichain-cli:
{"method":"appendrawexchange","params":["0100000001e001f80eae4a0ca7a83fefd890efe97ccd0985b26ce73f054a2a9fd31a44e8ed000000006b483045022100e4d7cc24fe616bed2e0c92cb2ce649f2cd6b67483b93f3d5cb24f2a97a45fe990220734da06b03b9b2303dc980973970d1dd3c7fec9fe244020fb122a1c9c5a9f14c83210272685178dfcb8e4f7ea9e488da690cd82ad9e577109582483cd8fd2e25802f58ffffffff0100000000000000003176a914448d117a6fe4956566000cc2a7b098ce12f592a688ac1673706b71930500000a010000e4800a000000000000007500000000","210a9ff719319dd5f4e60f52ebdd0867ab48c65b760a901753156fa869a362a2",0,{"TWOBHK":1}],"id":1,"chain_name":"aim1"}

{
    "hex" : "0100000002e001f80eae4a0ca7a83fefd890efe97ccd0985b26ce73f054a2a9fd31a44e8ed000000006b483045022100e4d7cc24fe616bed2e0c92cb2ce649f2cd6b67483b93f3d5cb24f2a97a45fe990220734da06b03b9b2303dc980973970d1dd3c7fec9fe244020fb122a1c9c5a9f14c83210272685178dfcb8e4f7ea9e488da690cd82ad9e577109582483cd8fd2e25802f58ffffffffa262a369a86f155317900a765bc648ab6708ddeb520fe6f4d59d3119f79f0a21000000006a473044022008cb24e4ac3d7727fa7fdb3c97883cb82bed7c896f74555b38e285ca26cf33b602205acabcdeb4a7e3bfaf6a009630bd67ee0e154de7b9e44761a6f646766d796e108321026725d370557d3aa957d526db71d2b45108f8774e8ae5cde52a9f743cf9f6fce5ffffffff0200000000000000003176a914448d117a6fe4956566000cc2a7b098ce12f592a688ac1673706b71930500000a010000e4800a000000000000007500000000000000003176a91485772563875e72b69cdd4c962dac5ab3818cd95988ac1673706b71cb5900001c020000748901000000000000007500000000",
    "complete" : true
}
We need to see the literal HTTP payload sent by the library since it's hard to know how to interpret that line you sent. But my guess is you have some extra escaping of quote (") marks which is causing the problem.
Below is the logic I have implemented
def receive():
        from socket import socket, gethostbyname, AF_INET, SOCK_DGRAM
        import sys
        PORT_NUMBER = 5000
        SIZE = 1024

        hostName = gethostbyname( '0.0.0.0' )
        mySocket = socket( AF_INET, SOCK_DGRAM )
        mySocket.bind( (hostName, PORT_NUMBER) )
        print ("Listening....")
        (data,addr) = mySocket.recvfrom(SIZE)
        mySocket.close()
        return (data)


def appendexchange(hex,txnid,v_out,asset):
        rpc_connection.appendrawexchange(hex,txnid,v_out,asset)


#Create locked Transaction
ltxn = '{"Rupees":10}'

unspent=rpc_connection.preparelockunspent(json.loads(ltxn))
#print(unspent)
v_out=unspent['vout']
txnid=unspent['txid']
ti=txnid.encode('ascii','ignore')
print(ti)
print(v_out)


foo = '{"TWOBHK":1}'

print(rpc_connection.appendrawexchange(receive(),ti,v_out,foo))
Thanks but I need to see the actual JSON-RPC request payloads for the two cases.
Sorry not sure ;but is this what is needed ? This is the logic at the other end
def lock_txn():
        ltxn = '{"TWOBHK":1}'
        unspent=rpc_connection.preparelockunspent(json.loads(ltxn))
        print(unspent)
        v_out=unspent['vout']
        txnid=unspent['txid']
        price = '{"Rupees":10}'
        rawexchange=rpc_connection.createrawexchange(txnid,v_out,json.loads(price))
        print("TOKEN IS :"),
        print((rawexchange))
        sendtoken(rawexchange)
lock_txn()
I need you to look into the library you are using, and get it to show the exact payload it is sending in the HTTP request to MultiChain. This will explain the problem.
Although I think the problem may be that you are setting foo as a string rather than a structure, i.e. foo={"TWOBHK":1} rather than foo="{"TWOBHK":1}"
Thank you . Will check and revert
...