Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #2384

Closed
wants to merge 5 commits into from
Closed

Fixes #2384

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions counterparty-core/counterpartycore/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def float_range_checker(arg):
[
("--rpc-host",),
{
"default": "localhost",
"default": "127.0.0.1",
"help": "the IP of the interface to bind to for providing JSON-RPC API access (0.0.0.0 for all interfaces)",
},
],
Expand Down Expand Up @@ -191,7 +191,7 @@ def float_range_checker(arg):
[
("--api-host",),
{
"default": "localhost",
"default": "127.0.0.1",
"help": "the IP of the interface to bind to for providing API access (0.0.0.0 for all interfaces)",
},
],
Expand Down
4 changes: 3 additions & 1 deletion counterparty-core/counterpartycore/lib/api/api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,9 @@ def handle_route(**kwargs):
message += f" - Response {result.status_code}"
message += f" - {int((time.time() - start_time) * 1000)}ms"
logger.debug(message)
return result.content, result.status_code, result.headers.items()
headers = dict(result.headers)
del headers["Connection"] # remove "hop-by-hop" headers
return result.content, result.status_code, headers

# clean up and return the result
if result is None:
Expand Down
4 changes: 2 additions & 2 deletions counterparty-core/counterpartycore/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def initialise_config(
if rpc_host:
config.RPC_HOST = rpc_host
else:
config.RPC_HOST = "localhost"
config.RPC_HOST = "127.0.0.1"

# The web root directory for API calls, eg. localhost:14000/rpc/
config.RPC_WEBROOT = "/rpc/"
Expand Down Expand Up @@ -415,7 +415,7 @@ def initialise_config(
if api_host:
config.API_HOST = api_host
else:
config.API_HOST = "localhost"
config.API_HOST = "127.0.0.1"

# Server API port
if api_port:
Expand Down
2 changes: 1 addition & 1 deletion counterparty-core/counterpartycore/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def api_server_v2(request, cp_server):
"zmq_publisher_port": None,
"db_connection_pool_size": None,
"json_logs": False,
"wsgi_server": "werkzeug",
"wsgi_server": "waitress",
"gunicorn_workers": 2,
}
server_config = (
Expand Down
46 changes: 46 additions & 0 deletions counterparty-core/counterpartycore/test/regtest/testscenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,50 @@ def run_item(node, item, context):
return context


def rpc_call(command, params=None):
if params is None:
params = []
curl_client = sh.curl.bake(
"-X",
"POST",
"http://localhost:24000/v1/",
"-H",
"Content-Type: application/json; charset=UTF-8",
"-H",
"Accept: application/json, text/javascript",
"--data-binary",
)
query = {
"method": command,
"params": params,
"jsonrpc": "2.0",
"id": 0,
}
result = json.loads(curl_client(json.dumps(query)).strip())
return result


def check_api_v1(node):
running_info = rpc_call("get_running_info")

if not running_info["result"]["server_ready"]:
raise Exception("Server not ready")
if not running_info["result"]["db_caught_up"]:
raise Exception("DB not caught up")

tx = rpc_call(
"create_send",
{
"source": node.addresses[0],
"destination": node.addresses[1],
"asset": "XCP",
"quantity": 1,
},
)
# check that the hex transaction is generated
int(tx["result"], 16)


def run_scenarios(serve=False, wsgi_server="gunicorn"):
try:
regtest_node_thread = RegtestNodeThread(wsgi_server=wsgi_server)
Expand All @@ -247,6 +291,8 @@ def run_scenarios(serve=False, wsgi_server="gunicorn"):

context = {}

check_api_v1(regtest_node_thread.node)

# run all scenarios
for item in SCENARIOS:
context = run_item(regtest_node_thread.node, item, context)
Expand Down
29 changes: 29 additions & 0 deletions release-notes/release-notes-v10.4.7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Release Notes - Counterparty Core v10.4.7 (2024-10-17)

This is a Hotfix release to fix API v1 with Waitress.

# Upgrading

# ChangeLog

## Bugfixes

- Fix API v1 with Waitress (remove hop-by-hop headers)

## Codebase

- Check API v1 in regtest test suite

## API

- Use `120.0.0.1` instead `localhost` as default for `API_HOST` and `RPC_HOST` (to force IPv4)

## CLI



# Credits

* Ouziel Slama
* Warren Puffett
* Adam Krellenstein
Loading