Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]: [lncli] lncli pendingsweeps returns error unhandled witness type for input #8322

Closed
hsjoberg opened this issue Dec 29, 2023 · 7 comments · Fixed by #8431
Closed

[bug]: [lncli] lncli pendingsweeps returns error unhandled witness type for input #8322

hsjoberg opened this issue Dec 29, 2023 · 7 comments · Fixed by #8431
Assignees
Labels
beginner Issues suitable for new developers bug Unintended code behaviour P1 MUST be fixed or reviewed taproot chans utxo sweeping
Milestone

Comments

@hsjoberg
Copy link
Contributor

Background

I'm running into this error when trying to run lncli pendingsweeps or lncli wallet bumpclosefee:

[lncli] rpc error: code = Unknown desc = unhandled witness type TaprootAnchorSweepSpend for input f490999ae4fe7b53227e57b4e8e04e854a5f6cac666da625f05da389bd1eeed5:1

I'm not sure what more information I can give, just ask if you need anything more.

Your environment

  • lnd version 0.17.2-beta commit=v0.17.2-beta
  • Ubuntu
  • bitcoind backend

Cheers
Hampus

@hsjoberg hsjoberg added bug Unintended code behaviour needs triage labels Dec 29, 2023
@hsjoberg
Copy link
Contributor Author

Just a guess, but I suppose the taproot chan anchors need to be included in the input types?

allWitnessTypes = map[input.WitnessType]WitnessType{
input.CommitmentTimeLock: WitnessType_COMMITMENT_TIME_LOCK,
input.CommitmentNoDelay: WitnessType_COMMITMENT_NO_DELAY,
input.CommitmentRevoke: WitnessType_COMMITMENT_REVOKE,
input.HtlcOfferedRevoke: WitnessType_HTLC_OFFERED_REVOKE,
input.HtlcAcceptedRevoke: WitnessType_HTLC_ACCEPTED_REVOKE,
input.HtlcOfferedTimeoutSecondLevel: WitnessType_HTLC_OFFERED_TIMEOUT_SECOND_LEVEL,
input.HtlcAcceptedSuccessSecondLevel: WitnessType_HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL,
input.HtlcOfferedRemoteTimeout: WitnessType_HTLC_OFFERED_REMOTE_TIMEOUT,
input.HtlcAcceptedRemoteSuccess: WitnessType_HTLC_ACCEPTED_REMOTE_SUCCESS,
input.HtlcSecondLevelRevoke: WitnessType_HTLC_SECOND_LEVEL_REVOKE,
input.WitnessKeyHash: WitnessType_WITNESS_KEY_HASH,
input.NestedWitnessKeyHash: WitnessType_NESTED_WITNESS_KEY_HASH,
input.CommitmentAnchor: WitnessType_COMMITMENT_ANCHOR,
input.HtlcOfferedTimeoutSecondLevelInputConfirmed: WitnessType_HTLC_OFFERED_TIMEOUT_SECOND_LEVEL_INPUT_CONFIRMED,
input.HtlcAcceptedSuccessSecondLevelInputConfirmed: WitnessType_HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL_INPUT_CONFIRMED,
input.CommitSpendNoDelayTweakless: WitnessType_COMMITMENT_NO_DELAY_TWEAKLESS,
input.CommitmentToRemoteConfirmed: WitnessType_COMMITMENT_TO_REMOTE_CONFIRMED,
input.LeaseCommitmentTimeLock: WitnessType_LEASE_COMMITMENT_TIME_LOCK,
input.LeaseCommitmentToRemoteConfirmed: WitnessType_LEASE_COMMITMENT_TO_REMOTE_CONFIRMED,
input.LeaseHtlcOfferedTimeoutSecondLevel: WitnessType_LEASE_HTLC_OFFERED_TIMEOUT_SECOND_LEVEL,
input.LeaseHtlcAcceptedSuccessSecondLevel: WitnessType_LEASE_HTLC_ACCEPTED_SUCCESS_SECOND_LEVEL,
input.TaprootPubKeySpend: WitnessType_TAPROOT_PUB_KEY_SPEND,
}

@hsjoberg
Copy link
Contributor Author

It's a bit unclear to me if txgenerator.go's createSweepTx() handles Taproot.
Presumably it does, so then just adding the taproot types to allWitnessTypes should work?

@ziggie1984
Copy link
Collaborator

Nice catch :) You are correct you need to add the new taproot types to the walletrpc enum: WitnessType and then add them as well to the allWitnessTypes mapping. A test guarantees that the allWitnessTypes always reflects all types of the enum. (TestWitnessTypeMapping)

Do you want to do the change ?

@yyforyongyu yyforyongyu added P1 MUST be fixed or reviewed taproot chans labels Jan 2, 2024
@saubyk saubyk added this to the v0.18.0 milestone Jan 2, 2024
@saubyk saubyk added this to lnd v0.18 Jan 2, 2024
@saubyk saubyk moved this to 📋 Backlog in lnd v0.18 Jan 2, 2024
@ziggie1984 ziggie1984 added the beginner Issues suitable for new developers label Jan 2, 2024
@jimbrend
Copy link

jimbrend commented Jan 19, 2024

Why are pendingsweeps related to pendingchannel close?

Why are we closing ln channels like this?

Out of curiosity, may you ELI5?

Since is not remotesweep correlated to a pending channel closure vs. the command:

lncli_pending_channels? etc. etc. via the following implementations:

e.g.

eclair*
LND,
Core Lightning?

@hsjoberg
Copy link
Contributor Author

@jimbrend basically pendingsweeps has code to check for UTXO types, where the taproot ones are missing. So the procedure fails.

witnessType, ok := allWitnessTypes[pendingInput.WitnessType]
if !ok {
return nil, fmt.Errorf("unhandled witness type %v for "+
"input %v", pendingInput.WitnessType,
pendingInput.OutPoint)
}

@jimbrend
Copy link

jimbrend commented Jan 29, 2024

Ok, thank you for confirming,

Unrelated just consolidating my thought process on other issue resolutions...

This is an ongoing issue with so many pendingchannel closures, I imagine this is also low-hanging fruit for malicious users targeting insecure lightning nodes.

I believe the remedy to be,
Documenting every instance of why we can't properly close channels including the following AFAIK:

  • eclair, LND, Core Lightning, and other implementation mismatches
  • One Lightning Node being offline and not able to accept the closure causing a zombie channel
  • and all the nuances the above causes that requires us diving into manual intervention such as remotesweep commands AND

chantools which no non-technical user can dare master yet they succumb to idk-- a years time of UX troubles?

I will work on documenting a list and cross-referencing this, because this is a big issue imo. Frustrating is it not, no?

p.s. i livestreamed this in the Twitch software and development category LUL

@kaloudis
Copy link
Contributor

I hit the same error running lncli wallet bumpclosefee

@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in lnd v0.18 Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginner Issues suitable for new developers bug Unintended code behaviour P1 MUST be fixed or reviewed taproot chans utxo sweeping
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

6 participants