Skip to content

Fail gracefully on second channel open attempt #287

Closed
@rustyrussell

Description

@rustyrussell

From #284 we can see things get into a weird state when (understandably!) they try to open a multiple channels to the same peer because one is failing:

root@alibaba:~# lightning-cli getpeers
{ "peers" : 
	[ 
		{ "unique_id" : 0, "state" : "CHANNELD_NORMAL", "netaddr" : "Unknown protocol 0", "peerid" : "0365c02afb409f4571d2962039c8c6e7394c93bc91a9a983c8e8b3dedbf993c8f6", "connected" : false, "channel" : "1196170:6:1", "msatoshi_to_us" : 0, "msatoshi_total" : 10000000000 }, 
		{ "unique_id" : 2, "state" : "OPENINGD", "netaddr" : "Unknown protocol 0", "peerid" : "02028f6eb6852cd153bdd7344d2f6f3d80baeaf5468c8f0fc9f2635461e078a81f", "connected" : false }, 
		{ "unique_id" : 2, "state" : "OPENINGD", "netaddr" : "Unknown protocol 0", "peerid" : "02028f6eb6852cd153bdd7344d2f6f3d80baeaf5468c8f0fc9f2635461e078a81f", "connected" : false }, 
		{ "unique_id" : 1, "state" : "OPENINGD", "netaddr" : "Unknown protocol 0", "peerid" : "02028f6eb6852cd153bdd7344d2f6f3d80baeaf5468c8f0fc9f2635461e078a81f", "connected" : false } ] }
root@alibaba:~# lightning-cli close 02028f6eb6852cd153bdd7344d2f6f3d80baeaf5468c8f0fc9f2635461e078a81f
{  }
root@alibaba:~# lightning-cli close 02028f6eb6852cd153bdd7344d2f6f3d80baeaf5468c8f0fc9f2635461e078a81f
{  }
root@alibaba:~# lightning-cli close 02028f6eb6852cd153bdd7344d2f6f3d80baeaf5468c8f0fc9f2635461e078a81f
{  }
root@alibaba:~# lightning-cli close 02028f6eb6852cd153bdd7344d2f6f3d80baeaf5468c8f0fc9f2635461e078a81f
"Could not find peer with that id"
root@alibaba:~# lightning-cli getpeers
{ "peers" : 
	[ 
		{ "unique_id" : 0, "state" : "CHANNELD_NORMAL", "netaddr" : "Unknown protocol 0", "peerid" : "0365c02afb409f4571d2962039c8c6e7394c93bc91a9a983c8e8b3dedbf993c8f6", "connected" : false, "channel" : "1196170:6:1", "msatoshi_to_us" : 0, "msatoshi_total" : 10000000000 } ] }
root@alibaba:~# lightning-cli connect 47.91.94.194 9735 0365c02afb409f4571d2962039c8c6e7394c93bc91a9a983c8e8b3dedbf993c8f6
{ "id" : "0365c02afb409f4571d2962039c8c6e7394c93bc91a9a983c8e8b3dedbf993c8f6" }
root@alibaba:~# lightning-cli getpeers
{ "peers" : 
	[ 
		{ "unique_id" : 0, "state" : "CHANNELD_NORMAL", "netaddr" : "47.91.94.194:9735", "peerid" : "0365c02afb409f4571d2962039c8c6e7394c93bc91a9a983c8e8b3dedbf993c8f6", "connected" : true, "owner" : "lightning_channeld", "channel" : "1196170:6:1", "msatoshi_to_us" : 0, "msatoshi_total" : 10000000000 } ] }
root@alibaba:~# lightning-cli getnodes
{ "nodes" : 
	[  ] }
root@alibaba:~# lightning-cli dev-ping 0365c02afb409f4571d2962039c8c6e7394c93bc91a9a983c8e8b3dedbf993c8f6 10 10
{ "totlen" : 14 }
root@alibaba:~# lightning-cli getpeers^C
root@alibaba:~# lightning-cli getchannels
{ "channels" : 
	[  ] }
