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

Plugin isn't working properly #22

Open
dancingsushii opened this issue Nov 7, 2022 · 1 comment
Open

Plugin isn't working properly #22

dancingsushii opened this issue Nov 7, 2022 · 1 comment

Comments

@dancingsushii
Copy link

Hi! First of all, many thanks for this useful project!

I am now trying to execute this plugin on one of the spawned nodes with various channels and getting the following error:

{
   "code": -32600,
   "message": "Error while processing rebalanceall: int() argument must be a string, a bytes-like object or a number, not 'dict'",
   "traceback": "Traceback (most recent call last):\n  File \"/usr/local/lib/python3.9/dist-packages/pyln/client/plugin.py\", line 639, in _dispatch_request\n    result = self._exec_func(method.func, request)\n  File \"/usr/local/lib/python3.9/dist-packages/pyln/client/plugin.py\", line 616, in _exec_func\n    ret = func(*ba.args, **ba.kwargs)\n  File \"/root/run/plugins/rebalance/rebalance.py\", line 677, in rebalanceall\n    channels = get_open_channels(plugin)\n  File \"/root/run/plugins/rebalance/rebalance.py\", line 415, in get_open_channels\n    for peer in plugin.rpc.listpeers()[\"peers\"]:\n  File \"/usr/local/lib/python3.9/dist-packages/pyln/client/lightning.py\", line 999, in listpeers\n    return self.call(\"listpeers\", payload)\n  File \"/usr/local/lib/python3.9/dist-packages/pyln/client/lightning.py\", line 384, in call\n    resp, buf = self._readobj(sock, buf)\n  File \"/usr/local/lib/python3.9/dist-packages/pyln/client/lightning.py\", line 312, in _readobj\n    obj, _ = self.decoder.raw_decode(parts[0].decode(\"UTF-8\"))\n  File \"/usr/lib/python3.9/json/decoder.py\", line 353, in raw_decode\n    obj, end = self.scan_once(s, idx)\n  File \"/usr/local/lib/python3.9/dist-packages/pyln/client/lightning.py\", line 494, in millisatoshi_hook\n    obj = LightningRpc.LightningJSONDecoder.replace_amounts(obj)\n  File \"/usr/local/lib/python3.9/dist-packages/pyln/client/lightning.py\", line 485, in replace_amounts\n    obj[k] = Millisatoshi(v)\n  File \"/usr/local/lib/python3.9/dist-packages/pyln/client/lightning.py\", line 70, in __init__\n    elif int(v) == v:\nTypeError: int() argument must be a string, a bytes-like object or a number, not 'dict'\n"
}

I have previously used this plugin on both testnet and mainnet networks, and it worked fine. The plugin itself is installed correctly, I guess there's some kind of error in the environment?

The entry point is in this plugin call.

def get_open_channels(plugin: Plugin):
    channels = []
    for peer in plugin.rpc.listpeers()["peers"]:
        for ch in peer["channels"]:
            if ch["state"] == "CHANNELD_NORMAL" and not ch["private"]:
                channels.append(ch)
    return  

And leads to this method in lightning.py

    def listpeers(self, peerid=None, level=None):
        """
        Show current peers, if {level} is set, include {log}s".
        """
        payload = {
            "id": peerid,
            "level": level,
        }
        return self.call("listpeers", payload)

Thank you very much in advance for your help!

@kostjaigin
Copy link

kostjaigin commented Nov 20, 2022

@cmdruid I am facing a very similar issue when simply trying to call listpeers from my own plugin:

plugin.log("Trying to execute listpeers")
peers = plugin.rpc.listpeers()

also returns the same error...:

{
   "code": -32600,
   "message": "Error while processing start_test: int() argument must be a string, a bytes-like object or a number, not 'dict'",
   "traceback": "Traceback (most recent call last):
File \"/usr/local/lib/python3.9/dist-packages/pyln/client/plugin.py\", line 639, in _dispatch_request
result = self._exec_func(method.func, request)
File \"/usr/local/lib/python3.9/dist-packages/pyln/client/plugin.py\", line 616, in _exec_func
ret = func(*ba.args, **ba.kwargs)
File \"/root/run/plugins/test/test.py\", line 276, in start_test
peers = plugin.rpc.listpeers()
File \"/usr/local/lib/python3.9/dist-packages/pyln/client/lightning.py\", line 999, in listpeers
return self.call(\"listpeers\", payload)
File \"/usr/local/lib/python3.9/dist-packages/pyln/client/lightning.py\", line 384, in call
resp, buf = self._readobj(sock, buf)
File \"/usr/local/lib/python3.9/dist-packages/pyln/client/lightning.py\", line 312, in _readobj\n    obj, _ = self.decoder.raw_decode(parts[0].decode(\"UTF-8\"))
File \"/usr/lib/python3.9/json/decoder.py\", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
File \"/usr/local/lib/python3.9/dist-packages/pyln/client/lightning.py\", line 494, in millisatoshi_hook
obj = LightningRpc.LightningJSONDecoder.replace_amounts(obj)
File \"/usr/local/lib/python3.9/dist-packages/pyln/client/lightning.py\", line 485, in replace_amounts
obj[k] = Millisatoshi(v)
File \"/usr/local/lib/python3.9/dist-packages/pyln/client/lightning.py\", line 70, in __init__
elif int(v) == v:
TypeError: int() argument must be a string, a bytes-like object or a number, not 'dict'"
}

And normal shell-based RPC call via container lcli listpeers works fine at all stages. I thought there is some problem with versions, but I also faced this issue only with workbench. Mb something comes up to your mind?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants