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.
This commit is contained in:
Olaoluwa Osuntokun 2023-01-16 19:55:21 -08:00
parent 9b422acffe
commit 843c62b59d
No known key found for this signature in database
GPG key ID: 3BBD59E99B280306

View file

@ -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
}