Conversation
753acf6 to
b44be37
Compare
NishantBansal2003
left a comment
There was a problem hiding this comment.
I think this needs to be rebased on top of #162 to consume the affine type SentShutdown
morehouse
left a comment
There was a problem hiding this comment.
I think we want the affine type wired in for sure.
But that probably isn't enough -- we can't expect the target to send us a shutdown message until all HTLCs have been resolved as well. There's also probably a case where we could send two shutdown messages and the target may ignore any of them after the first one.
I think for the HTLCs we can't really implement that part until #111 is implemented, so we can just add a TODO for that.
For the duplicate shutdown case we could probably add a flag to the channel state that indicates whether the peer has already responded to the first shutdown, and if they have then any subsequent RecvShutdown message becomes a no-op (similar to RecvChannelReady).
b44be37 to
7c5f9fc
Compare
bc867ba to
77cf4f8
Compare
Added TODOs in 77cf4f8. I thought it would be useful to group all HTLC TODOs together with
We now check in 77cf4f8 if we expect a shutdown on any channel. Only then we wait for a shutdown response. We don't know on which channel we will receive a shutdown, but I could change TODO:
Mhh, I wonder if there's a conflict between this (#163 (comment)):
and this (#163 (review)):
In 77cf4f8, |
2a50e89 to
d083969
Compare
I forgot tests for |
f399f63 to
74b38b0
Compare
|
This is ready for review now. I'm working on a new PR with a |
|
This PR has grown a bit. @ekzyis would it be possible to split this into smaller PRs? Perhaps something like this:
|
74b38b0 to
fd0bbbb
Compare
|
fd0bbbb: rebased on master (dc2ef28) and only includes the new FYI, this question in #163 (comment) is still open for me:
But I think it's more relevant when we start consuming the output of |
RecvShutdown consumes the SentShutdown of a previous SendShutdown, which now carries the `shutdown` we sent, and waits for the target's `shutdown` in reply. It returns the target's scriptpubkey, or empty bytes if no `shutdown` was received. If our own scriptpubkey isn't standard, BOLT 2 says the target should send a warning instead of replying, so we accept a warning for the channel as a reply. A `shutdown` for another channel may answer one we sent there earlier, which we can't check against the `shutdown` we sent here, so it ends the program as an unexpected message. RecvShutdown is a no-op if we don't track the channel or the target already replied. Before the target sent `channel_ready`, it may choose not to reply, but we still expect one: LDK always replies, and a target that doesn't only costs us a receive timeout, which isn't reported as a violation.
fd0bbbb to
8d65b49
Compare
|
8d65b49: add |
This implements the
RecvShutdownoperation for #98.RecvShutdownconsumes theSentShutdownof a previousSendShutdown, which now carries theshutdownwe sent, and waits for the target'sshutdownin reply. It returns the target's scriptpubkey, or empty bytes if noshutdownwas received.The reply is checked by a new
ShutdownOracle. It flags the target if:upfront_shutdown_scriptwe committed to andoption_upfront_shutdown_scriptwas negotiated, so the target must fail the connection instead of replyingupfront_shutdown_scriptit committed to, or isn't a standard form for the negotiated featuresIf our own scriptpubkey isn't standard, BOLT 2 says the target should send a warning instead of replying. If it breaks our
upfront_shutdown_script, the target may send a warning before failing the connection. In both cases we accept a warning for the channel as a reply.A
shutdownfor another tracked channel may answer one we sent there earlier, which we can't check against theshutdownwe sent here, so it ends the program as an unexpected message.RecvShutdownis a no-op if we don't track the channel or the target already replied. Before the target sentchannel_ready, it may choose not to reply, but we still expect one: LDK always replies, and a target doesn't only costs us a receive timeout, which isn't reported as a violation.