Skip to content

warnet bitcoin rpc should handle JSON params better #714

@pinheadmz

Description

@pinheadmz
$ warnet bitcoin rpc tank-0000 getnetmsgstats '["network"]'

error: Error parsing JSON: [network]
command terminated with exit code 1

We could be smarter how we parse these arguments so users don't have to escape all the quotes. I've also notice that spaces in JSON ( '["network", "message_type"]') can get interpreted as separate arguments and fail. Maybe we should try to detect JSON in the entire rpc string before chopping it up:

@bitcoin.command(context_settings={"ignore_unknown_options": True})
@click.argument("tank", type=str)
@click.argument("method", type=str)
@click.argument("params", type=str, nargs=-1) # this will capture all remaining arguments
@click.option("--namespace", default=None, show_default=True)
def rpc(tank: str, method: str, params: str, namespace: Optional[str]):
"""
Call bitcoin-cli <method> [params] on <tank pod name>
"""
try:
result = _rpc(tank, method, params, namespace)
except Exception as e:
print(f"{e}")
sys.exit(1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions