4
« on: July 30, 2018, 02:30:41 pm »
I've built a website that's utilizing the python-bitshares. The first request is always successful, example: /buy/bts?amount=10 generates an RPC request similar to the one below. Notice, there is only one item inside the signatures list:
{'method': 'call', 'params': ['network_broadcast', 'broadcast_transaction', [{'expiration': '2018-....', 'ref_block_num': 14306, 'ref_block_prefix': 8....., 'operations': [[2, {'fee': {'amount': 57, 'asset_id': '1.3.0'}, 'fee_paying_account': '1.2.8...', 'order': '1.7.1....', 'extensions': []}]], 'extensions': [], 'signatures': ['201...']}]], 'jsonrpc': '2.0', 'id': 12}
The second request (e.g. /cancel/order?id=$ID) fails with the following error:
File "/home/www/venv/lib/python3.6/site-packages/bitshares/market.py", line 526, in cancel
return self.bitshares.cancel(orderNumber, account=account)
File "/home/www/venv/lib/python3.6/site-packages/bitshares/bitshares.py", line 1170, in cancel
return self.finalizeOp(op, account["name"], "active", **kwargs)
File "/home/www/venv/lib/python3.6/site-packages/bitshares/bitshares.py", line 261, in finalizeOp
return self.txbuffer.broadcast()
File "/home/www/venv/lib/python3.6/site-packages/bitshares/transactionbuilder.py", line 381, in broadcast
raise e
File "/home/www/venv/lib/python3.6/site-packages/bitshares/transactionbuilder.py", line 379, in broadcast
ret, api="network_broadcast")
File "/home/www/venv/lib/python3.6/site-packages/grapheneapi/graphenewsrpc.py", line 206, in method
r = self.rpcexec(query)
File "/home/www/venv/lib/python3.6/site-packages/bitsharesapi/bitsharesnoderpc.py", line 56, in rpcexec
raise exceptions.UnhandledRPCError(msg)
bitsharesapi.exceptions.UnhandledRPCError: irrelevant signature included: Unnecessary signature(s) detected
The RPC call looks similar to this, this time notice two signatures inside the list:
{'method': 'call', 'params': ['network_broadcast', 'broadcast_transaction', [{'expiration': '2018-....', 'ref_block_num': 14306, 'ref_block_prefix': 8....., 'operations': [[2, {'fee': {'amount': 57, 'asset_id': '1.3.0'}, 'fee_paying_account': '1.2.8...', 'order': '1.7.1....', 'extensions': []}]], 'extensions': [], 'signatures': ['201...', '202...']}]], 'jsonrpc': '2.0', 'id': 12}
If I restart the web server and call the second request (/cancel/order?id=$ID) again, everything works. So basically, I can send make one transaction per webserver restart :-/
My theory is that the BitShares instance or the shared_bitshares_instance is caching something related to the signatures. I'm always using a new bitshares instace for each "transaction" (buy/sell/transfer..). I've tried calling bitshares.clear() and other things - but without luck.
One important thing to mention is that I'm creating the BitShares instance using the keys params, and do therefore not use the sqlite database. But this shouldn't affect things.
Any ideas how I can resolve this?