rpc+contractcourt: merge the contractResolver state into the pendingchannels RPC response #1875
I'd like to pick this back up, with the exclusion of the commit to detect spends in the nursery. Since then, we've created the Sweeper which itself will handle this notification case. It still stands that as is, the API is blind to these HTLCs that haven't yet timed out causing much user confusion and an inability to properly track all funds throughout the timeout cycle. Even after the new sweeper changes have been merged, we'll still need this for the lifetime that the current nursery exists (and the resolvers will still report directly back to the API).
Some observations on the current reporting situation:
Is this the desired behaviour? Ideally I think you'd want to see:
Yes we atm we only record the fully settled amount, as depending on a number of parameters (if it's batched, the fee rate, etc) we may actually sweep less than the total amount settled at closing time.
We report the CSV outputs, and HTLC outputs as they transition from stage 1 to stage 2. We also report the total limbo balance, and the amount of coins recovered at that given instance.
Yep, it's part of the base report. Only once all the outputs that were created by a channel have been resolved do we no longer report on it.
Agree this would be a good addition in order to ensure users have access to this data without doing any manual block chain crawling. I think it's out of the scope for this PR though, which should be focused on fixing the egregious blind spots.
All this but chain fees and the non delay output are already reported. Agree it would be nice to also show the confirmation status of the non-delay output as well. I don't think this would expand the scope of this PR too significantly, as arguably it's a blind spot in the current report and confirmations can take some time on mainnet.
Yeah we also have this issue where we want to account for the full amount recovered when we need to claim HTLCs on chain. I think this can be deferred from this PR and either picked up in #2075, or a sort of "fee report" message that can be requested from the sweeper (new PR all together).
We can still write the close summary as soon as we detect a channel close, but then update the fields as we go.
Yeah so we'd basically progressively move over this state from the nursery over to the main channel arb.
I think the first step would be to ensure we report (via the resolver) the state of the HTLCs that haven't yet timed out. Once they timeout, they get handed off to the nursery and can be reported externally as part of the regular nursery report. Next would be to report the state of the non-delay output while it hasn't yet been fully swept. After that we'd start to store within the channel arb's log the finalized state of all resolved contracts. The final step would then be moving all accounting from the
Nice work! I like the little fix ups and refactoring along the way. No major comments, mostly style related nits. Happy to have this hole patched before we continue to overhaul the resolvers to communicate directly with the sweeper.
Previously the arbitrator wasn't advanced to the final stage after the last contract resolved. Also channel arbitrator now does not ignore a log error anymore unresolved contracts cannot be retrieved.
In this commit we fix a reporting gap that previously existed for htlcs that were still contested.