Skip to content

Fundchannel: extend fundchannel_cancel to work before funding broadcast#3006

Merged
niftynei merged 9 commits into
ElementsProject:masterfrom
trueptolemy:fundchannel_cancel_extend
Sep 11, 2019
Merged

Fundchannel: extend fundchannel_cancel to work before funding broadcast#3006
niftynei merged 9 commits into
ElementsProject:masterfrom
trueptolemy:fundchannel_cancel_extend

Conversation

@trueptolemy
Copy link
Copy Markdown
Contributor

@trueptolemy trueptolemy commented Aug 28, 2019

Fix #2740
This PR try to make fundchannel_cancel can work after fundchannel_complete and before funding broadcast.

Process

The extended process is:
For funder:

  • At the first, funder used funderchannel_complete;
  • Then funder calls funderchannel_cancel:
    • funder check if the fundchannel process completed ==>
    • If completed, funder check if its clightning has broadcast the funding and check if the funding has been onchain ==>
    • If these 2 check pass, funder ask its channeld send a error message to fundee ==>
    • After sending error message, the funder delete(forget) the channel(also delete the peer, it's the limit of delete_channel())

For fundee:

  • After funder's funderchannel_complete, the channel state is AWAITING_LOCKIN. And the fundee begin to wait for funding locked both locally and remotely
  • During AWAITING_LOCKIN, when fundee receives the error message from funder, fundee will delete(forget) the channel(also delete the peer, because of the limit of notify_disconnect when remote peer sends error? #2741 )

Limits

But here's also some limits:

  • The check for funding broadcast can't completely ensure that the funding transaction isn't broadcast. We can't know the case if the funding is broadcast by external wallet but the transaction hasn't been onchain.
    This also ask caller to use fundchannel_cancel correctly: must be before funding broadcast.
  • If fundchannel_cancel is called after fundchannel_complete and we cancel the channel successfully. Then we must reconnect with the remote peer before fundchannel_start again.
    Like notify_disconnect when remote peer sends error? #2741 said, when the peer receive error message or when the peer deletes the channels, the peer will disconnect with the remote peer.
    The main reason for this is channel_set_owner(channel, NULL, false) moves responsibility for the connection to connectd not openingd. If we want to keep connection, rolling back from channeld to openingd is necessary.

Open Question

In f77d6c7 (Fix: Store the transaction(broadcast by txsend) into DB), I add the label TX_UNKNOWN
for the transaction broadcast by txsend.
I think maybe we can add optional string field for txsend command to specific the label. What do you think about it?

Unfinished

  • Update document

  • Add CHANGELOG

Note: 9ebb521 is duplicated with a commit of #2964 , just for making travis-ci happy

Thanks for @ZmnSCPxj and @niftynei's explanation, direction and help!

Copy link
Copy Markdown
Contributor

@ZmnSCPxj ZmnSCPxj left a comment

Choose a reason for hiding this comment

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

Looks OK to me, please just add documentation.

@trueptolemy
Copy link
Copy Markdown
Contributor Author

@ZmnSCPxj Thank you! Now I complete the document.

Comment thread doc/lightning-fundchannel_cancel.7.md Outdated
Comment thread doc/lightning-fundchannel_cancel.7.md Outdated
@trueptolemy trueptolemy force-pushed the fundchannel_cancel_extend branch from c20d47d to 5c4c68b Compare August 29, 2019 14:17
Comment thread tests/test_connection.py
@trueptolemy trueptolemy force-pushed the fundchannel_cancel_extend branch 5 times, most recently from f4eb879 to 6d4a303 Compare September 6, 2019 15:07
@trueptolemy trueptolemy requested a review from niftynei September 6, 2019 19:07
@trueptolemy
Copy link
Copy Markdown
Contributor Author

Add the check that the tx broadcast by bitcoind can be catched.

@trueptolemy trueptolemy force-pushed the fundchannel_cancel_extend branch 2 times, most recently from ea84584 to 81570e8 Compare September 10, 2019 18:58
@trueptolemy trueptolemy force-pushed the fundchannel_cancel_extend branch from 81570e8 to 67c15a5 Compare September 11, 2019 08:01
@trueptolemy
Copy link
Copy Markdown
Contributor Author

Rebased and resolved the conflict.

@niftynei
Copy link
Copy Markdown
Collaborator

ack 67c15a5

@niftynei niftynei merged commit 8d28e52 into ElementsProject:master Sep 11, 2019
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

Successfully merging this pull request may close these issues.

Feature: Cancel a fundchannel_started channel after fundchannel_complete

3 participants