Skip to content

Add devtools/mkpoint#3115

Closed
Sjors wants to merge 1 commit into
ElementsProject:masterfrom
Sjors:2019/09/mkpoint
Closed

Add devtools/mkpoint#3115
Sjors wants to merge 1 commit into
ElementsProject:masterfrom
Sjors:2019/09/mkpoint

Conversation

@Sjors
Copy link
Copy Markdown
Contributor

@Sjors Sjors commented Sep 29, 2019

Tool to dump a channel commitment point, useful for recovering funds.

It takes the following arguments:

  • node id (the public key of the other peer)
  • channel database id (see chan # entries in log)
  • commit_num: 0 for a freshly opened channel

For some reason hsmd.c doesn't have a header file, so I'm confused how to properly call its functions.

Background: https://bitcoin.stackexchange.com/questions/90196/how-to-recover-funds-from-a-force-closed-lnd-lightning-channel

@Sjors
Copy link
Copy Markdown
Contributor Author

Sjors commented Sep 29, 2019

From re-reading IRC I suspect I also need to mix in hsm_secret somewhere in this process.

@darosior
Copy link
Copy Markdown
Contributor

For some reason hsmd.c doesn't have a header file, so I'm confused how to properly call its functions.

You can use it as a subdaemon (as lightningd does) and use the autogenerated wire functions to request sigs. See lightningd/hsm_control.h.

From re-reading IRC I suspect I also need to mix in hsm_secret somewhere in this process.

Yep, it contains the bip32 master key, but it's handled by hsmd.

@Sjors
Copy link
Copy Markdown
Contributor Author

Sjors commented Sep 30, 2019

So what would be the right approach to dump a per-commitment point? Should I make devtools/mkpoint spin up an hsmd daemon and then talk to it? Or is it better to add a developer RPC call? Or a plugin?

@darosior
Copy link
Copy Markdown
Contributor

I'd go for spinning up hsmd as a subdaemon, however that's the path I know the less about so I might be wrong.
A plugin would need a hook or notification, I don't think that fits your need here.
A dev RPC call might be a good solution too if the channel is still active, to use when lightningd is running. However, as I think I read on IRC, this was to recover the points directly from the database file ? In this case an independent tool seems more appropriate.

@Sjors
Copy link
Copy Markdown
Contributor Author

Sjors commented Sep 30, 2019

The channel I need this for is long closed and pruned from listfunds. I assume it's not even in the database file, but it can still be reconstructed using the information I got from the logs.

@Sjors
Copy link
Copy Markdown
Contributor Author

Sjors commented Oct 18, 2019

It works now! I probably don't have time or skills to clean up this PR though... @darosior would it make sense to combine this with #3177?

@darosior
Copy link
Copy Markdown
Contributor

darosior commented Oct 18, 2019

@Sjors I wonder for the same reasons I wonder moving @rustyrussell signmessage and checkmessage to hsmtools (cf #3177)..

EDIT: After talking about it with ZmnSCPxj and cdecker it does not seem to be a good idea. I think I'll integrate it to the hsmtools though.

@Sjors
Copy link
Copy Markdown
Contributor Author

Sjors commented Oct 22, 2019

Closing in favor of #3186 which introduces the equivalent: tools/hsmtools dumpcommitments NODE_PUBKEY DB_INDEX COMMITMENT_INDEX

@Sjors Sjors closed this Oct 22, 2019
@Sjors Sjors deleted the 2019/09/mkpoint branch October 22, 2019 13:56
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.

2 participants