From 843c62b59da8fb68ad9684f42c3a544d9b272ca8 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 16 Jan 2023 19:55:21 -0800 Subject: [PATCH] lnwallet: ensure that SignOutputRaw can sign w/ non-default sighash for schnorr sigs Before this commitment, we'd end up failing in `schnorr.ParseSignature` if a non-default sighash was used. To fix that, we'll slice the signature to only pass in the sig w/o the sighash flag. --- lnwallet/btcwallet/signer.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lnwallet/btcwallet/signer.go b/lnwallet/btcwallet/signer.go index 91ee53e80..9522cefc4 100644 --- a/lnwallet/btcwallet/signer.go +++ b/lnwallet/btcwallet/signer.go @@ -401,9 +401,19 @@ func (b *BtcWallet) SignOutputRaw(tx *wire.MsgTx, if err != nil { return nil, err } + + default: + return nil, fmt.Errorf("unknown sign method: %v", + signDesc.SignMethod) } - sig, err := schnorr.ParseSignature(rawSig) + // The signature returned above might have a sighash flag + // attached if a non-default type was used. We'll slice this + // off if it exists to ensure we can properly parse the raw + // signature. + sig, err := schnorr.ParseSignature( + rawSig[:schnorr.SignatureSize], + ) if err != nil { return nil, err }