When it’s all good you’ll get meaningful errors or method not found
which of course means you’re using a wrong method (or wrong API, for example counterblock instead of counterparty).
Other times something else is wrong and I want to figure out why.
The logging is configured in counterpartylib/lib/log.py
. I can configure the requests library to propagate logs to counterparty-lib and then run counterparty-server with --verbose
to turn on debugging.
requests_log = logging.getLogger("requests")
requests_log.setLevel(log_level)
requests_log.propagate = True
urllib3_log = logging.getLogger('urllib3')
urllib3_log.setLevel(log_level)
urllib3_log.propagate = True
That gives us a bit more info in counterparty-server’s server.log, but still not enough to see exactly what the hell is going on with the method that’s “not found”.
Next, I try counterparty-lib-master/counterpartylib/lib/api.py
.
def init_api_access_log(app):
"""Initialize API logger."""
loggers = (logging.getLogger('werkzeug'), app.logger)
log.setLevel(logging.DEBUG)
log.addHandler(handler)
I rebuild the code and start server.
I capture network packets on the loopback interface and voila, the trace is here!
{
"method": "create_destroy",
"params": {
"encoding": "auto",
"op_return_value": 0,
"multisig_dust_size": 7799,
"pubkey": ["0265f9763ea8f857571a003a9c7abddc9875a3dd921dbdb15c1659944869f945cd"],
"regular_dust_size": 5429,
"disable_utxo_locks": false,
"allow_unconfirmed_inputs": true,
"fee_per_kb": 25000,
"source": "n4D7ndiC4yLZxhAf726uMHXC914sEuUAcg",
"quantity": 10000,
"dust_return_pubkey": null,
"fee": null,
"asset": "XCP",
"tag": ""
},
"jsonrpc": "2.0",
"id": 0
}
So what is the problem?
It seems that create_destroy
method really does not exist! (see http://counterparty.io/docs/api/#actionwrite-api-function-reference). I should have checked this document first, but I was focusing on debugging the client, assuming that the API is there.
And yesterday I was told the destroy action in the counterparty-client calls the CP (asset) destroy method and that destructions table in Counterparty Sqlite3 DB is empty because no one has used the API on mainnet.
It took me only 3 hours of searching in wrong places to find the truth :-). It now seems that one uses the API because it’s not there.