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

in open_channel in raiden/api/rest.py it allow the user to create a channel without any funds #3022

Closed
Giulio2002 opened this issue Nov 13, 2018 · 4 comments

Comments

@Giulio2002
Copy link
Contributor

Giulio2002 commented Nov 13, 2018

Scenario

i have no W-Eth and no unsettled channels as well. Therefore i can't join W-Eth token network.
i try to create a channel anyway with:

curl -i -X PUT http://localhost:5001/api/1/channels -H 'Content-Type: application/json' --data-raw '{"partner_address": "0x61C808D82A3Ac53231750daDc13c777b59310bD9", "settle_timeout": 500, "token_address": "0xc778417E063141139Fce010982780140Aa0cD5Ab", "total_deposit": 5000000}'

obviously i have 0 W-Eth, so i get this error:

Not enough balance to deposit. c778417e Available=0 Needed=5000000

despite the error if we execute

curl -i http://localhost:5001/api/1/channels

and then we can see from the output that a channel have been created and that we have been joined automatically the token Network W-Eth without any funds in it.

[{
state: 'opened',
    total_deposit: 0,
    partner_address: 0x61C808D82A3Ac53231750daDc13c777b59310bD9',
    settle_timeout: 500,
    token_network_identifier: '0xa1DE2cD74eFE0EDa3989aa6C1fa3B632927770A8',
    balance: 0,
    reveal_timeout: 50,
    channel_identifier: 31,
    token_address: '0xc778417E063141139Fce010982780140Aa0cD5Ab' }]
@Giulio2002
Copy link
Contributor Author

Giulio2002 commented Nov 13, 2018

i made also a pr that solve this bug if you want you can look at it:

@LefterisJP
Copy link
Contributor

Hello @Giulio2002. Thanks for the report.

I think you are correct in thinking this is a bug.

What happens is that:

  1. We combine the channel open and deposit in one call of the REST API
  2. First channel open happens
  3. Then deposit happens. The balance check is only made during deposit.

It would make sense to have a balance check at the rest api level before even allowing to open a channel. I will comment on your PR.

@Giulio2002
Copy link
Contributor Author

@Giulio2002 Giulio2002 reopened this Nov 14, 2018
@Giulio2002
Copy link
Contributor Author

#3023

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

No branches or pull requests

2 participants