github.com/decred/dcrlnd@v0.7.6/input/signer.go (about)

     1  package input
     2  
     3  import (
     4  	"github.com/decred/dcrd/wire"
     5  )
     6  
     7  // Signer represents an abstract object capable of generating raw signatures as
     8  // well as full complete input scripts given a valid SignDescriptor and
     9  // transaction. This interface fully abstracts away signing paving the way for
    10  // Signer implementations such as hardware wallets, hardware tokens, HSM's, or
    11  // simply a regular wallet.
    12  type Signer interface {
    13  	// SignOutputRaw generates a signature for the passed transaction
    14  	// according to the data within the passed SignDescriptor.
    15  	//
    16  	// NOTE: The resulting signature should be void of a sighash byte.
    17  	SignOutputRaw(tx *wire.MsgTx, signDesc *SignDescriptor) (Signature,
    18  		error)
    19  
    20  	// ComputeInputScript generates a complete InputIndex for the passed
    21  	// transaction with the signature as defined within the passed
    22  	// SignDescriptor. This method should be capable of generating the
    23  	// proper input script for regular p2pkh.
    24  	//
    25  	// NOTE: This method will ignore any tweak parameters set within the
    26  	// passed SignDescriptor as it assumes a set of typical script
    27  	// templates (p2wkh, np2wkh, etc).
    28  	ComputeInputScript(tx *wire.MsgTx, signDesc *SignDescriptor) (*Script,
    29  		error)
    30  }
    31  
    32  // InputScript represents any script inputs required to redeem a previous
    33  // output. This struct is used rather than just a witness, or scripSig in order
    34  // to accommodate nested p2sh which utilizes both types of input scripts.
    35  type Script struct {
    36  	// Witness is the full witness stack required to unlock this output.
    37  	//
    38  	// On decred this is used to store the individual elements used to
    39  	// build the final signature script.
    40  	Witness [][]byte
    41  
    42  	//  SigScript contains the full signature script witness data.
    43  	//
    44  	// On Decred this is mostly unused since we use the invidual elements
    45  	// of Witness above and convert to the final sig script by using the
    46  	// WitnessStackToSigScript() function.
    47  	SigScript []byte
    48  }