root@alibaba:~# lightning-cli fundchannel 0365c02afb409f4571d2962039c8c6e7394c93bc91a9a983c8e8b3dedbf993c8f6 10000
"Peer not ready for connection"
root@alibaba:~# lightning-cli connect 47.91.94.194 9735 0365c02afb409f4571d2962039c8c6e7394c93bc91a9a983c8e8b3dedbf993c8f6
{ "id" : "0365c02afb409f4571d2962039c8c6e7394c93bc91a9a983c8e8b3dedbf993c8f6" }
root@alibaba:~# lightning-cli fundchannel 0365c02afb409f4571d2962039c8c6e7394c93bc91a9a983c8e8b3dedbf993c8f6 10000
lightning-cli: Connecting to 'lightning-rpc': Connection refused
root@alibaba:~# lightning-cli connect 47.91.94.194 9735 0365c02afb409f4571d2962039c8c6e7394c93bc91a9a983c8e8b3dedbf993c8f6
"Failed to connect to peer"
root@alibaba:~# lightning-cli connect 47.91.94.194 9735 0365c02afb409f4571d2962039c8c6e7394c93bc91a9a983c8e8b3dedbf993c8f6
{ "id" : "0365c02afb409f4571d2962039c8c6e7394c93bc91a9a983c8e8b3dedbf993c8f6" }
root@alibaba:~# lightning-cli fundchannel 0365c02afb409f4571d2962039c8c6e7394c93bc91a9a983c8e8b3dedbf993c8f6 10000
"Peer not ready for connection"
root@alibaba:~# lightning-cli getpeers
{ "peers" : 
	[ 
		{ "unique_id" : 0, "state" : "CHANNELD_NORMAL", "netaddr" : "47.91.94.194:9735", "peerid" : "0365c02afb409f4571d2962039c8c6e7394c93bc91a9a983c8e8b3dedbf993c8f6", "connected" : true, "owner" : "lightning_channeld", "channel" : "1196170:6:1", "msatoshi_to_us" : 0, "msatoshi_total" : 10000000000 }, 
		{ "unique_id" : 3, "state" : "OPENINGD", "netaddr" : "Unknown protocol 0", "peerid" : "02028f6eb6852cd153bdd7344d2f6f3d80baeaf5468c8f0fc9f2635461e078a81f", "connected" : false }, 
		{ "unique_id" : 2, "state" : "OPENINGD", "netaddr" : "Unknown protocol 0", "peerid" : "02028f6eb6852cd153bdd7344d2f6f3d80baeaf5468c8f0fc9f2635461e078a81f", "connected" : false }, 
		{ "unique_id" : 2, "state" : "OPENINGD", "netaddr" : "Unknown protocol 0", "peerid" : "02028f6eb6852cd153bdd7344d2f6f3d80baeaf5468c8f0fc9f2635461e078a81f", "connected" : false }, 
		{ "unique_id" : 1, "state" : "OPENINGD", "netaddr" : "Unknown protocol 0", "peerid" : "02028f6eb6852cd153bdd7344d2f6f3d80baeaf5468c8f0fc9f2635461e078a81f", "connected" : false } ] }
root@alibaba:~# lightning-cli close 02028f6eb6852cd153bdd7344d2f6f3d80baeaf5468c8f0fc9f2635461e078a81f
{  }
root@alibaba:~# lightning-cli getpeers
{ "peers" : 
	[ 
		{ "unique_id" : 0, "state" : "CHANNELD_NORMAL", "netaddr" : "47.91.94.194:9735", "peerid" : "0365c02afb409f4571d2962039c8c6e7394c93bc91a9a983c8e8b3dedbf993c8f6", "connected" : true, "owner" : "lightning_channeld", "channel" : "1196170:6:1", "msatoshi_to_us" : 0, "msatoshi_total" : 10000000000 }, 
		{ "unique_id" : 2, "state" : "OPENINGD", "netaddr" : "Unknown protocol 0", "peerid" : "02028f6eb6852cd153bdd7344d2f6f3d80baeaf5468c8f0fc9f2635461e078a81f", "connected" : false }, 
		{ "unique_id" : 2, "state" : "OPENINGD", "netaddr" : "Unknown protocol 0", "peerid" : "02028f6eb6852cd153bdd7344d2f6f3d80baeaf5468c8f0fc9f2635461e078a81f", "connected" : false }, 
		{ "unique_id" : 1, "state" : "OPENINGD", "netaddr" : "Unknown protocol 0", "peerid" : "02028f6eb6852cd153bdd7344d2f6f3d80baeaf5468c8f0fc9f2635461e078a81f", "connected" : false } ] }
