mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-07 11:22:10 +02:00
input: add new ParseSignature helper func
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcec/v2"
|
"github.com/btcsuite/btcd/btcec/v2"
|
||||||
|
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
|
||||||
"github.com/btcsuite/btcd/btcec/v2/schnorr"
|
"github.com/btcsuite/btcd/btcec/v2/schnorr"
|
||||||
"github.com/btcsuite/btcd/btcec/v2/schnorr/musig2"
|
"github.com/btcsuite/btcd/btcec/v2/schnorr/musig2"
|
||||||
"github.com/btcsuite/btcd/btcutil"
|
"github.com/btcsuite/btcd/btcutil"
|
||||||
@@ -64,6 +65,17 @@ type Signature interface {
|
|||||||
Verify([]byte, *btcec.PublicKey) bool
|
Verify([]byte, *btcec.PublicKey) bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ParseSignature parses a raw signature into an input.Signature instance. This
|
||||||
|
// routine supports parsing normal ECDSA DER encoded signatures, as well as
|
||||||
|
// schnorr signatures.
|
||||||
|
func ParseSignature(rawSig []byte) (Signature, error) {
|
||||||
|
if len(rawSig) == schnorr.SignatureSize {
|
||||||
|
return schnorr.ParseSignature(rawSig)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ecdsa.ParseDERSignature(rawSig)
|
||||||
|
}
|
||||||
|
|
||||||
// WitnessScriptHash generates a pay-to-witness-script-hash public key script
|
// WitnessScriptHash generates a pay-to-witness-script-hash public key script
|
||||||
// paying to a version 0 witness program paying to the passed redeem script.
|
// paying to a version 0 witness program paying to the passed redeem script.
|
||||||
func WitnessScriptHash(witnessScript []byte) ([]byte, error) {
|
func WitnessScriptHash(witnessScript []byte) ([]byte, error) {
|
||||||
|
Reference in New Issue
Block a user