2019-01-16 15:47:43 +01:00
|
|
|
package input
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/btcsuite/btcd/wire"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Signer represents an abstract object capable of generating raw signatures as
|
|
|
|
// well as full complete input scripts given a valid SignDescriptor and
|
|
|
|
// transaction. This interface fully abstracts away signing paving the way for
|
|
|
|
// Signer implementations such as hardware wallets, hardware tokens, HSM's, or
|
|
|
|
// simply a regular wallet.
|
|
|
|
type Signer interface {
|
2022-04-27 22:20:34 +02:00
|
|
|
// MuSig2Signer is an embedded interface to make sure all our signers
|
|
|
|
// also support MuSig2 signing, so we can forward calls to a remote
|
|
|
|
// signer as well.
|
|
|
|
MuSig2Signer
|
|
|
|
|
2019-01-16 15:47:43 +01:00
|
|
|
// SignOutputRaw generates a signature for the passed transaction
|
|
|
|
// according to the data within the passed SignDescriptor.
|
|
|
|
//
|
|
|
|
// NOTE: The resulting signature should be void of a sighash byte.
|
2022-01-05 11:04:14 +01:00
|
|
|
SignOutputRaw(tx *wire.MsgTx, signDesc *SignDescriptor) (Signature,
|
|
|
|
error)
|
2019-01-16 15:47:43 +01:00
|
|
|
|
|
|
|
// ComputeInputScript generates a complete InputIndex for the passed
|
|
|
|
// transaction with the signature as defined within the passed
|
|
|
|
// SignDescriptor. This method should be capable of generating the
|
2022-06-27 22:00:07 +02:00
|
|
|
// proper input script for both regular p2wkh/p2tr outputs and p2wkh
|
|
|
|
// outputs nested within a regular p2sh output.
|
2019-01-16 15:47:43 +01:00
|
|
|
//
|
|
|
|
// NOTE: This method will ignore any tweak parameters set within the
|
|
|
|
// passed SignDescriptor as it assumes a set of typical script
|
2022-06-27 22:00:07 +02:00
|
|
|
// templates (p2wkh, p2tr, np2wkh, etc).
|
2022-01-05 11:04:14 +01:00
|
|
|
ComputeInputScript(tx *wire.MsgTx, signDesc *SignDescriptor) (*Script,
|
|
|
|
error)
|
2019-01-16 15:47:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Script represents any script inputs required to redeem a previous
|
|
|
|
// output. This struct is used rather than just a witness, or scripSig in order
|
|
|
|
// to accommodate nested p2sh which utilizes both types of input scripts.
|
|
|
|
type Script struct {
|
|
|
|
// Witness is the full witness stack required to unlock this output.
|
|
|
|
Witness wire.TxWitness
|
|
|
|
|
|
|
|
// SigScript will only be populated if this is an input script sweeping
|
|
|
|
// a nested p2sh output.
|
|
|
|
SigScript []byte
|
|
|
|
}
|