lnwire: update Sig to support both ECDSA and schnorr sigs
In this commit, we update the Sig type to support ECDSA and schnorr signatures. We need to do this as the HTLC signatures will become schnorr sigs for taproot channels. The current spec draft opts to overload this field since both the sigs are actually 64 bytes in length. The only consideration with this move is that callers need to "coerce" a sig to the proper type if they need schnorr signatures.
This commit is contained in:
29 files changed
+296
-128
No files matched your search
@@ -369,24 +369,26 @@ func (t *backupTask) craftSessionPayload(
|
||||
|
||||
// Re-encode the DER signature into a fixed-size 64 byte
|
||||
// signature.
|
||||
signature, err := lnwire.NewSigFromRawSignature(rawSignature)
|
||||
signature, err := lnwire.NewSigFromECDSARawSignature(
|
||||
rawSignature,
|
||||
)
|
||||
if err != nil {
|
||||
return hint, nil, err
|
||||
}
|
||||
|
||||
// Finally, copy the serialized signature into the justice kit,
|
||||
// using the input's witness type to select the appropriate
|
||||
// field.
|
||||
// field
|
||||
switch inp.WitnessType() {
|
||||
case input.CommitmentRevoke:
|
||||
copy(justiceKit.CommitToLocalSig[:], signature[:])
|
||||
justiceKit.CommitToLocalSig = signature
|
||||
|
||||
case input.CommitSpendNoDelayTweakless:
|
||||
fallthrough
|
||||
case input.CommitmentNoDelay:
|
||||
fallthrough
|
||||
case input.CommitmentToRemoteConfirmed:
|
||||
copy(justiceKit.CommitToRemoteSig[:], signature[:])
|
||||
justiceKit.CommitToRemoteSig = signature
|
||||
default:
|
||||
return hint, nil, fmt.Errorf("invalid witness type: %v",
|
||||
inp.WitnessType())
|
||||
|
||||
Reference in new issue
Block a user