root@alibaba:~# lightning-cli close 02028f6eb6852cd153bdd7344d2f6f3d80baeaf5468c8f0fc9f2635461e078a81f
{  }
root@alibaba:~# lightning-cli getpeers
{ "peers" : 
	[ 
		{ "unique_id" : 0, "state" : "CHANNELD_NORMAL", "netaddr" : "47.91.94.194:9735", "peerid" : "0365c02afb409f4571d2962039c8c6e7394c93bc91a9a983c8e8b3dedbf993c8f6", "connected" : true, "owner" : "lightning_channeld", "channel" : "1196170:6:1", "msatoshi_to_us" : 0, "msatoshi_total" : 10000000000 }, 
		{ "unique_id" : 2, "state" : "OPENINGD", "netaddr" : "Unknown protocol 0", "peerid" : "02028f6eb6852cd153bdd7344d2f6f3d80baeaf5468c8f0fc9f2635461e078a81f", "connected" : false }, 
		{ "unique_id" : 1, "state" : "OPENINGD", "netaddr" : "Unknown protocol 0", "peerid" : "02028f6eb6852cd153bdd7344d2f6f3d80baeaf5468c8f0fc9f2635461e078a81f", "connected" : false } ] }
root@alibaba:~# lightning-cli close 02028f6eb6852cd153bdd7344d2f6f3d80baeaf5468c8f0fc9f2635461e078a81f
{  }
root@alibaba:~# lightning-cli getpeers
{ "peers" : 
	[ 
		{ "unique_id" : 0, "state" : "CHANNELD_NORMAL", "netaddr" : "47.91.94.194:9735", "peerid" : "0365c02afb409f4571d2962039c8c6e7394c93bc91a9a983c8e8b3dedbf993c8f6", "connected" : true, "owner" : "lightning_channeld", "channel" : "1196170:6:1", "msatoshi_to_us" : 0, "msatoshi_total" : 10000000000 }, 
		{ "unique_id" : 1, "state" : "OPENINGD", "netaddr" : "Unknown protocol 0", "peerid" : "02028f6eb6852cd153bdd7344d2f6f3d80baeaf5468c8f0fc9f2635461e078a81f", "connected" : false } ] }
root@alibaba:~# lightning-cli close 02028f6eb6852cd153bdd7344d2f6f3d80baeaf5468c8f0fc9f2635461e078a81f
{  }
root@alibaba:~# lightning-cli getpeers
{ "peers" : 
	[ 
		{ "unique_id" : 0, "state" : "CHANNELD_NORMAL", "netaddr" : "47.91.94.194:9735", "peerid" : "0365c02afb409f4571d2962039c8c6e7394c93bc91a9a983c8e8b3dedbf993c8f6", "connected" : true, "owner" : "lightning_channeld", "channel" : "1196170:6:1", "msatoshi_to_us" : 0, "msatoshi_total" : 10000000000 } ] }
root@alibaba:~# lightning-cli connect 47.91.94.194 9735 0365c02afb409f4571d2962039c8c6e7394c93bc91a9a983c8e8b3dedbf993c8f6
{ "id" : "0365c02afb409f4571d2962039c8c6e7394c93bc91a9a983c8e8b3dedbf993c8f6" }
root@alibaba:~# lightning-cli fundchannel 0365c02afb409f4571d2962039c8c6e7394c93bc91a9a983c8e8b3dedbf993c8f6 10000
"Peer not ready for connection"

Metadata

Metadata

Assignees

Labels

Type::BugAn error, flaw, or fault that produces an incorrect or unexpected result

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions