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

setchannelfee: fix crash when channel is not in valid state. #4282

Merged

Conversation

rustyrussell
Copy link
Contributor

You can't fail a cmd when you've already started streaming
a successful response:

lightningd: ccan/ccan/json_out/json_out.c:343: json_out_finished: Assertion `tal_count(jout->wrapping) == 0' failed.
lightningd: FATAL SIGNAL 6 (version v0.9.2-119-gf7cdf1d)
0x1847d1 send_backtrace
common/daemon.c:38
0x184877 crashdump
common/daemon.c:51
0x5bda03f ???
???:0
0x5bd9fb7 ???
???:0
0x5bdb920 ???
???:0
0x5bcb489 ???
???:0
0x5bcb501 ???
???:0
0x1e07a8 json_out_finished
ccan/ccan/json_out/json_out.c:343
0x18db0a json_stream_double_cr
common/json_stream.c:95
0x18dbf3 json_stream_close
common/json_stream.c:117
0x12fd98 command_raw_complete
lightningd/jsonrpc.c:459
0x12fec9 command_failed
lightningd/jsonrpc.c:488
0x12ffb9 command_fail
lightningd/jsonrpc.c:503
0x14dc20 json_setchannelfee
lightningd/peer_control.c:2052

Signed-off-by: Rusty Russell rusty@rustcorp.com.au
Changelog-Fixed: JSONRPC: setchannelfee would fail an assertion if channel wasn't in normal state.

You can't fail a cmd when you've already started streaming
a successful response:

lightningd: ccan/ccan/json_out/json_out.c:343: json_out_finished: Assertion `tal_count(jout->wrapping) == 0' failed.
lightningd: FATAL SIGNAL 6 (version v0.9.2-119-gf7cdf1d)
0x1847d1 send_backtrace
	common/daemon.c:38
0x184877 crashdump
	common/daemon.c:51
0x5bda03f ???
	???:0
0x5bd9fb7 ???
	???:0
0x5bdb920 ???
	???:0
0x5bcb489 ???
	???:0
0x5bcb501 ???
	???:0
0x1e07a8 json_out_finished
	ccan/ccan/json_out/json_out.c:343
0x18db0a json_stream_double_cr
	common/json_stream.c:95
0x18dbf3 json_stream_close
	common/json_stream.c:117
0x12fd98 command_raw_complete
	lightningd/jsonrpc.c:459
0x12fec9 command_failed
	lightningd/jsonrpc.c:488
0x12ffb9 command_fail
	lightningd/jsonrpc.c:503
0x14dc20 json_setchannelfee
	lightningd/peer_control.c:2052

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: JSONRPC: `setchannelfee` would fail an assertion if channel wasn't in normal state.
Copy link
Collaborator

@m-schmoock m-schmoock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 93e2b19

That is correct.
I wrote a testcase that checks for this. Feel free to add it to tests/test_pay.py.
It also checks that channel lookup by channel_id is possible, which was uncovered before.

def test_setchannelfee_closed(node_factory, bitcoind):
    l1, l2 = node_factory.line_graph(2)
    # We use the `channel_id` (not scid) by intention
    # to also test channel lookup using `channel_id`.
    cid = l1.get_channel_id(l2)
    l2.stop()
    l1.rpc.close(cid, 1)
    with pytest.raises(RpcError, match="Channel is in state AWAITING_UNILATERAL"):
        l1.rpc.setchannelfee(cid, 12, 34)

Copy link
Collaborator

@darosior darosior left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 93e2b19

@niftynei niftynei merged commit eb4062b into ElementsProject:master Dec 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants