/**
 * Query for the number of confirmations a transaction has.
 * @param txid The transaction id to check for.
 * @return Number of confirmations the transaction has.
 * @throws JsonRpc::RpcError if the tx is not found.
 */
unsigned
CoinInterface::getNumberOfConfirmations (const std::string& txid)
{
  const JsonRpc::JsonData res = rpc.executeRpc ("gettransaction", txid);
  assert (res.isObject ());

  return res["confirmations"].asInt ();
}
int
main ()
{
  RpcSettings settings;
  settings.readDefaultConfig ();
  JsonRpc rpc(settings);

  JsonRpc::JsonData res = rpc.executeRpc ("getinfo");
  assert (res.isObject ());
  std::cout << "Running version: " << res["version"].asInt () << std::endl;

  res = rpc.executeRpc ("name_show", "id/domob");
  assert (res.isObject ());
  assert (res["name"].asString () == "id/domob");
  assert (res["value"].isString ());
  assert (res["expires_in"].isInt ());

  try
    {
      rpc.executeRpc ("method-does-not-exist", 5, "");
      assert (false);
    }
  catch (const JsonRpc::RpcError& err)
    {
      assert (err.getErrorCode () == -32601);
    }

  try
    {
      rpc.executeRpc ("name_history", "name-does-not-exist");
      assert (false);
    }
  catch (const JsonRpc::RpcError& err)
    {
      assert (err.getErrorCode () == -4);
    }

  return EXIT_SUCCESS;
}