lightninglabs / lightninglabs/chantools

chantools forceclose --channeldb crashes on taproot channels: malformed signature: no header magic

Open
#108 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
239
Forks
46
Avg merge
1d 6h
Merged PRs (30d)
6

Description

## Problem

I stopped LND and ran the following command:

```
$ chantools --testnet forceclose --channeldb ./.lnd/data/graph/testnet/channel.db --fromchanneldb ./.lnd/data/graph/testnet/channel.db
Input your 24-word mnemonic separated by spaces: ***
Input your cipher seed passphrase (press enter if your seed doesn't have a passphrase):
```

If the node does not have a taproot channel, this command completes successfully:

```
2023-12-31 18:32:20.935 [INF] CHAN: Writing result to results/forceclose-2023-12-31-18-32-20.json
```

After I opened a taproot channel, it started crashing with the following error:

```
Error: malformed signature: no header magic
Usage:
chantools forceclose [flags]
...
```

I verified this observation on two nodes (testnet and signet).

## Analysis

I think, that the root cause is in the function [LightningChannel.CreateSignDesc](https://github.com/lightninglabs/chantools/blob/5cf7fd60c48174608f0330d08298b35472425a17/lnd/channel.go#L24-L54) which is not aware of taproot channels.

lnd's function [createSignDesc](https://github.com/lightningnetwork/lnd/blob/4d8fa349ca405a42548717c17cc689e6612ff37a/lnwallet/channel.go#L1492) has taproot aware implementation.

In https://github.com/lightninglabs/chantools/pull/95 I'm adding the code building SignDescriptor from a channel backup. I think most of that code can be factored into a generic function, which can be used by LightningChannel.CreateSignDesc as well. Maybe even chantools can use a common function from LND to avoid diversions in the future.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with LightningChannel.CreateSignDesc in lnd/channel.go and compare it with LND's taproot-aware createSignDesc implementation. Review the SignDescriptor construction discussed in pull request 95, then reproduce the forceclose command with a taproot channel. Done means taproot forceclose no longer reports a malformed signature while non-taproot channels continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
blockchain
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.